void OnEnable() { m_Weight = serializedObject.FindProperty("m_Weight"); m_SourceObjectsToggle = serializedObject.FindProperty("m_SourceObjectsGUIToggle"); m_SettingsToggle = serializedObject.FindProperty("m_SettingsGUIToggle"); var data = serializedObject.FindProperty("m_Data"); m_ConstrainedObject = data.FindPropertyRelative("m_ConstrainedObject"); m_ConstrainedPositionAxes = data.FindPropertyRelative("m_ConstrainedPositionAxes"); m_ConstrainedRotationAxes = data.FindPropertyRelative("m_ConstrainedRotationAxes"); m_SourceObjects = data.FindPropertyRelative("m_SourceObjects"); m_MaintainPositionOffset = data.FindPropertyRelative("m_MaintainPositionOffset"); m_MaintainRotationOffset = data.FindPropertyRelative("m_MaintainRotationOffset"); m_Constraint = (MultiParentConstraint)serializedObject.targetObject; m_SourceObjectsArray = m_Constraint.data.sourceObjects; var dataType = m_Constraint.data.GetType(); var fieldInfo = dataType.GetField("m_SourceObjects", BindingFlags.NonPublic | BindingFlags.Instance); var range = fieldInfo.GetCustomAttribute <RangeAttribute>(); if (m_SourceObjectsArray.Count == 0) { m_SourceObjectsArray.Add(WeightedTransform.Default(1f)); m_Constraint.data.sourceObjects = m_SourceObjectsArray; } m_ReorderableList = WeightedTransformHelper.CreateReorderableList(m_SourceObjects, ref m_SourceObjectsArray, range); m_ReorderableList.onChangedCallback = (ReorderableList reorderableList) => { m_Constraint.data.sourceObjects = (WeightedTransformArray)reorderableList.list; }; }
void OnEnable() { m_Weight = serializedObject.FindProperty("m_Weight"); m_TwistNodesToggle = serializedObject.FindProperty("m_TwistNodesGUIToggle"); var data = serializedObject.FindProperty("m_Data"); m_Source = data.FindPropertyRelative("m_Source"); m_TwistAxis = data.FindPropertyRelative("m_TwistAxis"); m_TwistNodes = data.FindPropertyRelative("m_TwistNodes"); m_Constraint = (TwistCorrection)serializedObject.targetObject; m_TwistNodesArray = m_Constraint.data.twistNodes; var dataType = m_Constraint.data.GetType(); var fieldInfo = dataType.GetField("m_TwistNodes", BindingFlags.NonPublic | BindingFlags.Instance); var range = fieldInfo.GetCustomAttribute <RangeAttribute>(); if (m_TwistNodesArray.Count == 0) { m_TwistNodesArray.Add(WeightedTransform.Default(0f)); m_Constraint.data.twistNodes = m_TwistNodesArray; } m_ReorderableList = WeightedTransformHelper.CreateReorderableList(m_TwistNodes, ref m_TwistNodesArray, range); m_ReorderableList.onChangedCallback = (ReorderableList reorderableList) => { m_Constraint.data.twistNodes = (WeightedTransformArray)reorderableList.list; }; }
void OnEnable() { m_Weight = serializedObject.FindProperty("m_Weight"); m_SourceObjectsToggle = serializedObject.FindProperty("m_SourceObjectsGUIToggle"); m_SettingsToggle = serializedObject.FindProperty("m_SettingsGUIToggle"); var data = serializedObject.FindProperty("m_Data"); m_ConstrainedObject = data.FindPropertyRelative("m_ConstrainedObject"); m_AimAxis = data.FindPropertyRelative("m_AimAxis"); m_UpAxis = data.FindPropertyRelative("m_UpAxis"); m_WorldUpType = data.FindPropertyRelative("m_WorldUpType"); m_WorldUpAxis = data.FindPropertyRelative("m_WorldUpAxis"); m_WorldUpObject = data.FindPropertyRelative("m_WorldUpObject"); m_SourceObjects = data.FindPropertyRelative("m_SourceObjects"); m_MaintainOffset = data.FindPropertyRelative("m_MaintainOffset"); m_Offset = data.FindPropertyRelative("m_Offset"); m_ConstrainedAxes = data.FindPropertyRelative("m_ConstrainedAxes"); m_MinLimit = data.FindPropertyRelative("m_MinLimit"); m_MaxLimit = data.FindPropertyRelative("m_MaxLimit"); m_Constraint = (MultiAimConstraint)serializedObject.targetObject; m_SourceObjectsArray = m_Constraint.data.sourceObjects; var dataType = m_Constraint.data.GetType(); var fieldInfo = dataType.GetField("m_SourceObjects", BindingFlags.NonPublic | BindingFlags.Instance); var range = fieldInfo.GetCustomAttribute <RangeAttribute>(); if (m_SourceObjectsArray.Count == 0) { m_SourceObjectsArray.Add(WeightedTransform.Default(1f)); m_Constraint.data.sourceObjects = m_SourceObjectsArray; } m_ReorderableList = WeightedTransformHelper.CreateReorderableList(m_SourceObjects, ref m_SourceObjectsArray, range); m_ReorderableList.onChangedCallback = (ReorderableList reorderableList) => { Undo.RegisterCompleteObjectUndo(m_Constraint, "Edit MultiAim"); m_Constraint.data.sourceObjects = (WeightedTransformArray)reorderableList.list; if (PrefabUtility.IsPartOfPrefabInstance(m_Constraint)) { EditorUtility.SetDirty(m_Constraint); } }; Undo.undoRedoPerformed += () => { m_ReorderableList.list = m_Constraint.data.sourceObjects; }; }
void OnEnable() { m_Weight = serializedObject.FindProperty("m_Weight"); m_TwistNodesToggle = serializedObject.FindProperty("m_TwistNodesGUIToggle"); var data = serializedObject.FindProperty("m_Data"); m_Source = data.FindPropertyRelative("m_Source"); m_TwistAxis = data.FindPropertyRelative("m_TwistAxis"); m_TwistNodes = data.FindPropertyRelative("m_TwistNodes"); m_Constraint = (TwistCorrection)serializedObject.targetObject; m_TwistNodesArray = m_Constraint.data.twistNodes; var dataType = m_Constraint.data.GetType(); var fieldInfo = dataType.GetField("m_TwistNodes", BindingFlags.NonPublic | BindingFlags.Instance); var range = fieldInfo.GetCustomAttribute <RangeAttribute>(); if (m_TwistNodesArray.Count == 0) { m_TwistNodesArray.Add(WeightedTransform.Default(0f)); m_Constraint.data.twistNodes = m_TwistNodesArray; } m_ReorderableList = WeightedTransformHelper.CreateReorderableList(m_TwistNodes, ref m_TwistNodesArray, range); m_ReorderableList.onChangedCallback = (ReorderableList reorderableList) => { Undo.RegisterCompleteObjectUndo(m_Constraint, "Edit TwistCorrection"); m_Constraint.data.twistNodes = (WeightedTransformArray)reorderableList.list; if (PrefabUtility.IsPartOfPrefabInstance(m_Constraint)) { EditorUtility.SetDirty(m_Constraint); } }; Undo.undoRedoPerformed += () => { m_ReorderableList.list = m_Constraint.data.twistNodes; }; }