private void OnEnable() { creator = ( Path_behaviour )target; if (creator.path == null) { creator.create_path(); } path = creator.path; }
public override void OnInspectorGUI() { EditorGUI.BeginChangeCheck(); var new_type = (path_types)EditorGUILayout.EnumPopup(path.type); if (new_type != path.type) { Undo.RecordObject(creator, "change type"); path.type = new_type; } if (GUILayout.Button("add segment")) { Undo.RecordObject(creator, "add segment"); path.add_segment_relative(Vector3.right); } if (GUILayout.Button("create_new")) { Undo.RecordObject(creator, "create new"); creator.create_path(); path = creator.path; } bool is_closed = GUILayout.Toggle(path.is_close, "closed"); if (is_closed != path.is_close) { Undo.RecordObject(creator, "toggle closed"); path.is_close = is_closed; } if (GUILayout.Button("flat y")) { Undo.RecordObject(creator, "flat y"); foreach (var s in path.segments) { s.vp1 = new Vector3( s.vp1.x, creator.transform.position.y, s.vp1.z); s.vc1 = new Vector3( s.vc1.x, creator.transform.position.y, s.vc1.z); s.vp2 = new Vector3( s.vp2.x, creator.transform.position.y, s.vp2.z); s.vc2 = new Vector3( s.vc2.x, creator.transform.position.y, s.vc2.z); } path = creator.path; } var resolution = EditorGUILayout.FloatField( "resolution:", path.resolution); if (path.resolution != resolution) { Undo.RecordObject(creator, "resolution change"); foreach (var multi_creator in targets) { var tmp_creator = multi_creator as Path_behaviour; tmp_creator.path.resolution = resolution; } } var spacing = EditorGUILayout.FloatField("spacing:", path.spacing); if (path.spacing != spacing) { Undo.RecordObject(creator, "spacing change"); foreach (var multi_creator in targets) { var tmp_creator = multi_creator as Path_behaviour; tmp_creator.path.spacing = spacing; } } if (GUILayout.Button("bake")) { Undo.RecordObject(creator, "bake"); foreach (var multi_creator in targets) { var tmp_creator = multi_creator as Path_behaviour; tmp_creator.path.bake(); create_handlers(tmp_creator); } } if (EditorGUI.EndChangeCheck()) { SceneView.RepaintAll(); } DrawDefaultInspector(); }