Example #1
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);
         }
     }
 }
        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
        }