/// <summary> /// Global Main Panel /// </summary> /// <param name="helpEnabled"></param> private void GlobalSettings(bool helpEnabled) { m_editorUtils.Heading("Setup"); EditorGUI.indentLevel++; WaterReflections.SunLight = (Light)m_editorUtils.ObjectField("SunLight", WaterReflections.SunLight, typeof(Light), true, helpEnabled); WaterReflections.m_player = (Transform)m_editorUtils.ObjectField("Player", WaterReflections.m_player, typeof(Transform), true, helpEnabled); WaterReflections.SeaLevel = m_editorUtils.FloatField("SeaLevel", WaterReflections.SeaLevel, helpEnabled); WaterReflections.InfiniteMode = m_editorUtils.Toggle("InfiniteMode", WaterReflections.InfiniteMode, helpEnabled); EditorGUI.indentLevel--; /*m_editorUtils.Heading("SurfaceSettings"); * EditorGUI.indentLevel++; * WaterReflections.m_minSurfaceLight = m_editorUtils.FloatField("MinSurfaceLight", WaterReflections.m_minSurfaceLight, helpEnabled); * if (WaterReflections.m_minSurfaceLight > WaterReflections.m_maxSurfaceLight) * { * WaterReflections.m_minSurfaceLight = WaterReflections.m_maxSurfaceLight - 0.1f; * } * * if (WaterReflections.m_minSurfaceLight < 0f) * { * WaterReflections.m_minSurfaceLight = 0f; * } * WaterReflections.m_maxSurfaceLight = m_editorUtils.FloatField("MaxSurfaceLight", WaterReflections.m_maxSurfaceLight, helpEnabled); * if (WaterReflections.m_maxSurfaceLight < 0.1f) * { * WaterReflections.m_maxSurfaceLight = 0.1f; * } * EditorGUI.indentLevel--;*/ if (m_editorUtils.Button("EditReflectionSettings")) { GaiaUtils.FocusWaterProfile(); } }
/// <summary> Main GUI Function </summary> public override void OnInspectorGUI() { serializedObject.Update(); m_editorUtils.Initialize(); // Do not remove this! m_editorUtils.GUIHeader(); m_editorUtils.TitleNonLocalized(m_editorUtils.GetContent("SequenceDataHeader").text + serializedObject.targetObject.name); EditorGUI.BeginDisabledGroup(!Application.isPlaying); if (!Application.isPlaying || !AmbienceManager.WasSequenceAdded(target as Sequence)) { if (m_editorUtils.Button("EditorPlayButton")) { Sequence seq = target as Sequence; seq.m_forcePlay = true; AmbienceManager.AddSequence(seq); } } else { if (m_editorUtils.Button("EditorStopButton")) { Sequence seq = target as Sequence; seq.m_forcePlay = false; AmbienceManager.RemoveSequence(seq); } } EditorGUI.EndDisabledGroup(); m_editorUtils.Panel("RequirementsPanel", RequirementsPanel, true); m_editorUtils.Panel("ClipsPanel", ClipsPanel, true); m_editorUtils.Panel("OutputPanel", OutputPanel, true); m_editorUtils.Panel("RandomizationPanel", RandomizationPanel, true); m_editorUtils.Panel("ModifiersPanel", ModifiersPanel, true); m_editorUtils.Panel("EventsPanel", EventsPanel, true); m_editorUtils.Panel("SyncPanel", SyncPanel, true); //m_editorUtils.GUIFooter(); serializedObject.ApplyModifiedProperties(); }
private void DrawDelete(int i) { var p = Get(i); Handles.color = Color.red; if (EditorUtils.Button(p, curve.transform, 1, Handles.DotCap)) { Undo.RecordObject(curve, "Delete Point"); curve.Positions.RemoveAt(i); EditorUtility.SetDirty(curve); Repaint(); curve.SetAllDirty(); } }
void MainPanelUI() { GUILayout.Space(5); splatA = EditorUtils.Texture2dField("First Splatmap", ref splatA, 20f, 15f); EditorGUILayout.Separator(); splatB = EditorUtils.Texture2dField("Second Splatmap", ref splatB, 20f, 15f); EditorGUILayout.Separator(); if (EditorUtils.Button("Applay Splatmap", 20, 15)) { Debug.Log("Applay splatmap"); ApplySplatMap(); } }
void MainPanel_UI() { if (generator == null) { return; } mainfoldOut = EditorUtils.Foldout("Foilage Area", mainfoldOut, 5, 15); if (mainfoldOut) { GUILayout.BeginVertical(); FoilageDistributionUI(); GUILayout.Space(5f); GUILayout.BeginHorizontal(); EditorUtils.Label("Point Radius", 15, 0, minWidth: 100f); generator.pointRadius = EditorUtils.Float(ref generator.pointRadius, "", 15f, 15f, minWidth: 100); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorUtils.Label("Debug", 15, 0, minWidth: 100f); generator.debugMode = EditorUtils.Toggle(ref generator.debugMode, "", 0, 0); GUILayout.EndHorizontal(); if (EditorUtils.Button("Generate Points", 15f, 15f)) { GeneratePoints(); SceneView.RepaintAll(); } ; if (EditorUtils.Button("Clear Points Array", 15f, 15f)) { generator.ClearPoints(); SceneView.RepaintAll(); } ; if (EditorUtils.Button("Distribute", 15f, 15f)) { generator.Distribute(FoilageEditor.Instance.foilageGroupsEditor.groups); generator.debugMode = false; SceneView.RepaintAll(); } ; GUILayout.EndVertical(); } }
private void DrawAdd() { var m = EditorUtils.GetMousePosition(); int a; int b; GetNearestLine(out a, out b); Handles.color = Color.yellow; Handles.DrawLine(m, Get(a)); Handles.DrawLine(m, Get(b)); if (EditorUtils.Button(m, curve.transform, 1, Handles.DotCap)) { Undo.RecordObject(curve, "Add Point"); var p = curve.transform.InverseTransformPoint(m); curve.Positions.Insert(Mathf.Max(a, b), p); EditorUtility.SetDirty(curve); curve.SetAllDirty(); } }
void DrawUI() { GUILayout.Space(5); EditorUtils.Texture2dField("Grass Map", ref grassAndGroundCover.grassMap, 15f, 15f); EditorUtils.Texture2dField("Bush Map", ref grassAndGroundCover.treeMap, 15f, 15f); GUILayout.BeginHorizontal(); EditorUtils.Label("Grass Density", 15, 0); GUILayout.FlexibleSpace(); grassAndGroundCover.grassDensity = EditorGUILayout.Slider(grassAndGroundCover.grassDensity, 0.01f, 3f); GUILayout.Space(15); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorUtils.Label("Grass Clumping", 15, 0); GUILayout.FlexibleSpace(); grassAndGroundCover.grassClumping = EditorGUILayout.Slider(grassAndGroundCover.grassClumping, 0f, 1f); GUILayout.Space(15); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorUtils.Label("Bush/Detail Density", 15, 0); GUILayout.FlexibleSpace(); grassAndGroundCover.bushDensity = EditorGUILayout.Slider(grassAndGroundCover.bushDensity, 0.01f, 2f); GUILayout.Space(15); GUILayout.EndHorizontal(); GUILayout.Space(5); if (EditorUtils.Button("Simulate", 15, 0)) { grassAndGroundCover.Generate(); } GUILayout.Space(5); }
public void UpdateUI() { mainfoldOut = EditorUtils.Foldout("Foilage Groups", mainfoldOut, 5, 15); if (mainfoldOut) { for (int j = 0; j < groups.groupObjects.Count; j++) { GUILayout.BeginHorizontal(); GUILayout.Space(18); EditorUtils.Label(j.ToString(), 0, 0); groups.groupObjects[j] = (GameObject)EditorGUILayout.ObjectField(groups.groupObjects[j], typeof(GameObject), true); // if the user drags an object from the scene and if it;s not a GrassPatch if (groups.groupObjects[j] != null && !groups.groupObjects[j].GetComponent <GrassPatch>()) { groups.groupObjects[j] = null; } else { groups.AddEntry(j); } if (EditorUtils.Button("Remove", 0, 0)) { groups.Remove(j); groups.selectedIndex = -1; return; } if (EditorUtils.Button("Select", 0, 0)) { groups.Select(j); } GUILayout.Space(15); GUILayout.EndHorizontal(); } GUILayout.Space(5f); FoilageRules r = null; if (groups.selectedIndex != -1 && groups.foilageRules.ContainsKey(groups.selectedIndex)) { r = groups.foilageRules[groups.selectedIndex]; } if (r != null) { DrawScatterSettingsUI(r); DrawRulesUI(r); } GUILayout.Space(5f); GUILayout.BeginHorizontal(); if (EditorUtils.Button("Add Foilage group", 20, 0)) { groups.Add(); } if (EditorUtils.Button("Clear", 0, 15)) { } GUILayout.EndHorizontal(); GUILayout.Space(5f); } }
/// <summary> Panel to show all currently playing AudioClips </summary> /// <param name="inlineHelp">Should help be displayed?</param> void CurrentlyPlayingPanel(bool inlineHelp) { Event currentEvent = Event.current; GUIStyle muteButtonNormal; GUIStyle muteButtonPressed; muteButtonNormal = EditorStyles.miniButton; muteButtonPressed = new GUIStyle(muteButtonNormal); muteButtonPressed.normal = muteButtonNormal.active; foreach (AmbienceManager.TrackPlayingInfo track in AllTracks) { EditorGUILayout.BeginHorizontal(); if (track.m_sequence != null) { Color startColor = GUI.color; GUIStyle buttonStyle = muteButtonNormal; if (track.m_sequence.m_forceMuted) { GUI.color = Color.red; buttonStyle = muteButtonPressed; } if (m_editorUtils.Button(EditorGUIUtility.IconContent("preAudioAutoPlayOff"), buttonStyle, GUILayout.ExpandWidth(false))) { if (Event.current.button == 1) { track.m_sequence.m_forceMuted = false; bool curMuted = true; foreach (AmbienceManager.TrackPlayingInfo t in AllTracks) { if (t.m_sequence != null && t.m_sequence != track.m_sequence) { curMuted &= t.m_sequence.m_forceMuted; } } foreach (AmbienceManager.TrackPlayingInfo t in AllTracks) { if (t.m_sequence != null && t.m_sequence != track.m_sequence) { t.m_sequence.m_forceMuted = !curMuted; } } } else { track.m_sequence.m_forceMuted = !track.m_sequence.m_forceMuted; } } GUI.color = startColor; } Rect r = EditorGUILayout.GetControlRect(); EditorGUILayout.EndHorizontal(); Rect labelRect = r; labelRect.xMin += EditorGUIUtility.labelWidth; GUI.Label(labelRect, new GUIContent(track.m_name, track.m_name)); labelRect.xMax = labelRect.xMin; labelRect.xMin = r.xMin; Rect meterRect = labelRect; meterRect.xMin = meterRect.xMax - meterRect.height; if (currentEvent.type == EventType.MouseDown && meterRect.Contains(currentEvent.mousePosition)) { currentEvent.Use(); } else if (currentEvent.type == EventType.MouseDrag && r.Contains(currentEvent.mousePosition)) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new Object[] { track.m_sequence }; DragAndDrop.StartDrag("Sequence:" + track.m_sequence.name); currentEvent.Use(); weStartedDrag = true; } else if ((currentEvent.type == EventType.MouseUp || currentEvent.type == EventType.DragExited) && weStartedDrag) { weStartedDrag = false; DragAndDrop.PrepareStartDrag(); } EditorGUI.ObjectField(labelRect, track.m_sequence, typeof(Sequence), false); meterRect.xMin = labelRect.xMax - r.height * 0.75f; meterRect.xMax -= labelRect.height * 0.125f; EditorGUI.DrawRect(meterRect, Color.black); Rect levelRect = new Rect(meterRect); levelRect.yMin = meterRect.yMax - (meterRect.yMax - meterRect.yMin) * track.m_volumeLevel; EditorGUI.DrawRect(levelRect, Color.green); levelRect.yMin = meterRect.yMax - (meterRect.yMax - meterRect.yMin) * track.m_fadeLevel; levelRect.yMax = levelRect.yMin + 2f; EditorGUI.DrawRect(levelRect, Color.red); } }
/// <summary> Panel to display Output options </summary> /// <param name="inlineHelp">Should help be displayed?</param> void OutputPanel(bool inlineHelp) { ++EditorGUI.indentLevel; m_editorUtils.EnumPopupLocalized("mOutputType", "OutputType_", m_outputTypeProp, inlineHelp); OutputType outputType = ( OutputType)System.Enum.GetValues(typeof(OutputType)).GetValue(m_outputTypeProp.enumValueIndex); outputBool.target = outputType != OutputType.STRAIGHT; if (EditorGUILayout.BeginFadeGroup(outputBool.faded)) { EditorGUI.BeginChangeCheck(); Object prefab = m_editorUtils.ObjectField("mOutputPrefab", m_outputPrefabProp.objectReferenceValue, typeof(GameObject), false, inlineHelp); if (EditorGUI.EndChangeCheck()) { m_outputPrefabProp.objectReferenceValue = prefab; } if (m_outputPrefabProp != null && m_outputPrefabProp.objectReferenceValue != null) { AudioSource prefabSource = ((GameObject)m_outputPrefabProp.objectReferenceValue).GetComponent <AudioSource>(); if (prefabSource == null) { EditorGUILayout.HelpBox(m_editorUtils.GetContent("PrefabNoSource").text, MessageType.Info); } else { bool spatialize = false; bool spatialblend = false; if (prefabSource.spatialize == false) { spatialize = true; } if (prefabSource.spatialBlend < 1f) { spatialblend = true; } if (spatialize || spatialblend) { EditorGUILayout.HelpBox(m_editorUtils.GetContent("PrefabSettingsWarningPrefix").text + (spatialize ? m_editorUtils.GetContent("PrefabSettingsWarningSpatialize").text : "") + (spatialblend ? m_editorUtils.GetContent("PrefabSettingsWarningSpatialBlend").text : "") , MessageType.Warning); if (m_editorUtils.Button("PrefabSettingsButton")) { prefabSource.spatialize = true; prefabSource.spatialBlend = 1.0f; EditorUtility.SetDirty(m_outputPrefabProp.objectReferenceValue); #if UNITY_2018_3_OR_NEWER PrefabUtility.SavePrefabAsset(prefabSource.gameObject); #else PrefabUtility.ReplacePrefab(prefabSource.gameObject, m_outputPrefabProp.objectReferenceValue); #endif } } } } Rect r = EditorGUILayout.GetControlRect(); float[] vals = new float[2] { m_outputDistanceProp.vector2Value.x, m_outputDistanceProp.vector2Value.y }; EditorGUI.BeginChangeCheck(); EditorGUI.MultiFloatField(r, m_editorUtils.GetContent("mOutputDistance"), new GUIContent[] { new GUIContent(""), new GUIContent("-") }, vals); if (EditorGUI.EndChangeCheck()) { m_outputDistanceProp.vector2Value = new Vector2(vals[0], vals[1]); } m_editorUtils.SliderRange("mOutputVerticalAngle", m_outputVerticalAngleProp, inlineHelp, -180, 180); m_editorUtils.SliderRange("mOutputHorizontalAngle", m_outputHorizontalAngleProp, inlineHelp, -180, 180); m_outputFollowPosition.boolValue = m_editorUtils.Toggle("mOutputFollowPosition", m_outputFollowPosition.boolValue, inlineHelp); EditorGUI.BeginDisabledGroup(!m_outputFollowPosition.boolValue); m_outputFollowRotation.boolValue = m_editorUtils.Toggle("mOutputFollowRotation", m_outputFollowRotation.boolValue, inlineHelp); EditorGUI.EndDisabledGroup(); } EditorGUILayout.EndFadeGroup(); --EditorGUI.indentLevel; }
/// <summary> Displays a list of all Sequence assets in project </summary> /// <param name="inlineHelp">Should help be displayed?</param> void SequencesPanel(bool inlineHelp) { GUIStyle playButtonNormal; GUIStyle playButtonPressed; playButtonNormal = EditorStyles.miniButtonLeft; playButtonPressed = new GUIStyle(playButtonNormal); playButtonPressed.normal = playButtonNormal.active; GUIStyle muteButtonNormal; GUIStyle muteButtonPressed; muteButtonNormal = EditorStyles.miniButtonRight; muteButtonPressed = new GUIStyle(muteButtonNormal); muteButtonPressed.normal = muteButtonNormal.active; foreach (Sequence data in AllSequences) { EditorGUILayout.BeginHorizontal(); Rect r = EditorGUILayout.GetControlRect(); if (r.yMax > m_scrollPosition.y) { if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition)) { lastClickedOn = data; } else if (Event.current.type == EventType.MouseDrag && lastClickedOn == data && r.Contains(Event.current.mousePosition)) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new Object[] { data }; DragAndDrop.StartDrag("Sequence:" + data.name); Event.current.Use(); weStartedDrag = true; } else if (Event.current.type == EventType.DragUpdated && r.Contains(Event.current.mousePosition)) { bool found = false; for (int o = 0; o < DragAndDrop.objectReferences.Length; ++o) { if (DragAndDrop.objectReferences[o] is AudioClip) { DragAndDrop.visualMode = DragAndDropVisualMode.Link; Event.current.Use(); found = true; break; } } if (!found) { DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; Event.current.Use(); } } else if (Event.current.type == EventType.DragPerform && r.Contains(Event.current.mousePosition)) { List <Sequence.ClipData> clips = new List <Sequence.ClipData>(data.m_clipData); bool foundOne = false; for (int o = 0; o < DragAndDrop.objectReferences.Length; ++o) { if (DragAndDrop.objectReferences[o] is AudioClip) { foundOne = true; clips.Add(DragAndDrop.objectReferences[o] as AudioClip); } } if (foundOne) { data.m_clipData = clips.ToArray(); } } else if ((Event.current.type == EventType.DragExited || Event.current.type == EventType.MouseUp) && lastClickedOn == data && weStartedDrag) { weStartedDrag = false; lastClickedOn = null; DragAndDrop.PrepareStartDrag(); } } EditorGUI.ObjectField(r, data, typeof(Sequence), false); EditorGUI.BeginDisabledGroup(!Application.isPlaying); if (!Application.isPlaying || !AmbienceManager.WasSequenceAdded(data)) { if (m_editorUtils.Button(EditorGUIUtility.IconContent("PlayButton"), playButtonNormal, GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.ExpandWidth(false))) { data.m_forcePlay = true; AmbienceManager.AddSequence(data); } } else { if (m_editorUtils.Button(EditorGUIUtility.IconContent("PlayButton On"), playButtonPressed, GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.ExpandWidth(false))) { data.m_forcePlay = false; AmbienceManager.RemoveSequence(data); } } Color startColor = GUI.color; GUIStyle buttonStyle = muteButtonNormal; if (data.m_forceMuted) { GUI.color = Color.red; buttonStyle = muteButtonPressed; } if (m_editorUtils.Button(EditorGUIUtility.IconContent("preAudioAutoPlayOff"), buttonStyle, GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.ExpandWidth(false))) { if (Event.current.button == 1) { data.m_forceMuted = false; bool curMuted = true; foreach (Sequence s in AllSequences) { if (s != null && s != data) { curMuted &= s.m_forceMuted; } } foreach (Sequence s in AllSequences) { if (s != null && s != data) { s.m_forceMuted = !curMuted; } } } else { data.m_forceMuted = !data.m_forceMuted; } } GUI.color = startColor; EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); } ++EditorGUI.indentLevel; EditorGUILayout.BeginHorizontal(); if (m_editorUtils.Button("SequenceCreateButton", GUILayout.ExpandWidth(false))) { GUIContent dialogContent = m_editorUtils.GetContent("SequenceCreateDialog"); string newPath = EditorUtility.SaveFilePanelInProject(dialogContent.text, "Sequence", "asset", dialogContent.tooltip, newSequencePath); if (!string.IsNullOrEmpty(newPath)) { AssetDatabase.CreateAsset(CreateInstance <Sequence>(), newPath); Sequence newSequence = AssetDatabase.LoadAssetAtPath <Sequence>(newPath); Selection.activeInstanceID = newSequence.GetInstanceID(); } } Rect buttonRect = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.DragUpdated && buttonRect.Contains(Event.current.mousePosition)) { for (int o = 0; o < DragAndDrop.objectReferences.Length; ++o) { if (DragAndDrop.objectReferences[o] is AudioClip) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; Event.current.Use(); break; } } } else if (Event.current.type == EventType.DragPerform && buttonRect.Contains(Event.current.mousePosition)) { List <Sequence.ClipData> clips = new List <Sequence.ClipData>(); for (int o = 0; o < DragAndDrop.objectReferences.Length; ++o) { if (DragAndDrop.objectReferences[o] is AudioClip) { clips.Add(DragAndDrop.objectReferences[o] as AudioClip); } } if (clips.Count > 0) { if (Event.current.control) //create one for each { GUIContent dialogContent = m_editorUtils.GetContent("SequenceMultiCreateDialog"); string saveFolder = EditorUtility.SaveFolderPanel(dialogContent.text, "Assets", "Assets"); if (!string.IsNullOrEmpty(saveFolder)) { if (saveFolder.StartsWith(Application.dataPath)) { saveFolder = saveFolder.Substring(Application.dataPath.Length - 6); if (!saveFolder.EndsWith("/")) { saveFolder += "/"; } foreach (Sequence.ClipData clip in clips) { Sequence newSequence = CreateInstance <Sequence>(); newSequence.m_clipData = new Sequence.ClipData[] { clip }; AssetDatabase.CreateAsset(newSequence, saveFolder + clip.m_clip.name + ".asset"); } } else { GUIContent errorContent = m_editorUtils.GetContent("CreateWrongFolderError"); EditorUtility.DisplayDialog(errorContent.text, errorContent.tooltip, "Ok"); } } } else //stack all into one sequence { GUIContent dialogContent = m_editorUtils.GetContent("SequenceCreateDialog"); string savePath = EditorUtility.SaveFilePanelInProject(dialogContent.text, "Sequence", "asset", dialogContent.tooltip); if (!string.IsNullOrEmpty(savePath)) { Sequence newSequence = CreateInstance <Sequence>(); newSequence.m_clipData = clips.ToArray(); AssetDatabase.CreateAsset(newSequence, savePath); } } } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); m_editorUtils.InlineHelp("SequenceCreateButton", inlineHelp); --EditorGUI.indentLevel; }