void OnDuplicateChannel(object index) { SplineMesh extruder = (SplineMesh)target; SplineMesh.Channel source = extruder.GetChannel((int)index); SplineMesh.Channel newChannel = extruder.AddChannel(source.name); source.CopyTo(newChannel); }
protected override void BodyGUI() { showSize = false; showColor = false; showDoubleSided = false; showFlipFaces = false; base.BodyGUI(); SplineMesh user = (SplineMesh)target; EditorGUI.BeginChangeCheck(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Uv Coordinates", EditorStyles.boldLabel); user.uvOffset = EditorGUILayout.Vector2Field("UV Offset", user.uvOffset); user.uvScale = EditorGUILayout.Vector2Field("UV Scale", user.uvScale); if (targets.Length > 1) { EditorGUILayout.HelpBox("Cannot edit channels when multiple objects are selected", MessageType.Info); return; } EditorGUILayout.Space(); EditorGUILayout.LabelField("Channels", EditorStyles.boldLabel); for (int i = 0; i < user.GetChannelCount(); i++) { if (ChannelPanel(i)) { if (Event.current.type == EventType.MouseDown) { Repaint(); if (Event.current.button == 0) { if (selectedChannel == i) { selectedChannel = -1; } else { selectedChannel = i; scaleModifierEditor = new MeshScaleModifierEditor(user, this, user.GetChannel(i).scaleModifier); scaleModifierEditor.alwaysOpen = true; } } else if (Event.current.button == 1) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Rename"), false, OnRenameChannel, i); menu.AddItem(new GUIContent("Duplicate"), false, OnDuplicateChannel, i); if (i == 0) { menu.AddDisabledItem(new GUIContent("Move Up")); } else { menu.AddItem(new GUIContent("Move Up"), false, OnMoveChannelUp, i); } if (i == user.GetChannelCount() - 1) { menu.AddDisabledItem(new GUIContent("Move Down")); } else { menu.AddItem(new GUIContent("Move Down"), false, OnMoveChannelDown, i); } menu.AddSeparator(""); menu.AddItem(new GUIContent("Delete"), false, OnDeleteChannel, i); menu.ShowAsContext(); } } } } if (GUILayout.Button("New Channel")) { user.AddChannel("Channel " + (user.GetChannelCount() + 1)); } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(user); } }