public void OnNstStart() { if (nst != null) { hasAuthority = nst.na.IsMine; } // Find position and rotation elements that are defined for this child (assumes there are no more than one per, since there shouldn't be) if (nst != null && nst.nstElementsEngine != null) { foreach (TransformElement te in nst.nstElementsEngine.transformElements) { if (te.gameobject == _gameObject) { if (te is IPositionElement) { pe = te as IPositionElement; } else if (te is IRotationElement) { re = te as IRotationElement; } } } } isQuat = (re != null && re.RotationType == RotationType.Quaternion); turnWithForce = isRootGO && rb != null && !rb.isKinematic && isQuat; moveWithForce = isRootGO && rb != null && !rb.isKinematic; // Set the restriction bools based on the restrict switch and the enabled/disabled axes if (restrictToNstRange) { if (pe != null) { for (int i = 0; i < 3; i++) { allowMove[i] = pe[i]; } } if (re != null && !isQuat) { for (int i = 0; i < 3; i++) { allowTurn[i] = re[i]; } } } }
public override void OnGUI(Rect r, SerializedProperty property, GUIContent label) { savedIndentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 1; // Get the actual instance of this FloatRange TransformElement par = (TransformElement)Utilities.GUIUtilities.PropertyDrawerUtility.GetParent(property); SerializedProperty axis = property.FindPropertyRelative("axis"); IPositionElement pe = par as IPositionElement; IScaleElement se = par as IScaleElement; FloatRange ar = (pe != null) ? pe.AxisRanges[axis.intValue] : se.AxisRanges[axis.intValue]; realwidth = r.width; float padding = 4f; float lablelWidth = 64f; float fieldWidth = 56f; float labeloffset = -82f; float fieldOffset = -(fieldWidth * .5f) - padding; float col2 = realwidth - r.width * .6666667f; float col3 = realwidth - r.width * .3333333f; float colend = realwidth; float rowoffset = r.yMin; ar.Min = EditorGUI.FloatField(new Rect(col2 + fieldOffset, rowoffset, fieldWidth, 16), GUIContent.none, ar.Min); EditorGUI.LabelField(new Rect(col2 + labeloffset, rowoffset, lablelWidth, 16), new GUIContent("min"), "RightLabel"); ar.Max = EditorGUI.FloatField(new Rect(col3 + fieldOffset, rowoffset, fieldWidth, 16), GUIContent.none, ar.Max); EditorGUI.LabelField(new Rect(col3 + labeloffset, rowoffset, lablelWidth, 16), new GUIContent("max"), "RightLabel"); ar.Resolution = EditorGUI.IntField(new Rect(colend + fieldOffset, rowoffset, fieldWidth, 16), GUIContent.none, ar.Resolution); EditorGUI.LabelField(new Rect(colend + labeloffset, rowoffset, lablelWidth, 16), new GUIContent("res"), "RightLabel"); if (pe != null) { pe.AxisRanges[axis.intValue].ApplyValues(); } else if (se != null) { se.AxisRanges[axis.intValue].ApplyValues(); } EditorGUI.indentLevel = savedIndentLevel; }