void onExportTab(DTInspectorNode node) { GUI.enabled = Target.MeshCount > 0; if (GUILayout.Button("Save To Scene")) { Target.SaveToScene(); } if (GUILayout.Button("Save Mesh Asset(s)")) { string file = EditorUtility.SaveFilePanelInProject("Save Assets", Target.ModuleName, "mesh", "Save Mesh(es) as").Replace(".mesh", ""); if (!string.IsNullOrEmpty(file)) { List <Component> res; List <string> names; Target.GetManagedResources(out res, out names); for (int i = 0; i < res.Count; i++) { var resFile = string.Format("{0}{1}.asset", file, i); AssetDatabase.DeleteAsset(resFile); AssetDatabase.CreateAsset(res[i].GetComponent <MeshFilter>().sharedMesh, resFile); } AssetDatabase.Refresh(); } } GUI.enabled = true; }
void OnRenderTab(DTInspectorNode node) { int idx = node.Index - 1; if (idx >= 0 && idx < Target.MaterialCount) { var mat = Target.MaterialSetttings[idx]; EditorGUI.BeginChangeCheck(); mat.MaterialID = EditorGUILayout.IntField(new GUIContent("Material ID", "As defined in the Control Points"), mat.MaterialID); mat.SwapUV = EditorGUILayout.Toggle("Swap UV", mat.SwapUV); bool b = mat.KeepAspect != CGKeepAspectMode.Off; b = EditorGUILayout.Toggle(new GUIContent("Keep Aspect", "Keep proportional texel size?"), b); mat.KeepAspect = (b) ? CGKeepAspectMode.ScaleV : CGKeepAspectMode.Off; mat.UVOffset = EditorGUILayout.Vector2Field("UV Offset", mat.UVOffset); mat.UVScale = EditorGUILayout.Vector2Field("UV Scale", mat.UVScale); Target.SetMaterial(idx, EditorGUILayout.ObjectField("Material", Target.GetMaterial(idx), typeof(Material), true) as Material); if (Target.MaterialCount > 1 && GUILayout.Button("Remove")) { Target.RemoveMaterial(idx); node.Delete(); ensureMaterialTabs(); GUIUtility.ExitGUI(); } if (EditorGUI.EndChangeCheck()) { Target.Dirty = true; EditorUtility.SetDirty(Target); } } }
void ConnectionGUI(DTInspectorNode node) { if (mConnectionEditor != null && Target.Connection != null) { Target.Connection.name = EditorGUILayout.TextField("Name", Target.Connection.name); mConnectionEditor.OnInspectorGUI(); } }
/// <summary> /// Show the preview buttons /// </summary> protected void ShowPreviewButtons(DTInspectorNode node) { GUILayout.BeginHorizontal(); if (GUILayout.Toggle(mRunningInEditor, new GUIContent(CurvyStyles.TexPlay, "Play/Replay in Editor"), GUI.skin.button) != mRunningInEditor) { StartPreview(); } if (GUILayout.Button(new GUIContent(CurvyStyles.TexStop, "Stop"))) { StopPreview(); } GUILayout.EndHorizontal(); }
void ConnectionGUI(DTInspectorNode node) { if (mConnectionEditor != null && Target.Connection != null) { EditorGUILayout.BeginHorizontal(); Target.Connection.name = EditorGUILayout.TextField("Name", Target.Connection.name); if (GUILayout.Button(new GUIContent("Select", "Select the Connection GameObject"))) { DTSelection.SetGameObjects(Target.Connection); } EditorGUILayout.EndHorizontal(); mConnectionEditor.OnInspectorGUI(); } }
/// <summary> /// Show the preview buttons /// </summary> protected void ShowPreviewButtons(DTInspectorNode node) { GUILayout.BeginHorizontal(); GUI.enabled = !Application.isPlaying; if (GUILayout.Toggle(mRunningInEditor, new GUIContent(CurvyStyles.TexPlay, "Play/Pause in Editor"), GUI.skin.button) != mRunningInEditor) { StartPreview(); } if (GUILayout.Button(new GUIContent(CurvyStyles.TexStop, "Stop/Reset"))) { StopPreview(); } GUI.enabled = true; GUILayout.EndHorizontal(); }
void OnCrossGroupTab(DTInspectorNode node) { var vol = Target.InData.GetData <CGVolume>(); if (vol) { GUILayout.Label("MaterialGroup.Patch: (MaterialID) Patch Details", EditorStyles.boldLabel); for (int i = 0; i < vol.CrossMaterialGroups.Count; i++) { for (int p = 0; p < vol.CrossMaterialGroups[i].Patches.Count; p++) { GUILayout.Label(string.Format("{0}.{1}: (Mat:{2}) {3}", i, p, vol.CrossMaterialGroups[i].MaterialID, vol.CrossMaterialGroups[i].Patches[p].ToString())); } } } }
void OnShowSlots(DTInspectorNode node) { if (Target) { var inSlots = Target.Input; var outSlots = Target.Output; EditorGUILayout.BeginVertical(GUI.skin.box); if (inSlots.Count > 0) { EditorGUILayout.LabelField("Input", EditorStyles.boldLabel); showSlots <CGModuleInputSlot>(inSlots); } if (outSlots.Count > 0) { EditorGUILayout.LabelField("Output", EditorStyles.boldLabel); showSlots <CGModuleOutputSlot>(outSlots); } EditorGUILayout.EndVertical(); GUILayout.Space(10); } }
void OnRenderTab(DTInspectorNode node) { int grpIdx = node.Index - 2; if (grpIdx >= 0 && grpIdx < Target.GroupCount) { var pGroup = serializedObject.FindProperty(string.Format("m_Groups.Array.data[{0}]", grpIdx)); if (pGroup != null) { var group = Target.Groups[grpIdx]; var pItems = pGroup.FindPropertyRelative("m_Items"); if (pItems != null) { if (mCurrentGroup != null && mCurrentGroup != group) { mGroupItemsList = null; } if (mGroupItemsList == null) { mCurrentGroup = group; mGroupItemsList = new ReorderableList(pItems.serializedObject, pItems); mGroupItemsList.draggable = true; mGroupItemsList.drawHeaderCallback = (Rect Rect) => { EditorGUI.LabelField(Rect, "Items"); }; mGroupItemsList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { #region --- bool fix = (index <group.FirstRepeating || index> group.LastRepeating); if (fix) { DTHandles.DrawSolidRectangleWithOutline(rect.ShiftBy(0, -1), new Color(0, 0, 0.5f, 0.2f), new Color(0, 0, 0, 0)); } var prop = pItems.FindPropertyRelative(string.Format("Array.data[{0}]", index)); var pIndex = prop.FindPropertyRelative("Index"); rect.height = EditorGUIUtility.singleLineHeight; var r = new Rect(rect); EditorGUI.LabelField(new Rect(rect.x, rect.y, 30, rect.height), "#" + index.ToString() + ":"); r.x += 30; r.width = rect.width / 2 - 50; var bn = Target.BoundsNames; var bi = Target.BoundsIndices; if (bn.Length == 0) { pIndex.intValue = EditorGUI.IntField(r, "", pIndex.intValue); } else { EditorGUI.IntPopup(r, pIndex, bn, bi, new GUIContent("")); } r.x += r.width + 10; r.width = rect.width / 2; if (!fix && group.RepeatingOrder == CurvyRepeatingOrderEnum.Random) { EditorGUI.PropertyField(r, prop.FindPropertyRelative("m_Weight"), new GUIContent("")); } #endregion }; mGroupItemsList.onAddCallback = (ReorderableList l) => { group.Items.Insert(Mathf.Clamp(l.index + 1, 0, group.ItemCount), new CGBoundsGroupItem()); group.LastRepeating++; Target.Dirty = true; EditorUtility.SetDirty(Target); }; mGroupItemsList.onRemoveCallback = (ReorderableList l) => { group.Items.RemoveAt(l.index); group.LastRepeating--; Target.Dirty = true; EditorUtility.SetDirty(Target); }; } mGroupItemsList.DoLayoutList(); EditorGUILayout.PropertyField(pGroup.FindPropertyRelative("m_RepeatingItems")); EditorGUILayout.PropertyField(pGroup.FindPropertyRelative("m_RepeatingOrder")); EditorGUILayout.PropertyField(pGroup.FindPropertyRelative("m_KeepTogether")); EditorGUILayout.PropertyField(pGroup.FindPropertyRelative("m_SpaceBefore")); EditorGUILayout.PropertyField(pGroup.FindPropertyRelative("m_SpaceAfter")); EditorGUILayout.PropertyField(pGroup.FindPropertyRelative("m_DistributionMode"), new GUIContent("Mode")); EditorGUILayout.PropertyField(pGroup.FindPropertyRelative("m_PositionOffset")); EditorGUILayout.PropertyField(pGroup.FindPropertyRelative("m_Height")); EditorGUILayout.PropertyField(pGroup.FindPropertyRelative("m_RotationMode")); EditorGUILayout.PropertyField(pGroup.FindPropertyRelative("m_RotationOffset")); EditorGUILayout.PropertyField(pGroup.FindPropertyRelative("m_RotationScatter")); } } } }