void OnGUI() { if (toolbarSearchSkin == null) { toolbarSearchSkin = GUI.skin.FindStyle("ToolbarSeachTextField"); if (toolbarSearchButtonSkin == null) { toolbarSearchButtonSkin = GUI.skin.FindStyle("ToolbarSeachCancelButton"); } } EditorGUILayout.BeginVertical(); scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false); EditorGUILayout.BeginVertical("box"); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Particle Playground " + PlaygroundC.version + PlaygroundC.specialVersion, EditorStyles.largeLabel, GUILayout.Height(20)); EditorGUILayout.Separator(); // New version message if (!didSendVersionCheck) { CheckUpdate(); } if (updateAvailable) { EditorGUILayout.BeginVertical("box"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Update available"); GUILayout.FlexibleSpace(); if (GUILayout.Button("x", EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(18) })) { updateAvailable = false; } EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("Update " + onlineVersion + " is available. Please visit the Unity Asset Store to download the new version.", EditorStyles.wordWrappedMiniLabel); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Unity Asset Store", EditorStyles.toolbarButton, GUILayout.Width(100))) { Application.OpenURL("http://u3d.as/5ZJ"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); } EditorGUILayout.BeginVertical("box"); // Create New-buttons EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Particle Playground System", EditorStyles.toolbarButton)) { if (PlaygroundC.reference == null) { CreateManager(); } PlaygroundParticlesC newParticlePlayground = PlaygroundC.Particle(); Selection.activeGameObject = newParticlePlayground.particleSystemGameObject; } GUI.enabled = PlaygroundC.reference == null; if (GUILayout.Button("Playground Manager", EditorStyles.toolbarButton)) { PlaygroundC.ResourceInstantiate("Playground Manager"); } GUI.enabled = true; if (GUILayout.Button("Preset Wizard", EditorStyles.toolbarButton)) { PlaygroundCreatePresetWindowC.ShowWindow(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); // Presets EditorGUILayout.BeginVertical("box"); particlePresetFoldout = GUILayout.Toggle(particlePresetFoldout, "Presets", EditorStyles.foldout); if (particlePresetFoldout) { EditorGUILayout.BeginHorizontal("Toolbar"); // Search string prevSearchString = searchString; searchString = GUILayout.TextField(searchString, toolbarSearchSkin, new GUILayoutOption[] { GUILayout.ExpandWidth(false), GUILayout.Width(Mathf.FloorToInt(Screen.width) - 120), GUILayout.MinWidth(100) }); if (GUILayout.Button("", toolbarSearchButtonSkin)) { searchString = ""; GUI.FocusControl(null); } if (prevSearchString != searchString) { for (int p = 0; p < presetNames.Length; p++) { presetObjects[p].unfiltered = (searchString == ""?true:presetNames[p].ToLower().Contains(searchString.ToLower())); } } EditorGUILayout.Separator(); presetExampleUser = GUILayout.Toolbar(presetExampleUser, new string[] { "All", "User", "Examples" }, EditorStyles.toolbarButton, GUILayout.MaxWidth(170)); GUILayout.Label("", EditorStyles.toolbarButton); presetListStyle = GUILayout.Toolbar(presetListStyle, new string[] { "Icons", "List" }, EditorStyles.toolbarButton, GUILayout.MaxWidth(120)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical("box"); if (presetObjects.Count > 0) { if (presetListStyle == 0) { EditorGUILayout.BeginHorizontal(); } int rows = 1; int iconwidths = 0; int skippedPresets = 0; for (int i = 0; i < presetObjects.Count; i++) { // Filter out by search if (!presetObjects[i].unfiltered || presetExampleUser == 2 && !presetObjects[i].example || presetExampleUser == 1 && presetObjects[i].example) { skippedPresets++; continue; } // Preset Object were destroyed if (presetObjects[i].presetObject == null) { Initialize(); return; } // List if (presetListStyle == 1) { EditorGUILayout.BeginVertical("box", GUILayout.MinHeight(24)); EditorGUILayout.BeginHorizontal(); GUILayout.Label(i.ToString(), EditorStyles.miniLabel, new GUILayoutOption[] { GUILayout.Width(18) }); EditorGUILayout.LabelField(presetObjects[i].example?"(Example)":"(User)", EditorStyles.miniLabel, new GUILayoutOption[] { GUILayout.Width(50) }); if (GUILayout.Button(presetObjects[i].presetObject.name, EditorStyles.label)) { CreatePresetObject(i); } EditorGUILayout.Separator(); if (GUILayout.Button(presetObjects[i].example?"Convert to User":"******", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(106), GUILayout.Height(16) })) { if (presetObjects[i].example) { AssetDatabase.MoveAsset(AssetDatabase.GetAssetPath(presetObjects[i].presetObject), "Assets/" + playgroundPath + presetPath + presetObjects[i].presetObject.name + ".prefab"); } else { AssetDatabase.MoveAsset(AssetDatabase.GetAssetPath(presetObjects[i].presetObject), "Assets/" + playgroundPath + examplePresetPath + presetObjects[i].presetObject.name + ".prefab"); } } if (GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) })) { RemovePreset(presetObjects[i].presetObject); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } if (presetListStyle == 0) { // Break row for icons rows = Mathf.FloorToInt(Screen.width / 322); iconwidths += 322; if (iconwidths > Screen.width && i > 0) { iconwidths = 322; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); } if (Screen.width >= 644) { EditorGUILayout.BeginVertical("box", GUILayout.MaxWidth(Mathf.CeilToInt(Screen.width / rows) - (44 / rows))); } else { EditorGUILayout.BeginVertical("box"); } EditorGUILayout.BeginHorizontal(GUILayout.MinHeight(46)); if (GUILayout.Button(presetObjects[i].presetImage, EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.Width(44), GUILayout.Height(44) })) { CreatePresetObject(i); } EditorGUILayout.BeginVertical(); if (GUILayout.Button(presetObjects[i].presetObject.name, EditorStyles.label, GUILayout.Height(18))) { CreatePresetObject(i); } EditorGUILayout.LabelField(presetObjects[i].example?"Example":"User", EditorStyles.miniLabel); EditorGUILayout.EndVertical(); GUILayout.FlexibleSpace(); EditorGUILayout.BeginVertical(); if (GUILayout.Button("x", EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(18) })) { RemovePreset(presetObjects[i].presetObject); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } } if (skippedPresets == presetObjects.Count) { if (searchString != "") { EditorGUILayout.HelpBox("No preset found containing \"" + searchString + "\".", MessageType.Info); } else { if (presetExampleUser == 0) { EditorGUILayout.HelpBox("No presets found. Press \"Create\" to make a new preset.", MessageType.Info); } else if (presetExampleUser == 1) { EditorGUILayout.HelpBox("No user presets found in any \"Resources/Presets\" folder. Press \"Create\" to make a new preset.", MessageType.Info); } else if (presetExampleUser == 2) { EditorGUILayout.HelpBox("No example presets found. Make sure they are stored in \"" + "Assets/" + playgroundPath + examplePresetPath + "\"", MessageType.Info); } } } if (presetListStyle == 0) { EditorGUILayout.EndHorizontal(); } } else { EditorGUILayout.HelpBox("No presets found. Make sure that the path to the presets are set to: \"" + "Assets/" + playgroundPath + examplePresetPath + "\"", MessageType.Info); } if (GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))) { PlaygroundCreatePresetWindowC.ShowWindow(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); PlaygroundInspectorC.RenderPlaygroundSettings(); GUILayout.FlexibleSpace(); EditorGUILayout.BeginVertical("box"); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Official Site", EditorStyles.toolbarButton)) { Application.OpenURL("http://playground.polyfied.com/"); } if (GUILayout.Button("Asset Store", EditorStyles.toolbarButton)) { Application.OpenURL("http://u3d.as/5ZJ"); } if (GUILayout.Button("Manual", EditorStyles.toolbarButton)) { Application.OpenURL("http://www.polyfied.com/products/Particle-Playground-2-Next-Manual.pdf"); } if (GUILayout.Button("Support Forum", EditorStyles.toolbarButton)) { Application.OpenURL("http://forum.unity3d.com/threads/215154-Particle-Playground"); } if (GUILayout.Button("Mail Support", EditorStyles.toolbarButton)) { Application.OpenURL("mailto:[email protected]"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); GUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
void OnGUI() { if (toolbarSearchSkin == null) { toolbarSearchSkin = GUI.skin.FindStyle("ToolbarSeachTextField"); if (toolbarSearchButtonSkin == null) { toolbarSearchButtonSkin = GUI.skin.FindStyle("ToolbarSeachCancelButton"); } } EditorGUILayout.BeginVertical(); scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false); EditorGUILayout.BeginVertical("box"); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Playground Wizard (C#)", EditorStyles.largeLabel, GUILayout.Height(20)); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Particle Playground v" + PlaygroundC.version.ToString()); EditorGUILayout.Separator(); // Create New-button if (GUILayout.Button("Create New Particle Playground System", EditorStyles.toolbarButton)) { if (PlaygroundC.reference == null) { CreateManager(); } PlaygroundParticlesC newParticlePlayground = PlaygroundC.Particle(); Selection.activeGameObject = newParticlePlayground.particleSystemGameObject; } EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); // Presets EditorGUILayout.BeginVertical("box"); particlePresetFoldout = GUILayout.Toggle(particlePresetFoldout, "Presets", EditorStyles.foldout); if (particlePresetFoldout) { EditorGUILayout.BeginHorizontal("Toolbar"); // Search string prevSearchString = searchString; searchString = GUILayout.TextField(searchString, toolbarSearchSkin, new GUILayoutOption[] { GUILayout.ExpandWidth(false), GUILayout.Width(Mathf.FloorToInt(Screen.width) - 170), GUILayout.MinWidth(170) }); if (GUILayout.Button("", toolbarSearchButtonSkin)) { searchString = ""; GUI.FocusControl(null); } if (prevSearchString != searchString) { for (int p = 0; p < presetNames.Length; p++) { presetObjects[p].unfiltered = (searchString == ""?true:presetNames[p].ToLower().Contains(searchString.ToLower())); } } EditorGUILayout.Separator(); presetListStyle = GUILayout.Toolbar(presetListStyle, new string[] { "Icons", "List" }, EditorStyles.toolbarButton, GUILayout.MaxWidth(120)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical("box"); if (presetObjects.Count > 0) { int col1 = Mathf.FloorToInt(Screen.width / 2.2f) - 46; if (presetListStyle == 0) { EditorGUILayout.BeginHorizontal(); } int iconwidths = 0; for (int i = 0; i < presetObjects.Count; i++) { // Filter out by search if (!presetObjects[i].unfiltered) { continue; } // Preset Object were destroyed if (!presetObjects[i].presetObject) { Initialize(); return; } // List if (presetListStyle == 1) { EditorGUILayout.BeginVertical("box", GUILayout.MinHeight(22)); EditorGUILayout.BeginHorizontal(); presetObjects[i].foldout = GUILayout.Toggle(presetObjects[i].foldout, presetObjects[i].presetObject.name, EditorStyles.foldout); EditorGUILayout.Separator(); if (GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))) { CreatePresetObject(i); } EditorGUILayout.EndHorizontal(); if (presetObjects[i].foldout) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Source:", EditorStyles.miniBoldLabel, GUILayout.Width(col1)); EditorGUILayout.LabelField(presetObjects[i].presetScript.source.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("States:", EditorStyles.miniBoldLabel, GUILayout.Width(col1)); EditorGUILayout.LabelField(presetObjects[i].presetScript.states.Count.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Particle Count:", EditorStyles.miniBoldLabel, GUILayout.Width(col1)); EditorGUILayout.LabelField(presetObjects[i].presetScript.particleCount.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Emission Rate:", EditorStyles.miniBoldLabel, GUILayout.Width(col1)); EditorGUILayout.LabelField(presetObjects[i].presetScript.emissionRate.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Lifetime:", EditorStyles.miniBoldLabel, GUILayout.Width(col1)); EditorGUILayout.LabelField(presetObjects[i].presetScript.lifetime.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Sorting:", EditorStyles.miniBoldLabel, GUILayout.Width(col1)); EditorGUILayout.LabelField(presetObjects[i].presetScript.sorting.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Delta Movement:", EditorStyles.miniBoldLabel, GUILayout.Width(col1)); EditorGUILayout.LabelField(presetObjects[i].presetScript.calculateDeltaMovement.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Lifetime Velocity:", EditorStyles.miniBoldLabel, GUILayout.Width(col1)); EditorGUILayout.LabelField(presetObjects[i].presetScript.applyLifetimeVelocity.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Initial Velocity:", EditorStyles.miniBoldLabel, GUILayout.Width(col1)); EditorGUILayout.LabelField(presetObjects[i].presetScript.applyInitialVelocity.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Local Velocity:", EditorStyles.miniBoldLabel, GUILayout.Width(col1)); EditorGUILayout.LabelField(presetObjects[i].presetScript.applyInitialLocalVelocity.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Velocity Bending:", EditorStyles.miniBoldLabel, GUILayout.Width(col1)); EditorGUILayout.LabelField(presetObjects[i].presetScript.applyVelocityBending.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Collision:", EditorStyles.miniBoldLabel, GUILayout.Width(col1)); EditorGUILayout.LabelField(presetObjects[i].presetScript.collision.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Material:", EditorStyles.miniBoldLabel, GUILayout.Width(col1)); EditorGUILayout.LabelField(presetObjects[i].presetScript.particleSystemRenderer.sharedMaterial.name.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Update Rate:", EditorStyles.miniBoldLabel, GUILayout.Width(col1)); EditorGUILayout.LabelField(presetObjects[i].presetScript.updateRate.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); if (GUILayout.Button("Delete", EditorStyles.toolbarButton, GUILayout.Width(50))) { if (EditorUtility.DisplayDialog("Permanently delete this preset?", "The preset " + presetObjects[i].presetObject.name + " will be removed, are you sure?", "Yes", "No")) { AssetDatabase.MoveAssetToTrash(AssetDatabase.GetAssetPath(presetObjects[i].presetObject)); } } } EditorGUILayout.EndVertical(); } if (presetListStyle == 0) { // Break row for icons iconwidths += 318; if (iconwidths >= Screen.width && i > 0) { iconwidths = 318; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); } if (Screen.width > 636) { EditorGUILayout.BeginVertical("box", GUILayout.Width(300)); } else { EditorGUILayout.BeginVertical("box"); } EditorGUILayout.BeginHorizontal(GUILayout.MinHeight(42)); if (GUILayout.Button(presetObjects[i].presetImage, new GUILayoutOption[] { GUILayout.Width(44), GUILayout.Height(40) })) { CreatePresetObject(i); } EditorGUILayout.BeginVertical(); if (GUILayout.Button(presetObjects[i].presetScript.name.ToString(), EditorStyles.label, new GUILayoutOption[] { GUILayout.Height(18) })) { CreatePresetObject(i); } EditorGUILayout.LabelField(presetObjects[i].presetScript.source.ToString() + " (" + presetObjects[i].presetScript.particleCount.ToString() + ")", EditorStyles.miniLabel, new GUILayoutOption[] { GUILayout.Height(18), GUILayout.Width(240) }); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } } if (presetListStyle == 0) { EditorGUILayout.EndHorizontal(); } } else { EditorGUILayout.HelpBox("No presets found. Make sure that the path to the presets are set to: \"" + playgroundPath + presetPath + "\"", MessageType.Info); } if (GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))) { PlaygroundCreatePresetWindowC.ShowWindow(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); PlaygroundInspectorC.RenderPlaygroundSettings(); GUILayout.FlexibleSpace(); EditorGUILayout.BeginVertical("box"); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Official Site", EditorStyles.toolbarButton)) { Application.OpenURL("http://playground.polyfied.com/"); } if (GUILayout.Button("Asset Store", EditorStyles.toolbarButton)) { Application.OpenURL("http://u3d.as/5ZJ"); } if (GUILayout.Button("Support Forum", EditorStyles.toolbarButton)) { Application.OpenURL("http://forum.unity3d.com/threads/215154-Particle-Playground"); } if (GUILayout.Button("Mail Support", EditorStyles.toolbarButton)) { Application.OpenURL("mailto:[email protected]"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); GUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }