ResetTarget() public méthode

public ResetTarget ( ) : void
Résultat void
        // Call this from Editor's OnInspectorGUI
        public void OnInspectorGUI()
        {
            m_ScratchComponentList.Clear();
            int numNullComponents = GetComponent(m_Stage, m_ScratchComponentList);

            // Have the edited components changed?
            int  numComponents = m_ScratchComponentList.Count;
            bool dirty         = numComponents != m_EditedComponents.Count;

            for (int i = 0; !dirty && i < numComponents; ++i)
            {
                dirty = m_ScratchComponentList[i] != m_EditedComponents[i];
            }
            if (dirty)
            {
                if (m_ComponentEditor != null)
                {
                    ActiveEditorRegistry.SetActiveEditor(m_ComponentEditor, false);
                    m_ComponentEditor.ResetTarget();
                    UnityEngine.Object.DestroyImmediate(m_ComponentEditor);
                }
                m_ComponentEditor           = null;
                m_ComponentEditorOnSceneGUI = null;

                m_EditedComponents.Clear();
                m_EditedComponents.AddRange(m_ScratchComponentList);
                m_IsMixedType = false;
                for (int i = 1; !m_IsMixedType && i < numComponents; ++i)
                {
                    m_IsMixedType = m_EditedComponents[i].GetType() != m_EditedComponents[i - 1].GetType();
                }
            }
            if (numNullComponents > 0 && numComponents > 0)
            {
                m_IsMixedType = true;
            }
            if (numComponents > 0 && m_ComponentEditor == null && !m_IsMixedType)
            {
                UnityEditor.Editor.CreateCachedEditor(m_EditedComponents.ToArray(), null, ref m_ComponentEditor);
                if (m_ComponentEditor != null)
                {
                    m_ComponentEditorOnSceneGUI = m_ComponentEditor.GetType().GetMethod("OnSceneGUI",
                                                                                        System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                }
            }
            m_StageSelection = GetPopupIndexForComponent(numComponents == 0 ? null : m_EditedComponents[0]);

            m_StageError = false;
            for (int i = 0; !m_StageError && i < numComponents; ++i)
            {
                m_StageError = !m_EditedComponents[i].IsValid;
            }

            DrawComponentInspector();
        }
Exemple #2
0
 // Call this from Editor's OnInspectorGUI - returns new component if user changes type
 public void OnInspectorGUI(CinemachineComponentBase component)
 {
     if (component != mComponent)
     {
         if (mComponentEditor != null)
         {
             mComponentEditor.ResetTarget();
             UnityEngine.Object.DestroyImmediate(mComponentEditor);
         }
         mComponentEditor = null;
         mComponent       = component;
     }
     if (mComponent != null && mComponentEditor == null)
     {
         UnityEditor.Editor.CreateCachedEditor(mComponent, null, ref mComponentEditor);
     }
     mStageSelection = GetPopupIndexForComponent(mComponent);
     mStageError     = mComponent == null ? false : !mComponent.IsValid;
     DrawComponentInspector();
 }