void OnGUI() { EditorGUILayout.BeginVertical(); root = (Transform)EditorGUILayout.ObjectField("Ragdoll Root", root, typeof(Transform), true); folder = EditorGUILayout.ObjectField("Destination Folder", folder, typeof(Object), false); ragdoll = (RagdollAsset)EditorGUILayout.ObjectField("Ragdoll to Update (Optional)", ragdoll, typeof(RagdollAsset), false); GUILayoutHelpers.HorzLine(); GUI.enabled = (root != null) && ((ragdoll != null) || (folder != null)); if (GUILayout.Button((ragdoll != null) ? "Update Ragdoll Asset" : "Create Ragdoll Asset")) { if (ragdoll != null) { ragdoll.Rebuild(root); } else { if (RagdollAsset.Create(root, Utils.SafeGetNewAssetPathFromPath(AssetDatabase.GetAssetPath(folder) + "/NewRagdoll")) == null) { EditorUtility.DisplayDialog("Error", "No ragdoll components were found from the specified root.", "OK"); } } } GUI.enabled = true; EditorGUILayout.EndVertical(); }
public static string OnGUI_ScriptFlags(string symbols, bool forBuild) { EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUILayoutHelpers.CenterLabel("Script Options"); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); string newSymbols = string.Empty; foreach (var flag in flags) { if (!(forBuild && flag.hiddenInBuild)) { var b = EditorGUILayout.Toggle(new GUIContent(flag.name, flag.description), IsDefined(symbols, flag.value)); if (b) { if (newSymbols.Length > 0) { newSymbols += ';' + flag.value; } else { newSymbols = flag.value; } } } } return(newSymbols); }
public Group Begin(string text) { Group g; if (_index < _groups.Count) { g = _groups[_index]; } else { g = new Group(this); _groups.Add(g); } ++_index; g.foldout = GUILayoutHelpers.Foldout(g.foldout, text, true); if (!g.foldout) { return(null); } ++EditorGUI.indentLevel; return(g); }
bool Inspect(PhysicalContact contact) { var soundCue = (SoundCue)EditorGUILayout.ObjectField("Sound Cue", contact.soundCue, typeof(SoundCue), false); var fxPrefabChanged = WeakAssetRefDrawer.WeakRefField("Fx Prefab", contact.fxPrefab); var rate = Mathf.Max(0f, EditorGUILayout.FloatField("Max Contact Rate", contact.maxContactRate)); var max = Mathf.Max(0, EditorGUILayout.IntField("Max Living Contacts", contact.maxLivingContacts)); var splatterRadius = GUILayoutHelpers.MinMaxSlider("Blood Splatter Radius", contact.bloodSplatterRadius, 0, 8); var splatterSize = GUILayoutHelpers.MinMaxSlider("Blood Splatter Size", contact.bloodSplatterSize, 0, 8); var splatterCount = GUILayoutHelpers.MinMaxSlider("Blood Splatter Count", contact.bloodSplatterCount, 0, 64); if (fxPrefabChanged || !ReferenceEquals(soundCue, contact.soundCue) || (rate != contact.maxContactRate) || (max != contact.maxLivingContacts) || (splatterRadius != contact.bloodSplatterRadius) || (splatterSize != contact.bloodSplatterSize) || (splatterCount != contact.bloodSplatterCount)) { contact.soundCue = soundCue; contact.maxContactRate = rate; contact.maxLivingContacts = max; contact.bloodSplatterRadius = splatterRadius; contact.bloodSplatterSize = splatterSize; contact.bloodSplatterCount = splatterCount; return(true); } return(false); }
void OnGUI() { EditorGUILayout.BeginVertical(); root = (Transform)EditorGUILayout.ObjectField("Hierarchy Root", root, typeof(Transform), true); folder = EditorGUILayout.ObjectField("Destination Folder", folder, typeof(Object), false); tags = (TagsAsset)EditorGUILayout.ObjectField("Tags to Update (Optional)", tags, typeof(TagsAsset), false); GUILayoutHelpers.HorzLine(); GUI.enabled = (root != null) && ((tags != null) || (folder != null)); if (GUILayout.Button((tags != null) ? "Update Tags Asset" : "Create Tags Asset")) { if (tags != null) { tags.Rebuild(root); } else { if (TagsAsset.Create(root, Utils.SafeGetNewAssetPathFromPath(AssetDatabase.GetAssetPath(folder) + "/NewTags")) == null) { EditorUtility.DisplayDialog("Error", "Couldn't create tags asset.", "OK"); } } } GUI.enabled = true; EditorGUILayout.EndVertical(); }
void OnGUI_BuildPlatforms() { EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUILayoutHelpers.CenterLabel("Platforms"); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); foreach (var p in PLATFORMS) { var b = EditorGUILayout.Toggle(p.name, p.shouldBuild); if (b != p.shouldBuild) { p.shouldBuild = b; EditorPrefs.SetBool("steambuild_" + p.name, b); } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var attr = (MinMaxSlider)attribute; if (fieldInfo.FieldType == typeof(Vector2)) { property.vector2Value = GUILayoutHelpers.MinMaxSlider(position, label.text, property.vector2Value, attr.min, attr.max); } else { var boxed = property.GetValue(); if (boxed != null) { var v = (IntMath.Vector2i)property.GetValue(); var newV = GUILayoutHelpers.MinMaxSlider(position, label.text, v, Mathf.FloorToInt(attr.min), Mathf.FloorToInt(attr.max)); if (newV != v) { property.SetValue(newV); EditorUtility.SetDirty(property.serializedObject.targetObject); } } } }
void OnGUI() { EditorGUILayout.BeginVertical(); GUILayoutHelpers.HorzLine(); { var s = BuildOptionsWindow.OnGUI_ScriptFlags(scriptFlags, true); if (s != scriptFlags) { EditorPrefs.SetString("steamscriptflags", s); scriptFlags = s; } } GUILayoutHelpers.HorzLine(); OnGUI_BuildPlatforms(); GUILayoutHelpers.HorzLine(); #if PERFORCE EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUILayoutHelpers.CenterLabel("Perforce"); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); { var s = EditorGUILayout.TextField("P4 Directory", p4path); if (s != p4path) { EditorPrefs.SetString("p4path", s); p4path = s; } s = EditorGUILayout.TextField("P4 Server", p4server); if (s != p4server) { EditorPrefs.SetString("p4server", s); p4server = s; } s = EditorGUILayout.TextField("P4 User", p4user); if (s != p4user) { EditorPrefs.SetString("p4user", s); p4user = s; } s = EditorGUILayout.PasswordField("P4 Password", p4pass); if (s != p4pass) { EditorPrefs.SetString("p4pass", s); p4pass = s; } s = EditorGUILayout.TextField("P4 Workspace", p4client); if (s != p4client) { EditorPrefs.SetString("p4client", s); p4client = s; } } GUILayoutHelpers.HorzLine(); #endif EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUILayoutHelpers.CenterLabel("Steam"); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); { var i = 0; while ((branch != BRANCHES[i]) && (i < BRANCHES.Length)) { ++i; } if (i >= BRANCHES.Length) { i = 0; } var s = EditorGUILayout.Popup("Set Live", i, BRANCHES); if (s != i) { branch = BRANCHES[s]; EditorPrefs.SetString("steambranch", branch); } } { var s = EditorGUILayout.TextField("Steam Login", steamLogin); if (s != steamLogin) { EditorPrefs.SetString("steamlogin", s); steamLogin = s; } } { var s = EditorGUILayout.PasswordField("Steam Password", steamPassword); if (s != steamPassword) { EditorPrefs.SetString("steampass", s); steamPassword = s; } } GUILayoutHelpers.HorzLine(); bool build = false; if (GUILayout.Button("Build (testing only!)...")) { build = true; } bool publish = false; if (GUILayout.Button("Build and Publish...")) { publish = true; build = true; } //if (GUILayout.Button("Retry Publish (careful!)...")) { // publish = true; //} EditorGUILayout.EndVertical(); string oldScriptFlags = null; if (build || publish) { #if PERFORCE if (string.IsNullOrEmpty(p4path) || string.IsNullOrEmpty(p4server) || string.IsNullOrEmpty(p4user) || string.IsNullOrEmpty(p4pass) || string.IsNullOrEmpty(p4client)) { EditorUtility.DisplayDialog("Error", "Please fill in the perforce fields to build for Steam.", "OK"); return; } #endif oldScriptFlags = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone); } if (build && publish) { var progress = new EditorProgressBar("Building...", 2); var r = CheckForPrereqs() && Build(); if (r) { progress.Step("Publishing..."); r = Publish(); progress.Step(null); } else { progress.Close(); } if (r) { EditorUtility.DisplayDialog("Success", "Build and publish completed successfully.", "OK"); } else { EditorUtility.DisplayDialog("Error", "Build failed.", "OK"); } } else if (build) { var progress = new EditorProgressBar("Building...", 1); var r = CheckForPrereqs() && Build(); progress.Step(null); if (r) { EditorUtility.DisplayDialog("Success", "Build completed successfully.", "OK"); } else { EditorUtility.DisplayDialog("Error", "Build failed.", "OK"); } } else if (publish) { var progress = new EditorProgressBar("Publishing...", 1); var r = CheckForPrereqs(); if (r) { progress.Step("Publishing..."); r = Publish(); progress.Step(null); } else { progress.Close(); } if (r) { EditorUtility.DisplayDialog("Success", "Publish completed successfully.", "OK"); } else { EditorUtility.DisplayDialog("Error", "Publish failed.", "OK"); } } if (build || publish) { if (oldScriptFlags != PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone)) { PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, oldScriptFlags); } } }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.PropertyField(_playChance); _volume.vector2Value = GUILayoutHelpers.MinMaxSlider("Volume", _volume.vector2Value, 0, 1); _pitch.vector2Value = GUILayoutHelpers.MinMaxSlider("Pitch", _pitch.vector2Value, -3, 3); _reverb.vector2Value = GUILayoutHelpers.MinMaxSlider("Reverb", _reverb.vector2Value, 0, 1.1f); EditorGUILayout.PropertyField(_loop); EditorGUILayout.PropertyField(_clipRef); var newClip = _clip.Load(); if (newClip != _loaded) { _loaded = newClip; StopPlaying(); } var oldPrefab = _audioSourcePrefab.objectReferenceValue; EditorGUILayout.PropertyField(_audioSourcePrefab, true); if (!ReferenceEquals(oldPrefab, _audioSourcePrefab.objectReferenceValue)) { StopPlaying(); } SoundCue self = (SoundCue)target; var wasEnabled = GUI.enabled; if (_source == null) { GUI.enabled = (_loaded != null) && (self.audioSourcePrefab != null); if (GUILayout.Button("Play")) { string unused; var clipToPlay = _loaded.RandomClip(Random.value, out unused); if (clipToPlay != null) { var go = (GameObject)GameObject.Instantiate(self.audioSourcePrefab.gameObject, Vector3.zero, Quaternion.identity); go.hideFlags = HideFlags.HideAndDontSave; _source = go.GetComponent <AudioSource>(); go.AddComponent <AudioSourceGC>(); _source.spatialBlend = 0f; _source.clip = clipToPlay; _source.volume = self.RandomVolume(Random.value); _source.pitch = self.RandomPitch(Random.value); _source.reverbZoneMix = self.RandomReverb(Random.value); _source.loop = _loop.boolValue; _source.Play(); EditorApplication.update += Update; } } } else { GUI.enabled = true; if (GUILayout.Button("Stop")) { StopPlaying(); } } GUI.enabled = wasEnabled; serializedObject.ApplyModifiedProperties(); }