コード例 #1
0
        public void BindSceneInputSettings()
        {
            if (!m_InputsSettings.hasBrokenBindings)
            {
                return;
            }

            var sceneInputs = SceneHook.GetInputsComponent(m_AssetID);

            foreach (var input in sceneInputs.m_Settings)
            {
                m_InputsSettings.Rebind(input);
            }

#if UNITY_EDITOR
            if (m_InputsSettings.hasBrokenBindings)
            {
                // only supported case is scene stored input settings are missing (for example: new scene loaded that does not contain the scene stored inputs.)
                m_InputsSettings.RepareMissingBindings();
            }
#endif

            if (m_InputsSettings.hasBrokenBindings)
            {
                Debug.LogError("Recorder: missing input settings");
            }
        }
コード例 #2
0
        public void OnDestroy()
        {
            for (int i = 0; i < m_InputsSettingsAssets.Count; i++)
            {
                if (m_InputsSettingsAssets[i] is InputBinder)
                {
                    SceneHook.UnregisterInputSettingObj(ownerRecorderSettingsAssetId, m_InputsSettings[i]);
                }

                UnityHelpers.Destroy(m_InputsSettingsAssets[i], true);
            }
        }
コード例 #3
0
        void ReleaseAt(int index)
        {
            if (m_InputsSettingsAssets[index] is InputBinder)
            {
                SceneHook.UnregisterInputSettingObj(m_ParentAssetId, m_InputsSettings[index]);
            }

            UnityHelpers.Destroy(m_InputsSettingsAssets[index], true);

            m_InputsSettings[index]       = null;
            m_InputsSettingsAssets[index] = null;
        }
コード例 #4
0
 public void RepareMissingBindings()
 {
     for (int i = 0; i < m_InputsSettingsAssets.Count; i++)
     {
         var ib = m_InputsSettingsAssets[i] as InputBinder;
         if (ib != null && m_InputsSettings[i] == null)
         {
             var newInput = ScriptableObject.CreateInstance(ib.inputType) as RecorderInputSetting;
             newInput.m_DisplayName = ib.m_DisplayName;
             m_InputsSettings[i]    = newInput;
             SceneHook.RegisterInputSettingObj(m_ParentAssetId, newInput);
         }
     }
 }
コード例 #5
0
        public void Rebuild()
        {
            m_InputsSettings = new List <RecorderInputSetting>();

            foreach (var inputAsset in m_InputsSettingsAssets)
            {
                if (inputAsset is InputBinder)
                {
                    var  sceneInputs = SceneHook.GetInputsComponent(ownerRecorderSettingsAssetId);
                    bool found       = false;
                    foreach (var input in sceneInputs.m_Settings)
                    {
                        if (input.m_Id == inputAsset.m_Id)
                        {
                            m_InputsSettings.Add(input);
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        var binder = inputAsset as InputBinder;
                        if (string.IsNullOrEmpty(binder.typeName))
                        {
                            Debug.LogError("Recorder Input asset in invalid!");
                        }
                        else
                        {
                            if (Application.isPlaying)
                            {
                                Debug.LogError("Recorder input setting missing from scene, adding with default state.");
                            }
                            else if (Verbose.enabled)
                            {
                                Debug.Log("Recorder input setting missing from scene, adding with default state.");
                            }
                            var replacementInput = ScriptableObject.CreateInstance(binder.inputType) as RecorderInputSetting;
                            replacementInput.m_Id = inputAsset.m_Id;
                            m_InputsSettings.Add(replacementInput);
                        }
                    }
                }
                else
                {
                    m_InputsSettings.Add(inputAsset);
                }
            }
        }
コード例 #6
0
        void ReleaseAt(int index)
        {
#if UNITY_EDITOR
            bool isBinder = m_InputsSettingsAssets[index] is InputBinder;
            if (isBinder)
            {
                SceneHook.UnregisterInputSettingObj(ownerRecorderSettingsAssetId, m_InputsSettings[index]);
            }
#endif
            UnityHelpers.Destroy(m_InputsSettingsAssets[index], true);
#if UNITY_EDITOR
            AssetDatabase.SaveAssets();
#endif

            m_InputsSettings[index]       = null;
            m_InputsSettingsAssets[index] = null;
        }
コード例 #7
0
        public void ReplaceAt(int index, RecorderInputSetting input)
        {
            if (m_InputsSettingsAssets == null || m_InputsSettings.Count <= index)
            {
                throw new ArgumentException("Index out of range");
            }

            // Release input
            ReleaseAt(index);

            m_InputsSettings[index] = input;
            if (input.storeInScene)
            {
                var binder = ScriptableObject.CreateInstance <InputBinder>();
                binder.name                   = "Scene-Stored";
                binder.m_DisplayName          = input.m_DisplayName;
                binder.typeName               = input.GetType().AssemblyQualifiedName;
                binder.m_Id                   = input.m_Id;
                m_InputsSettingsAssets[index] = binder;
                SceneHook.RegisterInputSettingObj(ownerRecorderSettingsAssetId, input);

#if UNITY_EDITOR
                var assetPath = AssetDatabase.GUIDToAssetPath(ownerRecorderSettingsAssetId);
                AssetDatabase.AddObjectToAsset(binder, assetPath);
                AssetDatabase.SaveAssets();
#endif
            }
            else
            {
                m_InputsSettingsAssets[index] = input;
#if UNITY_EDITOR
                AssetDatabase.AddObjectToAsset(input, AssetDatabase.GUIDToAssetPath(ownerRecorderSettingsAssetId));
                AssetDatabase.SaveAssets();
#endif
            }
#if UNITY_EDITOR
            AssetDatabase.Refresh();
#endif
        }