using System; using System.Collections.Generic; using System.IO; using UnityEngine; public static class ControllerShortcutSettingData { public static ControllerShortcutSettingData.OvrControllerShortcutConfig config { get { ControllerShortcutSettingData.LoadDefault(); return ControllerShortcutSettingData.m_Config; } } public static void LoadDefault() { if (ControllerShortcutSettingData.m_IsLoadedDefault) { return; } ControllerShortcutSettingData.m_IsLoadedDefault = true; ControllerShortcutSettingData.m_Config = ControllerShortcutSettingData.m_Config.ReadAndSet(); } private static ControllerShortcutSettingData.OvrControllerShortcutConfig m_Config = new ControllerShortcutSettingData.OvrControllerShortcutConfig(); private static bool m_IsLoadedDefault = false; [Serializable] public class OvrControllerShortcutConfig : ISerializationCallbackReceiver { public void OnBeforeSerialize() { this.m_nVersion = 1480; } public void OnAfterDeserialize() { } public bool Write() { string contents = JsonUtility.ToJson(this, true); string path = Path.Combine(GameMain.Instance.SerializeStorageManager.StoreDirectoryPath, "OvrControllerShortcutConfig.json"); try { File.WriteAllText(path, contents); } catch { Debug.LogError("OvrControllerShortcutConfig.json の書き込みに失敗。"); return false; } return true; } public ControllerShortcutSettingData.OvrControllerShortcutConfig ReadAndSet() { string path = Path.Combine(GameMain.Instance.SerializeStorageManager.StoreDirectoryPath, "OvrControllerShortcutConfig.json"); if (!File.Exists(path)) { this.CreateDefaultData(); this.Write(); } string json; try { json = File.ReadAllText(path); } catch { Debug.LogError("OvrControllerShortcutConfig.json の読込に失敗。"); return this; } return JsonUtility.FromJson(json); } private void CreateDefaultData() { this.FaceListRight = new List(); List list = new List(); list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["通常"])); list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["微笑み"])); list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["にっこり"])); list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["優しさ"])); list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["ぷんすか"])); list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["むー"])); list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["泣き"])); list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["ダンスジト目"])); for (int i = 0; i < list.Count; i++) { PhotoFaceDataShortcut.FaceData faceData = new PhotoFaceDataShortcut.FaceData(); faceData.data = list[i]; this.FaceListRight.Add(faceData); } this.FaceListLeft = new List(); for (int j = 0; j < list.Count; j++) { PhotoFaceDataShortcut.FaceData faceData2 = new PhotoFaceDataShortcut.FaceData(); faceData2.data = list[j]; this.FaceListLeft.Add(faceData2); } this.isDirectMode = true; this.isEveryShowMode = true; this.maintainPelvisPosition = 0.3f; this.bodyPosStiffness = 0.55f; this.bodyRotStiffness = 0.1f; this.chestRotationWeight = 0.3f; this.selfCameraFOV = 0.5f; this.use1TrackerForHead = false; this.use23TrackerForFoot = false; this.use12TrackerForFoot = false; } public bool isDirectMode { get { return this.IsDirectShortcutMode; } set { this.IsDirectShortcutMode = value; } } public bool isEveryShowMode { get { return this.IsEveryShowMode; } set { this.IsEveryShowMode = value; } } public List faceListRight { get { return this.FaceListRight; } set { this.FaceListRight = value; } } public List faceListLeft { get { return this.FaceListLeft; } set { this.FaceListLeft = value; } } public float maintainPelvisPosition { get { return this.MaintainPelvisPosition; } set { this.MaintainPelvisPosition = Mathf.Clamp(value, 0f, 1f); } } public float bodyPosStiffness { get { return this.BodyPosStiffness; } set { this.BodyPosStiffness = Mathf.Clamp(value, 0f, 1f); } } public float bodyRotStiffness { get { return this.BodyRotStiffness; } set { this.BodyRotStiffness = Mathf.Clamp(value, 0f, 1f); } } public float chestRotationWeight { get { return this.ChestRotationWeight; } set { this.ChestRotationWeight = Mathf.Clamp(value, 0f, 1f); } } public float selfCameraFOV { get { return this.SelfCameraFOV; } set { this.SelfCameraFOV = Mathf.Clamp(value, 0f, 1f); } } public bool use1TrackerForHead { get { return this.Use1TrackerForHead; } set { this.Use1TrackerForHead = value; } } public bool use23TrackerForFoot { get { return this.Use23TrackerForFoot; } set { this.Use23TrackerForFoot = value; } } public bool use12TrackerForFoot { get { return this.Use12TrackerForFoot; } set { this.Use12TrackerForFoot = value; } } private const string CONF_NAME = "OvrControllerShortcutConfig.json"; [SerializeField] private int m_nVersion = 1480; [SerializeField] private bool IsDirectShortcutMode = true; [SerializeField] private bool IsEveryShowMode = true; [SerializeField] private List FaceListRight = new List(); [SerializeField] private List FaceListLeft = new List(); [SerializeField] private float MaintainPelvisPosition = 0.3f; [SerializeField] private float BodyPosStiffness = 0.55f; [SerializeField] private float BodyRotStiffness = 0.1f; [SerializeField] private float ChestRotationWeight = 0.3f; [SerializeField] private float SelfCameraFOV = 0.5f; [SerializeField] private bool Use1TrackerForHead; [SerializeField] private bool Use23TrackerForFoot; [SerializeField] private bool Use12TrackerForFoot; } }