void showSlots <T>(List <T> slots) where T : CGModuleSlot { foreach (CGModuleSlot slot in slots) { var linked = slot.GetLinkedModules(); if (linked.Count > 1) { for (int i = 0; i < linked.Count; i++) { var sel = EditorGUILayout.ObjectField((i == 0)?slot.Info.Name:" ", linked[i], typeof(CGModule), true); if (sel != linked[i]) { DTLog.Log("[Curvy] Linking modules from the inspector isn't supported yet! Use the Graph editor instead!"); } } } else { var lm = (linked.Count == 0) ? null : linked[0]; var sel = EditorGUILayout.ObjectField(slot.Info.Name, lm, typeof(CGModule), true); if (sel != lm) { DTLog.Log("[Curvy] Linking modules from the inspector isn't supported yet! Use the Graph editor instead!"); } } } }
void DeletePreDTSettings() { DTLog.Log("[Curvy] Removing old preferences"); EditorPrefs.DeleteKey("Curvy_GizmoColor"); EditorPrefs.DeleteKey("Curvy_GizmoSelectionColor"); EditorPrefs.DeleteKey("Curvy_ControlPointSize"); EditorPrefs.DeleteKey("Curvy_OrientationLength"); EditorPrefs.DeleteKey("Curvy_Gizmos"); EditorPrefs.DeleteKey("Curvy_ToolbarLabels"); EditorPrefs.DeleteKey("Curvy_ToolbarOrientation"); EditorPrefs.DeleteKey("Curvy_ShowShapeWizardUndoWarning"); EditorPrefs.DeleteKey("Curvy_KeyBindings"); }
/// <summary> /// Add code to handle upgrading (delete old pref-keys etc...) here /// </summary> /// <param name="oldVersion">the version stored in the EditorPrefs</param> static void UpgradeDevTools(string oldVersion) { DTLog.Log("[DevTools] Upgrading settings from " + oldVersion + " to " + VERSION); }
void OnGUI() { DTInspectorNode.IsInsideInspector = false; if (Curves.Count == 0) { return; } Mode = GUILayout.SelectionGrid(Mode, new GUIContent[] { new GUIContent("Closed Shape", "Export a closed shape with triangles"), new GUIContent("Vertex Line", "Export a vertex line") }, 2); if (!string.IsNullOrEmpty(TriangulationMessage) && !TriangulationMessage.Contains("Angle must be >0")) { EditorGUILayout.HelpBox(TriangulationMessage, MessageType.Error); } scroll = EditorGUILayout.BeginScrollView(scroll); // OUTLINE GUIRenderer.RenderSectionHeader(nSplines); if (nSplines.ContentVisible) { Winding = (WindingRule)EditorGUILayout.EnumPopup("Winding", Winding, GUILayout.Width(285)); GUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Spline", "Note: Curves from a SplineGroup needs to be connected!"), EditorStyles.boldLabel, GUILayout.Width(140)); GUILayout.Label("Vertex Generation", EditorStyles.boldLabel, GUILayout.Width(160)); GUILayout.Label("Orientation", EditorStyles.boldLabel); GUILayout.EndHorizontal(); CurveGUI(Curves[0]); if (Mode == CLOSEDSHAPE) { for (int i = 1; i < Curves.Count; i++) { CurveGUI(Curves[i]); } if (GUILayout.Button(CurvyStyles.AddSmallTexture, GUILayout.ExpandWidth(false))) { Curves.Add(new SplinePolyLine(null)); } } } mNeedRepaint = mNeedRepaint || nSplines.NeedRepaint; GUIRenderer.RenderSectionFooter(nSplines); // TEXTURING GUIRenderer.RenderSectionHeader(nTexture); if (nTexture.ContentVisible) { Mat = (Material)EditorGUILayout.ObjectField("Material", Mat, typeof(Material), true, GUILayout.Width(285)); UVTiling = EditorGUILayout.Vector2Field("Tiling", UVTiling, GUILayout.Width(285)); UVOffset = EditorGUILayout.Vector2Field("Offset", UVOffset, GUILayout.Width(285)); } GUIRenderer.RenderSectionFooter(nTexture); mNeedRepaint = mNeedRepaint || nTexture.NeedRepaint; // EXPORT GUIRenderer.RenderSectionHeader(nExport); if (nExport.ContentVisible) { EditorGUILayout.HelpBox("Export is 2D (x/y) only!", MessageType.Info); MeshName = EditorGUILayout.TextField("Mesh Name", MeshName, GUILayout.Width(285)); UV2 = EditorGUILayout.Toggle("Add UV2", UV2); GUILayout.BeginHorizontal(); if (GUILayout.Button("Save as Asset")) { string path = EditorUtility.SaveFilePanelInProject("Save Mesh", MeshName + ".asset", "asset", "Choose a file location"); if (!string.IsNullOrEmpty(path)) { Mesh msh = clonePreviewMesh(); if (msh) { msh.name = MeshName; AssetDatabase.DeleteAsset(path); AssetDatabase.CreateAsset(msh, path); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); DTLog.Log("[Curvy] Export: Mesh Asset saved!"); } } } if (GUILayout.Button("Create GameObject")) { Mesh msh = clonePreviewMesh(); if (msh) { msh.name = MeshName; var go = new GameObject(MeshName, typeof(MeshRenderer), typeof(MeshFilter)); go.GetComponent <MeshFilter>().sharedMesh = msh; go.GetComponent <MeshRenderer>().sharedMaterial = Mat; Selection.activeGameObject = go; DTLog.Log("[Curvy] Export: GameObject created!"); } else { DTLog.LogWarning("[Curvy] Export: Unable to triangulate spline!"); } } GUILayout.EndHorizontal(); } GUIRenderer.RenderSectionFooter(nExport); mNeedRepaint = mNeedRepaint || nExport.NeedRepaint; EditorGUILayout.EndScrollView(); refreshNow = refreshNow || GUI.changed; if (mNeedRepaint) { Repaint(); mNeedRepaint = false; } }
protected virtual void UpgradePreferences(string oldVersion) { DTLog.Log(string.Format("[{0}] Upgrading project settings from {1} to {2}", Identifier, oldVersion, Version)); }