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