public override bool OnGUI() { bool dirty = false; bool b = GUILayout.Toggle(mFreeform, "Freeform"); if (b != mFreeform) { if (b) { mCurrentShape.Spline.ShowGizmos = true; mCurrentShape.Delete(); mCurrentShape = null; mFreeform = b; } else if (EditorUtility.DisplayDialog("Warning", "The current shape will be irreversible replaced. Are you sure?", "Ok", "Cancel")) { mFreeform = b; mCurrentShape = (CurvyShape2D)Resource.gameObject.AddComponent(CurvyShape.GetShapeType(mMenuNames[mSelection])); mCurrentShape.Spline.ShowGizmos = false; } } if (!mFreeform) { int sel = EditorGUILayout.Popup(mSelection, mMenuNames); if (sel != mSelection) { mSelection = sel; dirty = true; if (mCurrentShape) mCurrentShape.Delete(); mCurrentShape = (CurvyShape2D)Resource.gameObject.AddComponent(CurvyShape.GetShapeType(mMenuNames[mSelection])); } if (mCurrentShape) { var so = new SerializedObject(mCurrentShape); var prop = so.GetIterator(); bool enterChildren = true; while (prop.NextVisible(enterChildren)) { switch (prop.name) { case "m_Script": case "InspectorFoldout": case "m_Plane": //case "m_Persistent": break; default: EditorGUILayout.PropertyField(prop); break; } enterChildren = false; } dirty = so.ApplyModifiedProperties(); } } return dirty; }
public override bool OnGUI() { bool dirty = false; bool b = GUILayout.Toggle(mFreeform, "Freeform"); if (b != mFreeform) { if (b) { mCurrentShape.Spline.ShowGizmos = true; mCurrentShape.Delete(); mCurrentShape = null; mFreeform = b; } else if (EditorUtility.DisplayDialog("Warning", "The current shape will be irreversible replaced. Are you sure?", "Ok", "Cancel")) { mFreeform = b; mCurrentShape = (CurvyShape2D)Resource.gameObject.AddComponent(CurvyShape.GetShapeType(mMenuNames[mSelection])); mCurrentShape.Dirty = true; mCurrentShape.Spline.ShowGizmos = false; } } if (!mFreeform) { int sel = EditorGUILayout.Popup(mSelection, mMenuNames); if (sel != mSelection) { mSelection = sel; dirty = true; if (mCurrentShape) { mCurrentShape.Delete(); } mCurrentShape = (CurvyShape2D)Resource.gameObject.AddComponent(CurvyShape.GetShapeType(mMenuNames[mSelection])); mCurrentShape.Dirty = true; } if (mCurrentShape) { var so = new SerializedObject(mCurrentShape); var prop = so.GetIterator(); bool enterChildren = true; while (prop.NextVisible(enterChildren)) { switch (prop.name) { case "m_Script": case "InspectorFoldout": case "m_Plane": //case "m_Persistent": break; default: EditorGUILayout.PropertyField(prop); break; } enterChildren = false; } dirty = dirty || so.ApplyModifiedProperties(); } } return(dirty); }
public CGShapeResourceGUI(Component resource) : base(resource) { mCurrentShape=resource.GetComponent<CurvyShape2D>(); mMenuNames = CurvyShape.GetShapesMenuNames((mCurrentShape) ? mCurrentShape.GetType() : null, out mSelection,true).ToArray(); mFreeform = (mCurrentShape == null); }
public CGShapeResourceGUI(Component resource) : base(resource) { mCurrentShape = resource.GetComponent <CurvyShape2D>(); mMenuNames = CurvyShape.GetShapesMenuNames((mCurrentShape) ? mCurrentShape.GetType() : null, out mSelection, true).ToArray(); mFreeform = (mCurrentShape == null); }