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(); }
public static void RenderPlaygroundSettings() { if (boxStyle == null) { boxStyle = GUI.skin.FindStyle("box"); } EditorGUILayout.BeginVertical(boxStyle); playgroundFoldout = GUILayout.Toggle(playgroundFoldout, "Playground Manager", EditorStyles.foldout); if (playgroundFoldout) { EditorGUILayout.BeginVertical(boxStyle); if (playgroundScriptReference == null) { playgroundScriptReference = GameObject.FindObjectOfType <PlaygroundC>(); if (playgroundScriptReference) { Initialize(playgroundScriptReference); } } if (playgroundFoldout && playgroundScriptReference != null) { playground.Update(); // Particle System List if (GUILayout.Button("Particle Systems (" + playgroundScriptReference.particleSystems.Count + ")", EditorStyles.toolbarDropDown)) { particleSystemsFoldout = !particleSystemsFoldout; } if (particleSystemsFoldout) { EditorGUILayout.Separator(); if (playgroundScriptReference.particleSystems.Count > 0) { for (int ps = 0; ps < playgroundScriptReference.particleSystems.Count; ps++) { EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(26)); EditorGUILayout.BeginHorizontal(); if (playgroundScriptReference.particleSystems[ps].particleSystemGameObject == Selection.activeGameObject) { GUILayout.BeginHorizontal(boxStyle); } GUILayout.Label(ps.ToString(), EditorStyles.miniLabel, new GUILayoutOption[] { GUILayout.Width(18) }); if (GUILayout.Button(playgroundScriptReference.particleSystems[ps].particleSystemGameObject.name, EditorStyles.label)) { Selection.activeGameObject = playgroundScriptReference.particleSystems[ps].particleSystemGameObject; } EditorGUILayout.Separator(); GUI.enabled = (playgroundScriptReference.particleSystems.Count > 1); if (GUILayout.Button("U", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) })) { particleSystems.MoveArrayElement(ps, ps == 0?playgroundScriptReference.particleSystems.Count - 1:ps - 1); } if (GUILayout.Button("D", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) })) { particleSystems.MoveArrayElement(ps, ps < playgroundScriptReference.particleSystems.Count - 1?ps + 1:0); } GUI.enabled = true; // Clone if (GUILayout.Button("+", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) })) { GameObject ppsDuplicateGo = Instantiate(playgroundScriptReference.particleSystems[ps].particleSystemGameObject, playgroundScriptReference.particleSystems[ps].particleSystemTransform.position, playgroundScriptReference.particleSystems[ps].particleSystemTransform.rotation) as GameObject; PlaygroundParticlesC ppsDuplicate = ppsDuplicateGo.GetComponent <PlaygroundParticlesC>(); // Cache state data for (int x = 0; x < ppsDuplicate.states.Count; x++) { ppsDuplicate.states[x].Initialize(); } // Set particle count to initiate all arrays PlaygroundC.SetParticleCount(ppsDuplicate, ppsDuplicate.particleCount); // Add this to Manager if (PlaygroundC.reference != null) { PlaygroundC.particlesQuantity++; PlaygroundC.reference.particleSystems.Add(ppsDuplicate); ppsDuplicate.particleSystemId = PlaygroundC.particlesQuantity; if (PlaygroundC.reference.autoGroup && ppsDuplicate.particleSystemTransform.parent == null) { ppsDuplicate.particleSystemTransform.parent = PlaygroundC.referenceTransform; } } } if (GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) })) { if (EditorUtility.DisplayDialog( "Remove " + playgroundScriptReference.particleSystems[ps].particleSystemGameObject.name + "?", "Are you sure you want to remove this Particle Playground System?", "Yes", "No")) { if (Selection.activeGameObject == playgroundScriptReference.particleSystems[ps].particleSystemGameObject) { Selection.activeGameObject = PlaygroundC.referenceTransform.gameObject; } PlaygroundC.Destroy(playgroundScriptReference.particleSystems[ps]); playground.ApplyModifiedProperties(); return; } } if (playgroundScriptReference.particleSystems[ps].particleSystemGameObject == Selection.activeGameObject) { GUILayout.EndHorizontal(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } } else { EditorGUILayout.HelpBox("No particle systems created.", MessageType.Info); } if (GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))) { PlaygroundParticlesC createdParticles = PlaygroundC.Particle(); Selection.activeGameObject = createdParticles.particleSystemGameObject; } EditorGUILayout.Separator(); } // Manipulators if (GUILayout.Button("Global Manipulators (" + playgroundScriptReference.manipulators.Count + ")", EditorStyles.toolbarDropDown)) { manipulatorsFoldout = !manipulatorsFoldout; } if (manipulatorsFoldout) { EditorGUILayout.Separator(); if (manipulators.arraySize > 0) { for (int i = 0; i < manipulators.arraySize; i++) { string mName; if (playgroundScriptReference.manipulators[i].transform) { mName = playgroundScriptReference.manipulators[i].transform.name; if (mName.Length > 24) { mName = mName.Substring(0, 24) + "..."; } } else { mName = "(Missing Transform!)"; } EditorGUILayout.BeginVertical(boxStyle); EditorGUILayout.BeginHorizontal(); GUILayout.Label(i.ToString(), EditorStyles.miniLabel, GUILayout.Width(18)); manipulatorListFoldout[i] = GUILayout.Toggle(manipulatorListFoldout[i], ManipulatorTypeName(playgroundScriptReference.manipulators[i].type), EditorStyles.foldout, GUILayout.Width(Screen.width / 4)); if (playgroundScriptReference.manipulators[i].transform) { if (GUILayout.Button(" (" + mName + ")", EditorStyles.label)) { Selection.activeGameObject = playgroundScriptReference.manipulators[i].transform.gameObject; } } else { GUILayout.Button(ManipulatorTypeName(playgroundScriptReference.manipulators[i].type) + " (Missing Transform!)", EditorStyles.label); } EditorGUILayout.Separator(); GUI.enabled = (playgroundScriptReference.manipulators.Count > 1); if (GUILayout.Button("U", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) })) { manipulators.MoveArrayElement(i, i == 0?playgroundScriptReference.manipulators.Count - 1:i - 1); } if (GUILayout.Button("D", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) })) { manipulators.MoveArrayElement(i, i < playgroundScriptReference.manipulators.Count - 1?i + 1:0); } GUI.enabled = true; if (GUILayout.Button("+", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) })) { PlaygroundC.reference.manipulators.Add(playgroundScriptReference.manipulators[i].Clone()); manipulatorListFoldout.Add(manipulatorListFoldout[i]); } if (GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) })) { if (EditorUtility.DisplayDialog( "Remove " + ManipulatorTypeName(playgroundScriptReference.manipulators[i].type) + " Manipulator " + i + "?", "Are you sure you want to remove the Manipulator assigned to " + mName + "? (GameObject in Scene will remain intact)", "Yes", "No")) { manipulators.DeleteArrayElementAtIndex(i); manipulatorListFoldout.RemoveAt(i); playground.ApplyModifiedProperties(); return; } } EditorGUILayout.EndHorizontal(); if (manipulatorListFoldout[i] && i < manipulators.arraySize) { RenderManipulatorSettings(playgroundScriptReference.manipulators[i], manipulators.GetArrayElementAtIndex(i), true); } GUI.enabled = true; EditorGUILayout.Separator(); EditorGUILayout.EndVertical(); } } else { EditorGUILayout.HelpBox("No manipulators created.", MessageType.Info); } if (GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))) { if (Selection.gameObjects.Length > 0 && Selection.activeGameObject.transform && Selection.activeTransform != null) { PlaygroundC.ManipulatorObject(Selection.activeGameObject.transform); } else { manipulators.InsertArrayElementAtIndex(manipulators.arraySize); } manipulatorListFoldout.Add(true); SceneView.RepaintAll(); } EditorGUILayout.Separator(); } // Advanced Settings if (GUILayout.Button("Advanced", EditorStyles.toolbarDropDown)) { advancedSettingsFoldout = !advancedSettingsFoldout; } if (advancedSettingsFoldout) { EditorGUILayout.Separator(); EditorGUILayout.PropertyField(calculate, new GUIContent("Calculate Particles", "Calculate forces on PlaygroundParticles objects. Disabling this overrides independently set values and halts all PlaygroundParticles objects.")); EditorGUILayout.PropertyField(garbageCollectOnResize, new GUIContent("Garbage Collection", "Issue a GC.Collect when resizing particle lists.")); EditorGUILayout.PropertyField(autoGroup, new GUIContent("Group Automatically", "Automatically parent a PlaygroundParticles object to Playground Manager if it has no parent.")); EditorGUILayout.PropertyField(buildZeroAlphaPixels, new GUIContent("Build Zero Alpha Pixels", "Turn this on if you want to build particles from 0 alpha pixels into states.")); EditorGUILayout.PropertyField(drawGizmos, new GUIContent("Scene Gizmos", "Show gizmos in Scene View for Playground objects.")); EditorGUILayout.PropertyField(paintToolbox, new GUIContent("Paint Toolbox", "Show Paint toolbox in Scene View when Source is set to Paint")); EditorGUILayout.PropertyField(showShuriken, new GUIContent("Show Shuriken", "Show the Shuriken component in Inspector.")); EditorGUILayout.PropertyField(pixelFilterMode, new GUIContent("Pixel Filter Mode", "Color filtering mode when creating particles from pixels in an image.")); EditorGUILayout.Separator(); // Time reset GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Time Simulation"); if (GUILayout.Button("Reset", EditorStyles.toolbarButton, GUILayout.Width(50))) { PlaygroundC.TimeReset(); for (int p = 0; p < playgroundScriptReference.particleSystems.Count; p++) { playgroundScriptReference.particleSystems[p].Start(); } } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); // Limits EditorGUILayout.BeginVertical(boxStyle); limitsFoldout = GUILayout.Toggle(limitsFoldout, "Editor Limits", EditorStyles.foldout); if (limitsFoldout) { EditorGUILayout.Separator(); playgroundScriptReference.maximumAllowedTransitionTime = EditorGUILayout.FloatField("Transition Time", playgroundScriptReference.maximumAllowedTransitionTime); EditorGUILayout.Separator(); playgroundScriptReference.maximumAllowedParticles = EditorGUILayout.IntField("Particle Count", playgroundScriptReference.maximumAllowedParticles); playgroundScriptReference.maximumAllowedLifetime = EditorGUILayout.FloatField("Particle Lifetime", playgroundScriptReference.maximumAllowedLifetime); playgroundScriptReference.maximumAllowedRotation = EditorGUILayout.FloatField("Particle Rotation", playgroundScriptReference.maximumAllowedRotation); playgroundScriptReference.maximumAllowedSize = EditorGUILayout.FloatField("Particle Size", playgroundScriptReference.maximumAllowedSize); playgroundScriptReference.maximumAllowedScale = EditorGUILayout.FloatField("Particle Scale", playgroundScriptReference.maximumAllowedScale); playgroundScriptReference.maximumAllowedSourceScatter = EditorGUILayout.FloatField("Source Scatter", playgroundScriptReference.maximumAllowedSourceScatter); EditorGUILayout.Separator(); playgroundScriptReference.maximumAllowedDeltaMovementStrength = EditorGUILayout.FloatField("Delta Movement Strength", playgroundScriptReference.maximumAllowedDeltaMovementStrength); playgroundScriptReference.maximumAllowedDamping = EditorGUILayout.FloatField("Damping", playgroundScriptReference.maximumAllowedDamping); playgroundScriptReference.maximumAllowedInitialVelocity = EditorGUILayout.FloatField("Initial Velocity", playgroundScriptReference.maximumAllowedInitialVelocity); playgroundScriptReference.maximumAllowedVelocity = EditorGUILayout.FloatField("Velocity", playgroundScriptReference.maximumAllowedVelocity); EditorGUILayout.Separator(); playgroundScriptReference.maximumAllowedCollisionRadius = EditorGUILayout.FloatField("Collision Radius", playgroundScriptReference.maximumAllowedCollisionRadius); playgroundScriptReference.maximumAllowedMass = EditorGUILayout.FloatField("Mass", playgroundScriptReference.maximumAllowedMass); playgroundScriptReference.maximumAllowedBounciness = EditorGUILayout.FloatField("Bounciness", playgroundScriptReference.maximumAllowedBounciness); EditorGUILayout.Separator(); playgroundScriptReference.minimumAllowedUpdateRate = EditorGUILayout.IntField("Update Rate", playgroundScriptReference.minimumAllowedUpdateRate); playgroundScriptReference.maximumRenderSliders = EditorGUILayout.FloatField("Render Sliders", playgroundScriptReference.maximumRenderSliders); EditorGUILayout.Separator(); playgroundScriptReference.maximumAllowedPaintPositions = EditorGUILayout.IntField("Paint Positions", playgroundScriptReference.maximumAllowedPaintPositions); playgroundScriptReference.minimumAllowedBrushScale = EditorGUILayout.FloatField("Brush Size Min", playgroundScriptReference.minimumAllowedBrushScale); playgroundScriptReference.maximumAllowedBrushScale = EditorGUILayout.FloatField("Brush Size Max", playgroundScriptReference.maximumAllowedBrushScale); playgroundScriptReference.minimumEraserRadius = EditorGUILayout.FloatField("Eraser Size Min", playgroundScriptReference.minimumEraserRadius); playgroundScriptReference.maximumEraserRadius = EditorGUILayout.FloatField("Eraser Size Max", playgroundScriptReference.maximumEraserRadius); playgroundScriptReference.maximumAllowedPaintSpacing = EditorGUILayout.FloatField("Paint Spacing", playgroundScriptReference.maximumAllowedPaintSpacing); EditorGUILayout.Separator(); playgroundScriptReference.maximumAllowedManipulatorSize = EditorGUILayout.FloatField("Manipulator Size", playgroundScriptReference.maximumAllowedManipulatorSize); playgroundScriptReference.maximumAllowedManipulatorStrength = EditorGUILayout.FloatField("Manipulator Strength", playgroundScriptReference.maximumAllowedManipulatorStrength); playgroundScriptReference.maximumAllowedManipulatorZeroVelocity = EditorGUILayout.FloatField("Zero Velocity Strength", playgroundScriptReference.maximumAllowedManipulatorZeroVelocity); EditorGUILayout.Separator(); } EditorGUILayout.EndVertical(); } EditorGUI.indentLevel--; playground.ApplyModifiedProperties(); EditorGUILayout.EndVertical(); } else { EditorGUILayout.HelpBox("The Playground Manager runs all Particle Playground Systems in the scene, you need to create one in your scene to get started.", MessageType.Info); if (GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50))) { PlaygroundC.ResourceInstantiate("Playground Manager"); } EditorGUILayout.EndVertical(); } } 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(); }