コード例 #1
0
        public void OnEnable(ConstraintStyleBase style)
        {
            Undo.undoRedoPerformed = (Undo.UndoRedoCallback)Delegate.Combine(Undo.undoRedoPerformed, new Undo.UndoRedoCallback(this.OnUndoRedoPerformed));
            this.m_SourceList      = new ReorderableList(base.serializedObject, this.sources, this.sources.editable, true, this.sources.editable, this.sources.editable);
            ReorderableList expr_6D = this.m_SourceList;

            expr_6D.drawElementCallback = (ReorderableList.ElementCallbackDelegate)Delegate.Combine(expr_6D.drawElementCallback, new ReorderableList.ElementCallbackDelegate(this.DrawElementCallback));
            ReorderableList expr_94 = this.m_SourceList;

            expr_94.onAddCallback = (ReorderableList.AddCallbackDelegate)Delegate.Combine(expr_94.onAddCallback, new ReorderableList.AddCallbackDelegate(this.OnAddCallback));
            ReorderableList expr_BC = this.m_SourceList;

            expr_BC.drawHeaderCallback = (ReorderableList.HeaderCallbackDelegate) Delegate.Combine(expr_BC.drawHeaderCallback, new ReorderableList.HeaderCallbackDelegate(delegate(Rect rect)
            {
                EditorGUI.LabelField(rect, style.Sources);
            }));
            ReorderableList expr_E3 = this.m_SourceList;

            expr_E3.onRemoveCallback = (ReorderableList.RemoveCallbackDelegate)Delegate.Combine(expr_E3.onRemoveCallback, new ReorderableList.RemoveCallbackDelegate(this.OnRemoveCallback));
            ReorderableList expr_10B = this.m_SourceList;

            expr_10B.onSelectCallback = (ReorderableList.SelectCallbackDelegate)Delegate.Combine(expr_10B.onSelectCallback, new ReorderableList.SelectCallbackDelegate(this.OnSelectedCallback));
            ReorderableList expr_133 = this.m_SourceList;

            expr_133.onReorderCallbackWithDetails = (ReorderableList.ReorderCallbackDelegateWithDetails)Delegate.Combine(expr_133.onReorderCallbackWithDetails, new ReorderableList.ReorderCallbackDelegateWithDetails(this.OnReorderCallback));
            if (this.sources.arraySize > 0 && this.m_SelectedSourceIdx == -1)
            {
                this.SelectSource(0);
            }
        }
コード例 #2
0
 internal virtual void ShowValueAtRest(ConstraintStyleBase style)
 {
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.PropertyField(this.atRest, style.AtRest, new GUILayoutOption[0]);
     if (EditorGUI.EndChangeCheck())
     {
         this.OnValueAtRestChanged();
     }
 }
コード例 #3
0
 internal override void ShowValueAtRest(ConstraintStyleBase style)
 {
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.PropertyField(this.m_TranslationAtRest, (style as ParentConstraintEditor.Styles).TranslationAtRest, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_RotationAtRest, (style as ParentConstraintEditor.Styles).RotationAtRest, new GUILayoutOption[0]);
     if (EditorGUI.EndChangeCheck())
     {
         this.OnValueAtRestChanged();
     }
 }
コード例 #4
0
 internal override void ShowValueAtRest(ConstraintStyleBase style)
 {
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.PropertyField(m_TranslationAtRest, (style as Styles).TranslationAtRest);
     EditorGUILayout.PropertyField(m_RotationAtRest, (style as Styles).RotationAtRest);
     if (EditorGUI.EndChangeCheck())
     {
         OnValueAtRestChanged();
     }
 }
コード例 #5
0
 internal override void ShowOffset <T>(ConstraintStyleBase style)
 {
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.PropertyField(offset, style.Offset);
     if (EditorGUI.EndChangeCheck())
     {
         foreach (var t in targets)
         {
             (t as T).UserUpdateOffset();
         }
     }
 }
コード例 #6
0
 internal override void ShowOffset <T>(ConstraintStyleBase style)
 {
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.PropertyField(this.offset, style.Offset, new GUILayoutOption[0]);
     if (EditorGUI.EndChangeCheck())
     {
         UnityEngine.Object[] targets = base.targets;
         for (int i = 0; i < targets.Length; i++)
         {
             UnityEngine.Object @object = targets[i];
             T t = @object as T;
             t.UserUpdateOffset();
         }
     }
 }
コード例 #7
0
 internal override void ShowOffset <T>(ConstraintStyleBase style)
 {
     using (new EditorGUI.DisabledGroupScope(isLocked.boolValue))
     {
         EditorGUI.BeginChangeCheck();
         m_OffsetList.DoLayoutList();
         if (EditorGUI.EndChangeCheck())
         {
             foreach (var t in targets)
             {
                 (t as IConstraintInternal).UserUpdateOffset();
             }
         }
     }
 }
コード例 #8
0
 internal override void ShowOffset <T>(ConstraintStyleBase style)
 {
     using (new EditorGUI.DisabledGroupScope(this.isLocked.boolValue))
     {
         EditorGUI.BeginChangeCheck();
         this.m_OffsetList.DoLayoutList();
         if (EditorGUI.EndChangeCheck())
         {
             UnityEngine.Object[] targets = base.targets;
             for (int i = 0; i < targets.Length; i++)
             {
                 UnityEngine.Object @object = targets[i];
                 (@object as IConstraintInternal).UserUpdateOffset();
             }
         }
     }
 }
コード例 #9
0
        public void OnEnable(ConstraintStyleBase style)
        {
            Undo.undoRedoPerformed += OnUndoRedoPerformed;

            m_SourceList = new ReorderableList(serializedObject, sources, sources.editable, true, sources.editable, sources.editable);
            m_SourceList.drawElementCallback          += DrawElementCallback;
            m_SourceList.onAddCallback                += OnAddCallback;
            m_SourceList.drawHeaderCallback           += rect => EditorGUI.LabelField(rect, style.Sources);
            m_SourceList.onRemoveCallback             += OnRemoveCallback;
            m_SourceList.onSelectCallback             += OnSelectedCallback;
            m_SourceList.onReorderCallbackWithDetails += OnReorderCallback;

            if (sources.arraySize > 0 && m_SelectedSourceIdx == -1)
            {
                SelectSource(0);
            }
        }
コード例 #10
0
 internal void ShowConstraintEditor <T>(ConstraintStyleBase style) where T : class, IConstraintInternal
 {
     if (this.m_SelectedSourceIdx == -1 || this.m_SelectedSourceIdx >= this.m_SourceList.serializedProperty.arraySize)
     {
         this.SelectSource(0);
     }
     using (new EditorGUI.DisabledScope(Application.isPlaying))
     {
         using (new EditorGUILayout.HorizontalScope(new GUILayoutOption[0]))
         {
             if (GUILayout.Button(style.Activate, new GUILayoutOption[0]))
             {
                 List <UnityEngine.Object> list = new List <UnityEngine.Object>();
                 list.AddRange(base.targets);
                 UnityEngine.Object[] targets = base.targets;
                 for (int i = 0; i < targets.Length; i++)
                 {
                     UnityEngine.Object        @object  = targets[i];
                     List <UnityEngine.Object> arg_AB_0 = list;
                     T t = @object as T;
                     arg_AB_0.Add(t.transform);
                 }
                 Undo.RegisterCompleteObjectUndo(list.ToArray(), "Activate the Constraint");
                 UnityEngine.Object[] targets2 = base.targets;
                 for (int j = 0; j < targets2.Length; j++)
                 {
                     UnityEngine.Object object2 = targets2[j];
                     T t2 = object2 as T;
                     t2.ActivateAndPreserveOffset();
                 }
             }
             if (GUILayout.Button(style.Zero, new GUILayoutOption[0]))
             {
                 List <UnityEngine.Object> list2 = new List <UnityEngine.Object>();
                 list2.AddRange(base.targets);
                 UnityEngine.Object[] targets3 = base.targets;
                 for (int k = 0; k < targets3.Length; k++)
                 {
                     UnityEngine.Object        object3   = targets3[k];
                     List <UnityEngine.Object> arg_180_0 = list2;
                     T t3 = object3 as T;
                     arg_180_0.Add(t3.transform);
                 }
                 Undo.RegisterCompleteObjectUndo(list2.ToArray(), "Zero the Constraint");
                 UnityEngine.Object[] targets4 = base.targets;
                 for (int l = 0; l < targets4.Length; l++)
                 {
                     UnityEngine.Object object4 = targets4[l];
                     T t4 = object4 as T;
                     t4.ActivateWithZeroOffset();
                 }
             }
         }
     }
     EditorGUILayout.PropertyField(this.isContraintActive, style.IsActive, new GUILayoutOption[0]);
     EditorGUILayout.Slider(this.weight, 0f, 1f, style.Weight, new GUILayoutOption[0]);
     this.ShowCustomProperties();
     this.m_ShowConstraintSettings = EditorGUILayout.Foldout(this.m_ShowConstraintSettings, style.ConstraintSettings, true);
     if (this.m_ShowConstraintSettings)
     {
         EditorGUI.indentLevel++;
         using (new EditorGUI.DisabledScope(Application.isPlaying))
         {
             EditorGUILayout.PropertyField(this.isLocked, style.IsLocked, new GUILayoutOption[0]);
         }
         using (new EditorGUI.DisabledGroupScope(this.isLocked.boolValue))
         {
             this.ShowValueAtRest(style);
             this.ShowOffset <T>(style);
         }
         this.ShowFreezeAxesControl();
         EditorGUI.indentLevel--;
     }
     this.m_SourceList.DoLayoutList();
 }
コード例 #11
0
        internal void ShowConstraintEditor <T>(ConstraintStyleBase style) where T : class, IConstraintInternal
        {
            if (m_SelectedSourceIdx == -1 || m_SelectedSourceIdx >= m_SourceList.serializedProperty.arraySize)
            {
                SelectSource(0);
            }

            using (new EditorGUI.DisabledScope(Application.isPlaying))
            {
                using (new EditorGUILayout.HorizontalScope())
                {
                    if (GUILayout.Button(style.Activate))
                    {
                        List <Object> recordObjects = new List <Object>();
                        recordObjects.AddRange(targets);
                        foreach (var t in targets)
                        {
                            recordObjects.Add((t as T).transform);
                        }
                        Undo.RegisterCompleteObjectUndo(recordObjects.ToArray(), "Activate the Constraint");

                        foreach (var t in targets)
                        {
                            (t as T).ActivateAndPreserveOffset();
                        }
                    }

                    if (GUILayout.Button(style.Zero))
                    {
                        List <Object> recordObjects = new List <Object>();
                        recordObjects.AddRange(targets);
                        foreach (var t in targets)
                        {
                            recordObjects.Add((t as T).transform);
                        }
                        Undo.RegisterCompleteObjectUndo(recordObjects.ToArray(), "Zero the Constraint");

                        foreach (var t in targets)
                        {
                            (t as T).ActivateWithZeroOffset();
                        }
                    }
                }
            }

            EditorGUILayout.PropertyField(isContraintActive, style.IsActive);
            EditorGUILayout.Slider(weight, 0.0f, 1.0f, style.Weight);
            ShowCustomProperties();

            m_ShowConstraintSettings = EditorGUILayout.Foldout(m_ShowConstraintSettings, style.ConstraintSettings, true);
            if (m_ShowConstraintSettings)
            {
                EditorGUI.indentLevel++;
                using (new EditorGUI.DisabledScope(Application.isPlaying))
                {
                    EditorGUILayout.PropertyField(isLocked, style.IsLocked);
                }
                using (new EditorGUI.DisabledGroupScope(isLocked.boolValue))
                {
                    ShowValueAtRest(style);

                    ShowOffset <T>(style);
                }
                ShowFreezeAxesControl();
                EditorGUI.indentLevel--;
            }
            m_SourceList.DoLayoutList();
        }