bool IsRendererInAnotherGameObject(SpriteToParticles stP) { RenderSystemUsing renderType = (RenderSystemUsing)renderSystemType.intValue; if (renderType == RenderSystemUsing.SpriteRenderer && stP.spriteRenderer != null) { return(stP.spriteRenderer.gameObject != stP.particlesSystem.gameObject); } if (renderType == RenderSystemUsing.ImageRenderer && stP.imageRenderer != null) { return(stP.imageRenderer.gameObject != stP.particlesSystem.gameObject); } return(true); }
/// <summary> /// Display precise variables for StP different modes /// </summary> public override void OnInspectorGUI() { SpriteToParticles StP = (SpriteToParticles)target; showHelp = EditorPrefs.GetBool("SpriteToParticles.ShowTools"); //showWarnings = EditorPrefs.GetBool("SpriteToParticles.ShowWarnings"); GUIStyle Title = new GUIStyle(EditorStyles.textArea); Title.normal.textColor = Color.white; Title.fontStyle = FontStyle.Bold; serializedObject.Update(); RenderSystemUsing renderType = (RenderSystemUsing)renderSystemType.intValue; SpriteMode _emissionMode = (SpriteMode)spriteMode.intValue; GUILayout.Space(5f); EditorGUILayout.LabelField("Main Config", Title); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(spriteMode); EditorGUILayout.PropertyField(renderSystemType); EditorGUI.indentLevel--; GUILayout.Space(5f); EditorGUILayout.LabelField("References", Title); EditorGUI.indentLevel++; if (renderType == RenderSystemUsing.SpriteRenderer) { EditorGUILayout.PropertyField(spriteRenderer); } if (renderType == RenderSystemUsing.ImageRenderer) { EditorGUILayout.PropertyField(imageRenderer); } EditorGUILayout.PropertyField(particlesSystem); if (showHelp) { CheckValidations(); } EditorGUI.indentLevel--; GUILayout.Space(5f); EditorGUILayout.LabelField("Emission Options", Title); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(PlayOnAwake); EditorGUILayout.PropertyField(EmissionRate); if (_emissionMode != SpriteMode.Static) { EditorGUILayout.PropertyField(borderEmission); } EditorGUILayout.PropertyField(UsePixelSourceColor); GUILayout.Space(5f); EditorGUILayout.PropertyField(UseEmissionFromColor); if (UseEmissionFromColor.boolValue) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(EmitFromColor); EditorGUILayout.PropertyField(RedTolerance); EditorGUILayout.PropertyField(GreenTolerance); EditorGUILayout.PropertyField(BlueTolerance); EditorGUI.indentLevel--; } EditorGUI.indentLevel--; GUILayout.Space(5f); if (IsRendererInAnotherGameObject(StP)) { EditorGUILayout.LabelField("Renderer in different GameObject specifics", Title); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(matchTargetGOPostionData); EditorGUILayout.PropertyField(matchTargetGOScale); EditorGUI.indentLevel--; GUILayout.Space(5f); } EditorGUILayout.LabelField("Advanced Options", Title); EditorGUI.indentLevel++; //advancedOptions = EditorGUILayout.Foldout(advancedOptions, "Show"); //if (advancedOptions) { //EditorGUI.indentLevel++; if (_emissionMode == SpriteMode.Dynamic) { EditorGUILayout.PropertyField(CacheSprites); } else { EditorGUILayout.PropertyField(CacheOnAwake); } EditorGUILayout.PropertyField(useSpritesSharingCache); EditorGUILayout.PropertyField(useBetweenFramesPrecision); if (showHelp && useBetweenFramesPrecision.boolValue) { #if UNITY_5_5_OR_NEWER if (StP.particlesSystem && StP.particlesSystem.main.simulationSpace != ParticleSystemSimulationSpace.World) { EditorGUILayout.HelpBox("Between frames precision is only to be use with ParticleSystem's simulation space set to world.", MessageType.Warning); } #endif } GUILayout.Space(5f); EditorGUILayout.PropertyField(verboseDebug); showHelp = EditorGUILayout.Toggle("Show Inspector Help", showHelp); EditorPrefs.SetBool("SpriteToParticles.ShowTools", showHelp); //showWarnings = EditorGUILayout.Toggle("Show Inspector Warnings", showWarnings); //EditorPrefs.SetBool("SpriteToParticles.ShowWarnings", showWarnings); //EditorGUI.indentLevel--; } if (GUILayout.Button("Emit All")) { StP.particlesSystem.Play(); StP.EmitAll(false); } if (GUILayout.Button("Reset Cache")) { StP.ResetAllCache(); } EditorGUI.indentLevel--; serializedObject.ApplyModifiedProperties(); }