Handling merge
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e5cf234fec296c4cb0231cc8ad204ea
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityGLTF;
|
||||
|
||||
|
||||
public class ModelExporter
|
||||
{
|
||||
public static string RetrieveTexturePath(UnityEngine.Texture texture)
|
||||
{
|
||||
string m_Path = Application.dataPath;
|
||||
var path = m_Path + "/../unknown/" + texture.name; ;
|
||||
return path;
|
||||
}
|
||||
|
||||
public static void Export(Transform[] transforms, string sceneName)
|
||||
{
|
||||
var exportOptions = new UnityGLTF.ExportOptions { TexturePathRetriever = RetrieveTexturePath };
|
||||
var exporter = new GLTFSceneExporter(transforms, exportOptions);
|
||||
|
||||
string m_Path = Application.dataPath;
|
||||
|
||||
string path = m_Path + "/../Exported/" + sceneName;
|
||||
|
||||
var resultFile = GLTFSceneExporter.GetFileName(path, sceneName, ".gltf");
|
||||
|
||||
exporter.SaveGLTFandBin(path, sceneName);
|
||||
|
||||
}
|
||||
|
||||
public static void exportModel(GameObject gameobj)
|
||||
{
|
||||
string sceneName = gameobj.name;
|
||||
Transform[] rootTransforms = new Transform[] { gameobj.transform };
|
||||
|
||||
Export(rootTransforms, sceneName);
|
||||
}
|
||||
}
|
||||
+1
-3
@@ -1,7 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab30c2ca30e1a144c97b8e0cc5c3d316
|
||||
timeCreated: 1535288250
|
||||
licenseType: Free
|
||||
guid: bf3b5b616874ba1479b187dd881b2ebb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,111 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
|
||||
public class TextureExporter
|
||||
{
|
||||
static public Texture2D duplicateTexture(Texture2D source)
|
||||
{
|
||||
RenderTexture renderTex = RenderTexture.GetTemporary(
|
||||
source.width,
|
||||
source.height,
|
||||
0,
|
||||
RenderTextureFormat.Default,
|
||||
RenderTextureReadWrite.Linear);
|
||||
|
||||
Graphics.Blit(source, renderTex);
|
||||
RenderTexture previous = RenderTexture.active;
|
||||
RenderTexture.active = renderTex;
|
||||
Texture2D readableText = new Texture2D(source.width, source.height);
|
||||
readableText.ReadPixels(new Rect(0, 0, renderTex.width, renderTex.height), 0, 0);
|
||||
readableText.Apply();
|
||||
RenderTexture.active = previous;
|
||||
RenderTexture.ReleaseTemporary(renderTex);
|
||||
return readableText;
|
||||
}
|
||||
|
||||
static public void exportAllTexture(GameObject gameobj)
|
||||
{
|
||||
string m_Path = Application.dataPath;
|
||||
|
||||
string savePath = m_Path + "/../Exported/" + gameobj.name + "/Texture2D/";
|
||||
|
||||
if (!Directory.Exists(savePath))
|
||||
{
|
||||
Directory.CreateDirectory(savePath);
|
||||
}
|
||||
|
||||
foreach (SkinnedMeshRenderer skin_mesh in gameobj.transform.GetComponentsInChildren<SkinnedMeshRenderer>())
|
||||
{
|
||||
foreach (Material mat in skin_mesh.sharedMaterials)
|
||||
{
|
||||
//获得材质的所有属性名,如果改属性名对应的是贴图,提取该贴图
|
||||
Shader mat_shader = mat.shader;
|
||||
int p_num = mat_shader.GetPropertyCount();
|
||||
Debug.Log(p_num);
|
||||
for (int i = 0; i < p_num; i++)
|
||||
{
|
||||
string p_name = mat_shader.GetPropertyName(i);
|
||||
if (mat_shader.GetPropertyType(i) == UnityEngine.Rendering.ShaderPropertyType.Texture)
|
||||
{
|
||||
//Debug.Log("Hello!");
|
||||
Debug.Log(p_name);
|
||||
Texture2D mat_texture = (Texture2D)mat.GetTexture(p_name);
|
||||
if (mat_texture)
|
||||
{
|
||||
//Debug.Log("There is a Name!");
|
||||
string tex_name = mat_texture.name;
|
||||
string tex_path = savePath + tex_name + ".png";
|
||||
if (!File.Exists(tex_path))
|
||||
{
|
||||
mat_texture = duplicateTexture(mat_texture);
|
||||
byte[] bytes = mat_texture.EncodeToPNG();
|
||||
File.WriteAllBytes(tex_path, bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (MeshRenderer mr in gameobj.transform.GetComponentsInChildren<MeshRenderer>())
|
||||
{
|
||||
foreach (Material mat in mr.sharedMaterials)
|
||||
{
|
||||
//获得材质的所有属性名,如果改属性名对应的是贴图,提取该贴图
|
||||
Shader mat_shader = mat.shader;
|
||||
int p_num = mat_shader.GetPropertyCount();
|
||||
Debug.Log(p_num);
|
||||
for (int i = 0; i < p_num; i++)
|
||||
{
|
||||
//Debug.Log(mat_shader.GetPropertyName(i));
|
||||
//Debug.Log(mat_shader.GetPropertyType(i));
|
||||
string p_name = mat_shader.GetPropertyName(i);
|
||||
if (mat_shader.GetPropertyType(i) == UnityEngine.Rendering.ShaderPropertyType.Texture)
|
||||
{
|
||||
//Debug.Log("Hello!");
|
||||
Debug.Log(p_name);
|
||||
Texture2D mat_texture = (Texture2D)mat.GetTexture(p_name);
|
||||
if (mat_texture)
|
||||
{
|
||||
//Debug.Log("There is a Name!");
|
||||
string tex_name = mat_texture.name;
|
||||
string tex_path = savePath + tex_name + ".png";
|
||||
if (!File.Exists(tex_path))
|
||||
{
|
||||
mat_texture = duplicateTexture(mat_texture);
|
||||
byte[] bytes = mat_texture.EncodeToPNG();
|
||||
File.WriteAllBytes(tex_path, bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log("提取成功");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7af2b716c09cdaa459a69078c84d6e9a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -63,6 +63,7 @@ public class UmaUIContainer : MonoBehaviour
|
||||
public Text Text;
|
||||
public Button Button;
|
||||
public Slider Slider;
|
||||
public Toggle Toggle;
|
||||
public Image Image;
|
||||
public Image ToggleImage;
|
||||
}
|
||||
|
||||
@@ -75,15 +75,16 @@ public class UmaContainer : MonoBehaviour
|
||||
|
||||
[Header("Other")]
|
||||
public CharaShaderEffectData ShaderEffectData;
|
||||
private List<MaterialHelper> Materials = new List<MaterialHelper>();
|
||||
|
||||
public void Initialize()
|
||||
public void Initialize(bool smile)
|
||||
{
|
||||
TrackTarget = Camera.main.gameObject;
|
||||
UpBodyPosition = UpBodyBone.transform.localPosition;
|
||||
UpBodyRotation = UpBodyBone.transform.localRotation;
|
||||
|
||||
//Models must be merged before handling extra morphs
|
||||
if (FaceDrivenKeyTarget)
|
||||
if (FaceDrivenKeyTarget && smile)
|
||||
FaceDrivenKeyTarget.ChangeMorphWeight(FaceDrivenKeyTarget.MouthMorphs[3], 1);
|
||||
}
|
||||
|
||||
@@ -142,6 +143,38 @@ public class UmaContainer : MonoBehaviour
|
||||
UmaAnimator.avatar = AvatarBuilder.BuildGenericAvatar(gameObject, gameObject.name);
|
||||
OverrideController = Instantiate(UmaViewerBuilder.Instance.OverrideController);
|
||||
UmaAnimator.runtimeAnimatorController = OverrideController;
|
||||
|
||||
//Materials
|
||||
foreach (var rend in gameObject.GetComponentsInChildren<Renderer>())
|
||||
{
|
||||
for(int i = 0; i < rend.materials.Length; i++)
|
||||
{
|
||||
Material mat = rend.materials[i];
|
||||
|
||||
var matHlp = Materials.FirstOrDefault(m => m.Mat == mat);
|
||||
if (matHlp == null)
|
||||
{
|
||||
matHlp = new MaterialHelper()
|
||||
{
|
||||
Mat = mat,
|
||||
Renderers = new Dictionary<Renderer, List<int>>(),
|
||||
Toggle = Instantiate(UmaViewerUI.Instance.UmaContainerTogglePrefab, UmaViewerUI.Instance.MaterialsList.content)
|
||||
};
|
||||
matHlp.Toggle.Name = mat.name;
|
||||
matHlp.Toggle.Toggle.onValueChanged.AddListener((value) => { Debug.Log("e"); matHlp.ToggleMaterials(value); });
|
||||
Materials.Add(matHlp);
|
||||
}
|
||||
|
||||
if (!matHlp.Renderers.ContainsKey(rend))
|
||||
{
|
||||
matHlp.Renderers.Add(rend, new List<int> { i });
|
||||
}
|
||||
else
|
||||
{
|
||||
matHlp.Renderers[rend].Add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void MergeHairModel()
|
||||
@@ -305,4 +338,28 @@ public class UmaContainer : MonoBehaviour
|
||||
UpBodyBone.transform.localRotation = UpBodyRotation;
|
||||
}
|
||||
}
|
||||
|
||||
class MaterialHelper
|
||||
{
|
||||
public Material Mat;
|
||||
public UmaUIContainer Toggle;
|
||||
public Dictionary<Renderer, List<int>> Renderers;
|
||||
|
||||
public void ToggleMaterials(bool value)
|
||||
{
|
||||
foreach(var rend in Renderers)
|
||||
{
|
||||
Debug.Log(rend.Key.name);
|
||||
Material[] mat = new Material[rend.Key.materials.Length];
|
||||
for(int i = 0; i < mat.Length; i++)
|
||||
{
|
||||
//if material slot is not in list, keep current material
|
||||
//if material slot in list and toggle is on - assign original
|
||||
//if material slot in list and toggle is off - assign invisible
|
||||
mat[i] = rend.Value.Contains(i) ? (value? Mat : UmaViewerBuilder.Instance.TransMaterialCharas ): rend.Key.materials[i];
|
||||
}
|
||||
rend.Key.materials = mat;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,6 +151,7 @@ public enum UmaFileType
|
||||
gacha,
|
||||
gachaselect,
|
||||
guide,
|
||||
heroes,
|
||||
home,
|
||||
imageeffect,
|
||||
item,
|
||||
@@ -160,6 +161,7 @@ public enum UmaFileType
|
||||
manifest,
|
||||
manifest2,
|
||||
manifest3,
|
||||
mapevent,
|
||||
master,
|
||||
minigame,
|
||||
mob,
|
||||
|
||||
@@ -98,15 +98,15 @@ public class UmaDatabaseController
|
||||
|
||||
static IEnumerable<UmaDatabaseEntry> ReadMeta(SqliteConnection conn)
|
||||
{
|
||||
List<UmaDatabaseEntry> entries = new List<UmaDatabaseEntry>();
|
||||
SqliteCommand sqlite_cmd = conn.CreateCommand();
|
||||
sqlite_cmd.CommandText = "SELECT m,n,h,c,d FROM a";
|
||||
SqliteDataReader sqlite_datareader = sqlite_cmd.ExecuteReader();
|
||||
while (sqlite_datareader.Read())
|
||||
{
|
||||
UmaDatabaseEntry entry = null;
|
||||
try
|
||||
{
|
||||
UmaDatabaseEntry entry = new UmaDatabaseEntry()
|
||||
entry = new UmaDatabaseEntry()
|
||||
{
|
||||
Type = (UmaFileType)Enum.Parse(typeof(UmaFileType), sqlite_datareader["m"] as String),
|
||||
Name = sqlite_datareader["n"] as String,
|
||||
@@ -114,11 +114,12 @@ public class UmaDatabaseController
|
||||
Checksum = sqlite_datareader["c"].ToString(),
|
||||
Prerequisites = sqlite_datareader["d"] as String
|
||||
};
|
||||
entries.Add(entry);
|
||||
}
|
||||
catch(Exception e) { Debug.LogError("Error caught: " + e); }
|
||||
|
||||
if (entry != null)
|
||||
yield return entry;
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
static IEnumerable<DataRow> ReadCharaMaster(SqliteConnection conn)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using CriWare;
|
||||
using CriWareFormats;
|
||||
using Gallop;
|
||||
using MiniJSON;
|
||||
using NAudio.Wave;
|
||||
using System;
|
||||
using System.Collections;
|
||||
@@ -290,6 +291,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
}
|
||||
|
||||
CurrentUMAContainer.LoadPhysics(); //Need to load physics before loading FacialMorph
|
||||
CurrentUMAContainer.SetDynamicBoneEnable(UI.DynamicBoneEnable);
|
||||
|
||||
//Load FacialMorph
|
||||
LoadFaceMorph(id, costumeId);
|
||||
@@ -298,9 +300,12 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
CurrentUMAContainer.HeadBone = (GameObject)CurrentUMAContainer.Body.GetComponent<AssetHolder>()._assetTable["head"];
|
||||
CurrentUMAContainer.EyeHeight = CurrentUMAContainer.Head.GetComponent<AssetHolder>()._assetTableValue["head_center_offset_y"];
|
||||
CurrentUMAContainer.MergeModel();
|
||||
CurrentUMAContainer.Initialize();
|
||||
CurrentUMAContainer.Initialize(!UI.isTPose);
|
||||
CurrentUMAContainer.SetHeight(-1);
|
||||
LoadAsset(UmaViewerMain.Instance.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"anm_eve_chr{id}_00_idle01_loop")));
|
||||
if (!UI.isTPose)
|
||||
{
|
||||
LoadAsset(UmaViewerMain.Instance.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"anm_eve_chr{id}_00_idle01_loop")));
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadMobUma(CharaEntry chara, string costumeId, int bodyid = -1)
|
||||
@@ -510,6 +515,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
}
|
||||
|
||||
CurrentUMAContainer.LoadPhysics(); //Need to load physics before loading FacialMorph
|
||||
CurrentUMAContainer.SetDynamicBoneEnable(UI.DynamicBoneEnable);
|
||||
|
||||
//Load FacialMorph
|
||||
LoadFaceMorph(id, costumeId);
|
||||
@@ -518,9 +524,12 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
CurrentUMAContainer.HeadBone = (GameObject)CurrentUMAContainer.Body.GetComponent<AssetHolder>()._assetTable["head"];
|
||||
CurrentUMAContainer.EyeHeight = CurrentUMAContainer.Head.GetComponent<AssetHolder>()._assetTableValue["head_center_offset_y"];
|
||||
CurrentUMAContainer.MergeModel();
|
||||
CurrentUMAContainer.Initialize();
|
||||
CurrentUMAContainer.Initialize(!UI.isTPose);
|
||||
CurrentUMAContainer.SetHeight(-1);
|
||||
LoadAsset(UmaViewerMain.Instance.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"homestand{personality.PadLeft(2, '0')}_loop")));
|
||||
if (!UI.isTPose)
|
||||
{
|
||||
LoadAsset(UmaViewerMain.Instance.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"homestand{personality.PadLeft(2, '0')}_loop")));
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadMiniUma(CharaEntry chara, string costumeId)
|
||||
@@ -1367,7 +1376,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
private void LoadFaceMorph(int id, string costumeId)
|
||||
{
|
||||
if (!CurrentUMAContainer.Head) return;
|
||||
var locatorEntry = Main.AbList.FirstOrDefault(a => a.Name.EndsWith("3d/animator/drivenkeylocator"));
|
||||
var locatorEntry = Main.AbList.FirstOrDefault(a => a.Name == "3d/animator/drivenkeylocator");
|
||||
var bundle = AssetBundle.LoadFromFile(locatorEntry.FilePath);
|
||||
Main.LoadedBundles.Add(locatorEntry.Name, bundle);
|
||||
var locator = Instantiate(bundle.LoadAsset("DrivenKeyLocator"), CurrentUMAContainer.transform) as GameObject;
|
||||
@@ -1836,6 +1845,10 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
UmaViewerUI.Instance.currentFaceDrivenKeyTarget = null;
|
||||
UmaViewerUI.Instance.LoadEmotionPanels(null);
|
||||
UmaViewerUI.Instance.LoadFacialPanels(null);
|
||||
foreach(Transform t in UmaViewerUI.Instance.MaterialsList.content)
|
||||
{
|
||||
Destroy(t.gameObject);
|
||||
}
|
||||
Destroy(CurrentUMAContainer.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
public ScrollRect PropList;
|
||||
public PageManager PropPageCtrl;
|
||||
public ScrollRect SceneList;
|
||||
public ScrollRect MaterialsList;
|
||||
public PageManager ScenePageCtrl;
|
||||
public ScrollRect MessageScrollRect;
|
||||
public Text MessageText;
|
||||
@@ -122,6 +123,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
public GameObject UmaContainerLivePrefab;
|
||||
public GameObject UmaContainerSliderPrefab;
|
||||
public GameObject UmaContainerAssetsPrefab;
|
||||
public UmaUIContainer UmaContainerTogglePrefab;
|
||||
|
||||
private int LoadedAssetCount = 0;
|
||||
[SerializeField] private RectTransform LoadedAssetsPanel;
|
||||
@@ -130,6 +132,8 @@ public class UmaViewerUI : MonoBehaviour
|
||||
|
||||
public bool isCriware = false;
|
||||
public bool isHeadFix = false;
|
||||
public bool isTPose = false;
|
||||
public bool DynamicBoneEnable = true;
|
||||
public bool EnableEyeTracking = true;
|
||||
public bool EnableFaceOverride = true;
|
||||
|
||||
@@ -895,6 +899,11 @@ public class UmaViewerUI : MonoBehaviour
|
||||
isHeadFix = value;
|
||||
}
|
||||
|
||||
public void SetTPose(bool value)
|
||||
{
|
||||
isTPose = value;
|
||||
}
|
||||
|
||||
public void UpdateGifQualityLabel(float value)
|
||||
{
|
||||
GifQualityLabel.text = $"Quality: {(int)value} (default: 10)";
|
||||
@@ -1014,6 +1023,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
|
||||
public void SetDynamicBoneEnable(bool isOn)
|
||||
{
|
||||
DynamicBoneEnable = isOn;
|
||||
if (Builder.CurrentUMAContainer)
|
||||
{
|
||||
Builder.CurrentUMAContainer.SetDynamicBoneEnable(isOn);
|
||||
@@ -1304,6 +1314,16 @@ public class UmaViewerUI : MonoBehaviour
|
||||
MessageScrollRect.verticalNormalizedPosition = 0;
|
||||
}
|
||||
|
||||
public void ExportModel()
|
||||
{
|
||||
if (Builder.CurrentUMAContainer)
|
||||
{
|
||||
//TextureExporter.exportAllTexture(Builder.CurrentUMAContainer.gameObject);
|
||||
ModelExporter.exportModel(Builder.CurrentUMAContainer.gameObject);
|
||||
TextureExporter.exportAllTexture(Builder.CurrentUMAContainer.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void Debug()
|
||||
{
|
||||
var container = Builder.CurrentUMAContainer;
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
"GUID:fd1d627189c561043911a07470238b9c",
|
||||
"GUID:145e2572884581c48a08acf566c1a1d6",
|
||||
"GUID:86ee6720b4f4f604caf8a6add1fd3b06"
|
||||
"GUID:145e2572884581c48a08acf566c1a1d6",
|
||||
"GUID:18d18f811ba286c49814567a3cfba688"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class RuntimeInitializer : MonoBehaviour
|
||||
{
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
#elif UNITY_STANDALONE
|
||||
int isfull = Screen.fullScreen ? 1 : 0;
|
||||
SaveManager.SetInt("ScreenMode", isfull);
|
||||
if(isfull == 0)
|
||||
{
|
||||
SaveManager.SetInt("ScreenWidth", Screen.width);
|
||||
SaveManager.SetInt("ScreenHeight", Screen.height);
|
||||
}
|
||||
SaveManager.Save();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 明示的に初期化する場合
|
||||
/// </summary>
|
||||
public static void CallInitialize()
|
||||
{
|
||||
InitializeBeforeSceneLoad();
|
||||
}
|
||||
|
||||
//[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||
private static void InitializeBeforeSceneLoad()
|
||||
{
|
||||
SaveManager.GetString("先にセーブデータを作成します");
|
||||
|
||||
#if UNITY_EDITOR
|
||||
#elif UNITY_STANDALONE
|
||||
//画面の解像度を設定する
|
||||
int isFullScreen = SaveManager.GetInt("ScreenMode", 1);
|
||||
if(isFullScreen == 1)
|
||||
{
|
||||
int width = Screen.currentResolution.width;
|
||||
int height = Screen.currentResolution.height;
|
||||
|
||||
Screen.SetResolution(width, height, true);
|
||||
|
||||
SaveManager.SetInt("ScreenWidth", width);
|
||||
SaveManager.SetInt("ScreenHeight", height);
|
||||
}
|
||||
else
|
||||
{
|
||||
int width = SaveManager.GetInt("ScreenWidth", 1280);
|
||||
int height = SaveManager.GetInt("ScreenHeight", 720);
|
||||
|
||||
Screen.SetResolution(width, height, false);
|
||||
|
||||
SaveManager.SetInt("ScreenWidth", width);
|
||||
SaveManager.SetInt("ScreenHeight", height);
|
||||
}
|
||||
|
||||
SaveManager.SetInt("ScreenMode", isFullScreen);
|
||||
SaveManager.Save();
|
||||
#endif
|
||||
|
||||
//フレームレートの設定を行う
|
||||
int DontSync = SaveManager.GetInt("vSyncSetting", 1); //デフォルトは垂直同期無し
|
||||
if (DontSync == 1)
|
||||
{
|
||||
QualitySettings.vSyncCount = 0;
|
||||
int FrameRate = SaveManager.GetInt("FrameRate", 1); //デフォルト60
|
||||
switch (FrameRate)
|
||||
{
|
||||
case 0:
|
||||
Application.targetFrameRate = 30;
|
||||
break;
|
||||
case 1:
|
||||
//Every VBlank(60fps)
|
||||
Application.targetFrameRate = 60;
|
||||
break;
|
||||
case 2:
|
||||
//Every VBlank(120fps)
|
||||
Application.targetFrameRate = 120;
|
||||
break;
|
||||
}
|
||||
SaveManager.SetInt("FrameRate", FrameRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
QualitySettings.vSyncCount = 1;
|
||||
int FrameRate = SaveManager.GetInt("FrameRate", 1); //デフォルト60
|
||||
switch (FrameRate)
|
||||
{
|
||||
case 0:
|
||||
//Every Second VBlank(60fpsの半分)
|
||||
QualitySettings.vSyncCount = 2;
|
||||
Application.targetFrameRate = 60;
|
||||
break;
|
||||
case 1:
|
||||
//Every VBlank(60fps)
|
||||
Application.targetFrameRate = 60;
|
||||
break;
|
||||
case 2:
|
||||
//Every VBlank(120fps)
|
||||
Application.targetFrameRate = 120;
|
||||
break;
|
||||
}
|
||||
SaveManager.SetInt("FrameRate", FrameRate);
|
||||
}
|
||||
SaveManager.SetInt("vSyncSetting", DontSync);
|
||||
SaveManager.Save();
|
||||
|
||||
|
||||
// ScriptableObjectテーブルから情報を取得し設定する。
|
||||
var table = Resources.Load("InitializerTable") as InitializerTable;
|
||||
if (table != null)
|
||||
{
|
||||
GameObject obj1 = GameObject.Find("AssetManager");
|
||||
if (obj1 == null)
|
||||
{
|
||||
GameObject assetManager = Instantiate(table.AssetManager);
|
||||
assetManager.name = assetManager.name.Replace("(Clone)", "");
|
||||
GameObject.DontDestroyOnLoad(assetManager);
|
||||
}
|
||||
|
||||
GameObject obj2 = GameObject.Find("ViewLauncher");
|
||||
if (obj2 == null)
|
||||
{
|
||||
GameObject viewLauncher = Instantiate(table.ViewLauncher);
|
||||
viewLauncher.name = viewLauncher.name.Replace("(Clone)", "");
|
||||
GameObject.DontDestroyOnLoad(viewLauncher);
|
||||
}
|
||||
|
||||
GameObject obj3 = GameObject.Find("UIManager");
|
||||
if (obj3 == null)
|
||||
{
|
||||
GameObject uiManager = Instantiate(table.UIManager);
|
||||
uiManager.name = uiManager.name.Replace("(Clone)", "");
|
||||
GameObject.DontDestroyOnLoad(uiManager);
|
||||
}
|
||||
|
||||
GameObject obj4 = GameObject.Find("ResourceManager");
|
||||
if (obj4 == null)
|
||||
{
|
||||
GameObject resourceManager = Instantiate(table.ResourcesManager);
|
||||
resourceManager.name = resourceManager.name.Replace("(Clone)", "");
|
||||
GameObject.DontDestroyOnLoad(resourceManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user