示例#1
0
	public static void Initialize (PlaygroundC targetRef) {
		playgroundScriptReference = targetRef;
		PlaygroundC.reference = targetRef;
		if (playgroundScriptReference==null) return;
		playground = new SerializedObject(playgroundScriptReference);
		particleSystems = playground.FindProperty("particleSystems");
		manipulators = playground.FindProperty("manipulators");
		calculate = playground.FindProperty("calculate");
		pixelFilterMode = playground.FindProperty("pixelFilterMode");
		autoGroup = playground.FindProperty("autoGroup");
		buildZeroAlphaPixels = playground.FindProperty("buildZeroAlphaPixels");
		drawGizmos = playground.FindProperty("drawGizmos");
		drawSourcePositions = playground.FindProperty("drawSourcePositions");
		drawWireframe = playground.FindProperty("drawWireframe");
		drawSplinePreview = playground.FindProperty("drawSplinePreview");
		paintToolbox = playground.FindProperty("paintToolbox");
		showShuriken = playground.FindProperty("showShuriken");
		showSnapshots = playground.FindProperty("showSnapshotsInHierarchy");
		threads = playground.FindProperty("threadMethod");
		threadsTurbulence = playground.FindProperty("turbulenceThreadMethod");
		threadsSkinned = playground.FindProperty("skinnedMeshThreadMethod");
		maxThreads = playground.FindProperty("maxThreads");
		
		playgroundSettings = PlaygroundSettingsC.GetReference();
		playgroundLanguage = PlaygroundSettingsC.GetLanguage();
	}
	void OnEnable () {
		spline = target as PlaygroundSpline;
		
		playgroundSettings = PlaygroundSettingsC.GetReference();
		playgroundLanguage = PlaygroundSettingsC.GetLanguage();
		
		lastActiveTool = UnityEditor.Tools.current;
		
		UpdateUserList();
	}
	void OnEnable () {
		playgroundLanguage = PlaygroundSettingsC.GetLanguage();

		brushPreset = new SerializedObject(target);
		texture = brushPreset.FindProperty("texture");
		presetName = brushPreset.FindProperty("presetName");
		scale = brushPreset.FindProperty("scale");
		detail = brushPreset.FindProperty("detail");
		distance = brushPreset.FindProperty("distance");
		spacing = brushPreset.FindProperty("spacing");
		exceedMaxStopsPaint = brushPreset.FindProperty("exceedMaxStopsPaint");
	}
	public void OnEnable () 
	{
		follow = target as PlaygroundFollow;
		s_follow = new SerializedObject(follow);

		s_particles = s_follow.FindProperty("particles");
		s_referenceObject = s_follow.FindProperty("referenceObject");
		s_followerLifetime = s_follow.FindProperty("followerLifetime");
		s_cacheSize = s_follow.FindProperty("cacheSize");
		s_sendEvents = s_follow.FindProperty("sendEvents");

		playgroundSettings = PlaygroundSettingsC.GetReference();
		playgroundLanguage = PlaygroundSettingsC.GetLanguage();
	}
	void OnEnable () 
	{
		// Set references
		recorder = target as PlaygroundRecorder;

		// Load settings
		playgroundSettings = PlaygroundSettingsC.GetReference();
		
		// Load language
		playgroundLanguage = PlaygroundSettingsC.GetLanguage();

		// Load data
		if (recorder.recorderData != null)
			recorder.LoadAsync();
		else
			recorder.recordedFrames = new List<RecordedFrame>();
	}
	void OnGUI () {
		EditorGUILayout.BeginVertical();
		scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false);
		EditorGUILayout.Separator();
		EditorGUILayout.LabelField(PlaygroundParticleWindowC.playgroundLanguage.languageInstallWizard, EditorStyles.largeLabel, GUILayout.Height(20));
		EditorGUILayout.Separator();
		
		EditorGUILayout.HelpBox(PlaygroundParticleWindowC.playgroundLanguage.installText, MessageType.Info);
		EditorGUILayout.Separator();

		installType = (LanguageInstallType)EditorGUILayout.EnumPopup(PlaygroundParticleWindowC.playgroundLanguage.installType, installType);
		if (installType==LanguageInstallType.Asset) {
			languageFile = (PlaygroundLanguageC)EditorGUILayout.ObjectField(PlaygroundParticleWindowC.playgroundLanguage.languageFile, languageFile, typeof(PlaygroundLanguageC), false);
		} else {
			EditorGUILayout.BeginHorizontal();
			languageLocation = EditorGUILayout.TextField(PlaygroundParticleWindowC.playgroundLanguage.languageLocation, languageLocation);
			if (GUILayout.Button (PlaygroundParticleWindowC.playgroundLanguage.browse, EditorStyles.toolbarButton, GUILayout.ExpandWidth (false))) {
				string newLanguageLocation = EditorUtility.OpenFilePanel (PlaygroundParticleWindowC.playgroundLanguage.languageLocation, "", "xml");
				if (newLanguageLocation.Length!=0) {
					languageLocation = newLanguageLocation;
				}
			}
			EditorGUILayout.EndHorizontal();
		}
		
		EditorGUILayout.Separator();
		
		GUI.enabled = (installType==LanguageInstallType.Asset && languageFile!=null || installType==LanguageInstallType.Xml && languageLocation.Length>0 && languageLocation.ToLower().Contains (".xml"));
		if (GUILayout.Button (PlaygroundParticleWindowC.playgroundLanguage.install, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) {
			if (installType==LanguageInstallType.Asset) {
				if (!PlaygroundParticleWindowC.playgroundSettings.languages.Contains (languageFile)) {
					AssetDatabase.MoveAsset( AssetDatabase.GetAssetPath ((Object)languageFile), "Assets/"+PlaygroundParticleWindowC.playgroundSettings.playgroundPath+PlaygroundParticleWindowC.playgroundSettings.languagePath+languageFile.name);
					PlaygroundParticleWindowC.playgroundSettings.languages.Add (languageFile);
					EditorUtility.SetDirty(PlaygroundParticleWindowC.playgroundSettings);
				}
			} else {
				PlaygroundSettingsC.ImportLanguage(languageLocation);
			}
			window.Close();
		}
		GUI.enabled = true;

		GUILayout.EndScrollView();
		EditorGUILayout.EndVertical();
	}
	public void OnEnable () 
	{
		trails = target as PlaygroundTrails;
		s_trails = new SerializedObject(trails);

		s_time = s_trails.FindProperty("time");

		s_material = s_trails.FindProperty("material");
		s_lifetimeColor = s_trails.FindProperty("lifetimeColor");
		s_colorMode = s_trails.FindProperty("colorMode");
		s_uvMode = s_trails.FindProperty("uvMode");
		s_pointArrayAlpha = s_trails.FindProperty("pointArrayAlpha");
		s_renderMode = s_trails.FindProperty("renderMode");
		s_billboardTransform = s_trails.FindProperty("billboardTransform");
		s_customRenderScale = s_trails.FindProperty("customRenderScale");

		s_timeWidth = s_trails.FindProperty("timeWidth");
		s_widthScale = s_trails.FindProperty("widthScale");

		s_minVertexDistance = s_trails.FindProperty("minVertexDistance");
		s_maxVertexDistance = s_trails.FindProperty("maxVertexDistance");
		s_maxPathDeviation = s_trails.FindProperty("maxPathDeviation");
		s_createPointsOnCollision = s_trails.FindProperty("createPointsOnCollision");
		s_maxPoints = s_trails.FindProperty("maxPoints");
		s_createFirstPointOnParticleBirth = s_trails.FindProperty("createFirstPointOnParticleBirth");
		s_createLastPointOnParticleDeath = s_trails.FindProperty("createLastPointOnParticleDeath");

		s_playgroundSystem = s_trails.FindProperty("playgroundSystem");
		s_multithreading = s_trails.FindProperty("multithreading");

		s_receiveShadows = s_trails.FindProperty("receiveShadows");
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
		s_castShadows = s_trails.FindProperty("castShadows");
#else
		s_castShadows = s_trails.FindProperty("shadowCastingMode");
#endif
		playgroundSettings = PlaygroundSettingsC.GetReference();
		playgroundLanguage = PlaygroundSettingsC.GetLanguage();

		// Issue a quick refresh
		if (!EditorApplication.isPlaying && Selection.activeTransform!=null)
		{
			trails.ResetTrails();
		}
	}
    void OnGUI()
    {
        if ( boxStyle == null )
            boxStyle = GUI.skin.FindStyle("box");
        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(boxStyle);
        EditorGUILayout.Separator();
        EditorGUILayout.LabelField(playgroundLanguage.playgroundName + " " + PlaygroundC.version + PlaygroundC.specialVersion, EditorStyles.largeLabel, GUILayout.Height(20));
        EditorGUILayout.Separator();

        // New version message
        if ( playgroundSettings.checkForUpdates && !didSendVersionCheck )
            CheckUpdate();
        if ( playgroundSettings.checkForUpdates && updateAvailable ) {
            EditorGUILayout.BeginVertical(boxStyle);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(playgroundLanguage.updateAvailable);
            GUILayout.FlexibleSpace();
            if ( GUILayout.Button("x", EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(18) }) ) {
                updateAvailable = false;
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.LabelField(onlineVersion + " " + playgroundLanguage.updateAvailableText, EditorStyles.wordWrappedMiniLabel);
            EditorGUILayout.BeginHorizontal();
            if ( GUILayout.Button(playgroundLanguage.unityAssetStore, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)) ) {
                Application.OpenURL("com.unity3d.kharma:content/13325");
            }

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
            EditorGUILayout.Separator();
        }
        EditorGUILayout.BeginVertical(boxStyle);

        // Create New-buttons
        EditorGUILayout.BeginHorizontal();
        if ( GUILayout.Button(playgroundLanguage.newParticlePlaygroundSystem, EditorStyles.toolbarButton) ) {
            if ( PlaygroundC.reference == null )
                CreateManager();
            PlaygroundParticlesC newParticlePlayground = PlaygroundC.Particle();
            newParticlePlayground.EditorYieldSelect();
        }
        GUI.enabled = PlaygroundC.reference == null;
        if ( GUILayout.Button(playgroundLanguage.playgroundManager, EditorStyles.toolbarButton) ) {
            PlaygroundC.ResourceInstantiate("Playground Manager");
        }
        GUI.enabled = true;
        if ( GUILayout.Button(playgroundLanguage.presetWizard, EditorStyles.toolbarButton) ) {
            PlaygroundCreatePresetWindowC.ShowWindow();
        }

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndVertical();

        if ( assetsFound ) {

            // Presets
            EditorGUILayout.BeginVertical(boxStyle);
            playgroundSettings.presetsFoldout = GUILayout.Toggle(playgroundSettings.presetsFoldout, playgroundLanguage.presets, EditorStyles.foldout);
            if ( playgroundSettings.presetsFoldout ) {
                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[] { playgroundLanguage.all, playgroundLanguage.user, playgroundLanguage.examples }, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false));
                GUILayout.Label("", EditorStyles.toolbarButton);
                presetListStyle = GUILayout.Toolbar(presetListStyle, new string[] { playgroundLanguage.icons, playgroundLanguage.list }, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false));
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginVertical(boxStyle);

                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(boxStyle, GUILayout.MinHeight(24));
                            EditorGUILayout.BeginHorizontal();
                            GUILayout.Label(i.ToString(), EditorStyles.miniLabel, new GUILayoutOption[] { GUILayout.Width(18) });
                            EditorGUILayout.LabelField(presetObjects[i].example ? "(" + playgroundLanguage.example + ")" : "(" + playgroundLanguage.user + ")", EditorStyles.miniLabel, new GUILayoutOption[] { GUILayout.MaxWidth(70) });
                            if ( GUILayout.Button(presetObjects[i].presetObject.name, EditorStyles.label) ) {
                                CreatePresetObject(i);
                            }
                            EditorGUILayout.Separator();
                            if ( GUILayout.Button(presetObjects[i].example ? playgroundLanguage.convertTo + " " + playgroundLanguage.user : playgroundLanguage.convertTo + " " + playgroundLanguage.example, EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.ExpandWidth(false), GUILayout.Height(16) }) ) {
                                if ( presetObjects[i].example ) {
                                    AssetDatabase.MoveAsset(AssetDatabase.GetAssetPath(presetObjects[i].presetObject), "Assets/" + playgroundSettings.playgroundPath + playgroundSettings.presetPath + presetObjects[i].presetObject.name + ".prefab");
                                } else {
                                    AssetDatabase.MoveAsset(AssetDatabase.GetAssetPath(presetObjects[i].presetObject), "Assets/" + playgroundSettings.playgroundPath + playgroundSettings.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();
                        } else
                        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(boxStyle, GUILayout.MaxWidth(Mathf.CeilToInt(Screen.width / rows) - (44 / rows)));
                            } else
                                EditorGUILayout.BeginVertical(boxStyle);
                            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 ? playgroundLanguage.example : playgroundLanguage.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(playgroundLanguage.searchNoPresetFound + " \"" + searchString + "\".", MessageType.Info);
                        } else {
                            if ( presetExampleUser == 0 )
                                EditorGUILayout.HelpBox(playgroundLanguage.noPresetsFound, MessageType.Info);
                            else if ( presetExampleUser == 1 )
                                EditorGUILayout.HelpBox(playgroundLanguage.noUserPresetsFound, MessageType.Info);
                            else if ( presetExampleUser == 2 )
                                EditorGUILayout.HelpBox(playgroundLanguage.noExamplePresetsFound + " \"" + "Assets/" + playgroundSettings.playgroundPath + playgroundSettings.examplePresetPath + "\"", MessageType.Info);
                        }
                    }
                    if ( presetListStyle == 0 )
                        EditorGUILayout.EndHorizontal();
                } else {
                    EditorGUILayout.HelpBox(playgroundLanguage.noPresetsFoundInProject + " \"" + "Assets/" + playgroundSettings.playgroundPath + playgroundSettings.examplePresetPath + "\"", MessageType.Info);
                }

                if ( GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)) ) {
                    PlaygroundCreatePresetWindowC.ShowWindow();
                }

                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndVertical();
        } else {
            EditorGUILayout.HelpBox(playgroundLanguage.noAssetsFoundMessage, MessageType.Warning);
        }

        // Extension check
        if ( playgroundSettings.enableExtensions && !didSendExtensionsCheck )
            CheckExtensions();

        // Extension icon download
        if ( playgroundSettings.enableExtensions && extensionObjects != null && iconDownloadIndex < extensionObjects.Count ) {
            if ( extensionObjects[iconDownloadIndex].IsExpectingDownload() )
                extensionObjects[iconDownloadIndex].IconDownloadRoutine();
            else {
                iconDownloadIndex++;
            }
        }

        // Extend Your Playground GUI
        if ( playgroundSettings.enableExtensions ) {
            EditorGUILayout.BeginVertical(boxStyle);
            playgroundSettings.extensionsFoldout = GUILayout.Toggle(playgroundSettings.extensionsFoldout, playgroundLanguage.extendYourPlayground, EditorStyles.foldout);
            if ( playgroundSettings.extensionsFoldout ) {
                EditorGUILayout.BeginHorizontal("Toolbar");

                // Search
                string prevSearchString = searchStringExtensions;
                searchStringExtensions = GUILayout.TextField(searchStringExtensions, toolbarSearchSkin, new GUILayoutOption[] { GUILayout.ExpandWidth(false), GUILayout.Width(Mathf.FloorToInt(Screen.width) - 120), GUILayout.MinWidth(100) });
                if ( GUILayout.Button("", toolbarSearchButtonSkin) ) {
                    searchStringExtensions = "";
                    GUI.FocusControl(null);
                }

                if ( prevSearchString != searchStringExtensions ) {
                    for ( int p = 0; p < extensionObjects.Count; p++ )
                        extensionObjects[p].unfiltered = (searchStringExtensions == "" ? true : extensionObjects[p].searchMeta.ToLower().Contains(searchStringExtensions.ToLower()));
                }

                EditorGUILayout.Separator();

                playgroundSettings.extensionIconSize = GUILayout.HorizontalSlider(playgroundSettings.extensionIconSize, .5f, 1f, GUILayout.MaxWidth(60));
                EditorGUILayout.EndHorizontal();

                if ( didSendExtensionsCheck ) {
                    if ( extensionsAvailable && extensionObjects != null ) {
                        EditorGUILayout.BeginHorizontal();
                        int rows = 1;
                        int iconwidths = 0;
                        int iconSize = Mathf.RoundToInt(75 * playgroundSettings.extensionIconSize);
                        int skippedExtensions = 0;
                        bool smallSize = playgroundSettings.extensionIconSize <= .65;
                        bool listSize = playgroundSettings.extensionIconSize <= .5;
                        bool didLoad = false;

                        // List of extensions
                        if ( listSize ) {
                            EditorGUILayout.BeginVertical();
                            for ( int i = 0; i < extensionObjects.Count; i++ ) {

                                // Filter out by search
                                if ( !extensionObjects[i].unfiltered ) {
                                    skippedExtensions++;
                                    continue;
                                }

                                if ( !didLoad )
                                    didLoad = extensionObjects[i].CheckAvailability();

                                EditorGUILayout.BeginHorizontal(boxStyle);
                                GUILayout.Label(extensionObjects[i].icon, new GUILayoutOption[] { GUILayout.Width(24), GUILayout.Height(24) });
                                if ( GUILayout.Button(extensionObjects[i].title, EditorStyles.boldLabel, GUILayout.ExpandWidth(true)) )
                                    OpenUAS(extensionObjects[i].id);

                                if ( GUILayout.Button(extensionObjects[i].publisher, EditorStyles.miniLabel, GUILayout.ExpandWidth(false)) ) {
                                    searchStringExtensions = extensionObjects[i].publisher;
                                    for ( int p = 0; p < extensionObjects.Count; p++ )
                                        extensionObjects[p].unfiltered = (searchStringExtensions == "" ? true : extensionObjects[p].searchMeta.ToLower().Contains(searchStringExtensions.ToLower()));
                                }

                                if ( GUILayout.Button(extensionObjects[i].category, boxStyle, GUILayout.ExpandWidth(false)) ) {
                                    searchStringExtensions = extensionObjects[i].category;
                                    for ( int p = 0; p < extensionObjects.Count; p++ )
                                        extensionObjects[p].unfiltered = (searchStringExtensions == "" ? true : extensionObjects[p].searchMeta.ToLower().Contains(searchStringExtensions.ToLower()));
                                }

                                EditorGUILayout.EndHorizontal();
                            }
                            EditorGUILayout.EndVertical();
                        } else {
                            for ( int i = 0; i < extensionObjects.Count; i++ ) {

                                // Filter out by search
                                if ( !extensionObjects[i].unfiltered ) {
                                    skippedExtensions++;
                                    continue;
                                }

                                if ( !didLoad )
                                    didLoad = extensionObjects[i].CheckAvailability();

                                // 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(boxStyle, GUILayout.MaxWidth(Mathf.CeilToInt(Screen.width / rows) - (45 / rows)));
                                } else
                                    EditorGUILayout.BeginVertical(boxStyle);
                                EditorGUILayout.BeginHorizontal(GUILayout.MinHeight(iconSize + 16));
                                if ( GUILayout.Button(extensionObjects[i].icon, EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.Width(iconSize + 12), GUILayout.Height(iconSize + 12) }) ) {
                                    OpenUAS(extensionObjects[i].id);
                                }
                                EditorGUILayout.BeginVertical();

                                EditorGUILayout.BeginVertical(boxStyle, GUILayout.MinHeight(iconSize + 10));
                                if ( GUILayout.Button(extensionObjects[i].title, EditorStyles.boldLabel, GUILayout.ExpandWidth(true)) )
                                    OpenUAS(extensionObjects[i].id);

                                if ( smallSize ) {
                                    EditorGUILayout.BeginHorizontal();
                                }

                                if ( GUILayout.Button(extensionObjects[i].category, EditorStyles.label, GUILayout.ExpandWidth(false)) ) {
                                    searchStringExtensions = extensionObjects[i].category;
                                    for ( int p = 0; p < extensionObjects.Count; p++ )
                                        extensionObjects[p].unfiltered = (searchStringExtensions == "" ? true : extensionObjects[p].searchMeta.ToLower().Contains(searchStringExtensions.ToLower()));
                                }

                                if ( GUILayout.Button(extensionObjects[i].publisher, EditorStyles.miniLabel, GUILayout.ExpandWidth(false)) ) {
                                    searchStringExtensions = extensionObjects[i].publisher;
                                    for ( int p = 0; p < extensionObjects.Count; p++ )
                                        extensionObjects[p].unfiltered = (searchStringExtensions == "" ? true : extensionObjects[p].searchMeta.ToLower().Contains(searchStringExtensions.ToLower()));
                                }

                                if ( smallSize ) {
                                    EditorGUILayout.EndHorizontal();
                                }

                                EditorGUILayout.EndHorizontal();
                                EditorGUILayout.EndVertical();
                                EditorGUILayout.EndVertical();
                                EditorGUILayout.EndVertical();
                            }
                        }

                        EditorGUILayout.EndHorizontal();

                        // No extensions found by search
                        if ( skippedExtensions == extensionObjects.Count ) {
                            if ( searchStringExtensions != "" ) {
                                EditorGUILayout.HelpBox(playgroundLanguage.searchNoExtensionsFound + " \"" + searchStringExtensions + "\".", MessageType.Info);
                            }
                        } else if ( skippedExtensions > 0 && searchStringExtensions != "" )
                            EditorGUILayout.HelpBox(playgroundLanguage.listHasBeenFilteredWith + ": \"" + searchStringExtensions + "\".", MessageType.Info);

                    } else
                        EditorGUILayout.HelpBox(playgroundLanguage.extensionsDownloadError, MessageType.Warning);
                } else
                    EditorGUILayout.HelpBox(playgroundLanguage.extensionsDownloading, MessageType.Info);
            }
            EditorGUILayout.EndVertical();
        }

        PlaygroundInspectorC.RenderPlaygroundSettings();

        // Playground Settings
        EditorGUILayout.BeginVertical(boxStyle);
        playgroundSettings.settingsFoldout = GUILayout.Toggle(playgroundSettings.settingsFoldout, playgroundLanguage.settings, EditorStyles.foldout);
        if ( playgroundSettings.settingsFoldout ) {
            EditorGUILayout.BeginVertical(boxStyle);
            if ( playgroundSettings == null || playgroundSettings.IsInstance() ) {
                EditorGUILayout.HelpBox(playgroundLanguage.noSettingsFile + " \"" + PlaygroundSettingsC.settingsPath + "\".", MessageType.Warning);
                if ( GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)) ) {
                    PlaygroundSettingsC.New();
                    Initialize();
                    return;
                }
            } else {
                playgroundSettings.checkForUpdates = EditorGUILayout.Toggle(playgroundLanguage.checkForUpdates, playgroundSettings.checkForUpdates);
                playgroundSettings.enableExtensions = EditorGUILayout.Toggle(playgroundLanguage.extendYourPlayground, playgroundSettings.enableExtensions);
                playgroundSettings.presetsHasPrefabConnection = EditorGUILayout.Toggle(playgroundLanguage.prefabConnection, playgroundSettings.presetsHasPrefabConnection);

                EditorGUI.BeginChangeCheck();
                playgroundSettings.hierarchyIcon = EditorGUILayout.Toggle(playgroundLanguage.hierarchyIcon, playgroundSettings.hierarchyIcon);
                if ( EditorGUI.EndChangeCheck() ) {
                    PlaygroundHierarchyIcon.Set();
                }
                EditorGUILayout.Separator();

                EditorGUILayout.BeginVertical(boxStyle);
                playgroundSettings.settingsLanguageFoldout = GUILayout.Toggle(playgroundSettings.settingsLanguageFoldout, playgroundLanguage.language, EditorStyles.foldout);
                if ( playgroundSettings.settingsLanguageFoldout ) {
                    if ( playgroundSettings.languages.Count > 0 ) {

                        bool setThisLoadFrom = false;
                        int currentLanguageCount = playgroundSettings.languages.Count;
                        for ( int i = 0; i < playgroundSettings.languages.Count; i++ ) {
                            if ( currentLanguageCount != playgroundSettings.languages.Count ) {
                                Initialize();
                                return;
                            }
                            setThisLoadFrom = false;
                            EditorGUILayout.BeginHorizontal(boxStyle);

                            if ( playgroundSettings.languages[i] == null ) {
                                playgroundSettings.languages.RemoveAt(i);
                                Initialize();
                                return;
                            }

                            if ( playgroundSettings.selectedLanguage == i ) {
                                EditorGUILayout.Toggle(true, EditorStyles.radioButton, GUILayout.Width(14));
                            } else
                                setThisLoadFrom = EditorGUILayout.Toggle(setThisLoadFrom, EditorStyles.radioButton, GUILayout.Width(14));
                            if ( setThisLoadFrom || GUILayout.Button(playgroundSettings.languages[i].languageName + " (" + playgroundSettings.languages[i].languageNameSeenByEnglish + ")", EditorStyles.label) ) {
                                playgroundSettings.selectedLanguage = i;
                                playgroundLanguage = PlaygroundSettingsC.GetLanguage();
                                PlaygroundInspectorC.playgroundLanguage = playgroundLanguage;
                                PlaygroundParticleSystemInspectorC.playgroundLanguage = playgroundLanguage;
                            }

                            if ( GUILayout.Button(playgroundLanguage.edit, EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.ExpandWidth(false), GUILayout.Height(16) }) )
                                Selection.activeObject = (Object) playgroundSettings.languages[i];
                            if ( GUILayout.Button(playgroundLanguage.export, EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.ExpandWidth(false), GUILayout.Height(16) }) )
                                PlaygroundSettingsC.ExportLanguage(i);
                            if ( GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) }) ) {
                                if ( EditorUtility.DisplayDialog(
                                    playgroundLanguage.remove + " " + playgroundSettings.languages[i].languageName + "?",
                                    playgroundLanguage.removeLanguage + " " + playgroundSettings.languages[i].languageName + "?",
                                    playgroundLanguage.yes, playgroundLanguage.no) ) {
                                    AssetDatabase.MoveAssetToTrash(AssetDatabase.GetAssetPath(playgroundSettings.languages[i]));
                                    playgroundSettings.languages.RemoveAt(i);
                                    if ( playgroundSettings.selectedLanguage == i )
                                        playgroundSettings.selectedLanguage = 0;
                                    Initialize();
                                    return;
                                }
                            }

                            EditorGUILayout.EndHorizontal();
                        }
                    } else {
                        EditorGUILayout.HelpBox(playgroundLanguage.noLanguageFound, MessageType.Warning);
                    }
                    EditorGUILayout.BeginHorizontal();
                    if ( GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)) ) {
                        playgroundSettings.languages.Add(PlaygroundLanguageC.New());
                        EditorUtility.SetDirty(playgroundSettings);
                        Initialize();
                        return;
                    }
                    if ( GUILayout.Button(playgroundLanguage.install, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)) ) {
                        PlaygroundInstallLanguageWindowC.ShowWindow();
                    }
                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.EndVertical();

                // Limits
                EditorGUILayout.BeginVertical(boxStyle);
                playgroundSettings.limitsFoldout = GUILayout.Toggle(playgroundSettings.limitsFoldout, playgroundLanguage.editorLimits, EditorStyles.foldout);
                if ( playgroundSettings.limitsFoldout ) {
                    EditorGUILayout.Separator();
                    playgroundSettings.maximumAllowedTransitionTime = EditorGUILayout.FloatField(playgroundLanguage.transitionTime, playgroundSettings.maximumAllowedTransitionTime);
                    EditorGUILayout.Separator();
                    playgroundSettings.maximumAllowedParticles = EditorGUILayout.IntField(playgroundLanguage.particleCount, playgroundSettings.maximumAllowedParticles);
                    playgroundSettings.maximumAllowedLifetime = EditorGUILayout.FloatField(playgroundLanguage.particleLifetime, playgroundSettings.maximumAllowedLifetime);
                    playgroundSettings.maximumAllowedRotation = EditorGUILayout.FloatField(playgroundLanguage.particleRotation, playgroundSettings.maximumAllowedRotation);
                    playgroundSettings.maximumAllowedSize = EditorGUILayout.FloatField(playgroundLanguage.particleSize, playgroundSettings.maximumAllowedSize);
                    playgroundSettings.maximumAllowedScale = EditorGUILayout.FloatField(playgroundLanguage.particleScale, playgroundSettings.maximumAllowedScale);
                    playgroundSettings.maximumAllowedSourceScatter = EditorGUILayout.FloatField(playgroundLanguage.sourceScatter, playgroundSettings.maximumAllowedSourceScatter);
                    EditorGUILayout.Separator();
                    playgroundSettings.maximumAllowedDeltaMovementStrength = EditorGUILayout.FloatField(playgroundLanguage.deltaMovementStrength, playgroundSettings.maximumAllowedDeltaMovementStrength);
                    playgroundSettings.maximumAllowedDamping = EditorGUILayout.FloatField(playgroundLanguage.damping, playgroundSettings.maximumAllowedDamping);
                    playgroundSettings.maximumAllowedInitialVelocity = EditorGUILayout.FloatField(playgroundLanguage.initialVelocity, playgroundSettings.maximumAllowedInitialVelocity);
                    playgroundSettings.maximumAllowedVelocity = EditorGUILayout.FloatField(playgroundLanguage.velocity, playgroundSettings.maximumAllowedVelocity);
                    playgroundSettings.maximumAllowedStretchSpeed = EditorGUILayout.FloatField(playgroundLanguage.stretchSpeed, playgroundSettings.maximumAllowedStretchSpeed);
                    EditorGUILayout.Separator();
                    playgroundSettings.maximumAllowedCollisionRadius = EditorGUILayout.FloatField(playgroundLanguage.collisionRadius, playgroundSettings.maximumAllowedCollisionRadius);
                    playgroundSettings.maximumAllowedMass = EditorGUILayout.FloatField(playgroundLanguage.mass, playgroundSettings.maximumAllowedMass);
                    playgroundSettings.maximumAllowedBounciness = EditorGUILayout.FloatField(playgroundLanguage.bounciness, playgroundSettings.maximumAllowedBounciness);
                    playgroundSettings.maximumAllowedDepth = EditorGUILayout.FloatField(playgroundLanguage.depth2D, playgroundSettings.maximumAllowedDepth);
                    EditorGUILayout.Separator();
                    playgroundSettings.minimumAllowedUpdateRate = EditorGUILayout.IntField(playgroundLanguage.updateRate, playgroundSettings.minimumAllowedUpdateRate);
                    playgroundSettings.maximumAllowedTimescale = EditorGUILayout.FloatField(playgroundLanguage.timeScale, playgroundSettings.maximumAllowedTimescale);
                    playgroundSettings.maximumAllowedPrewarmCycles = EditorGUILayout.IntField(playgroundLanguage.prewarmCyclesResolution, playgroundSettings.maximumAllowedPrewarmCycles);
                    playgroundSettings.maximumRenderSliders = EditorGUILayout.FloatField(playgroundLanguage.renderSliders, playgroundSettings.maximumRenderSliders);
                    EditorGUILayout.Separator();
                    playgroundSettings.maximumAllowedPaintPositions = EditorGUILayout.IntField(playgroundLanguage.paintPositions, playgroundSettings.maximumAllowedPaintPositions);
                    playgroundSettings.minimumAllowedBrushScale = EditorGUILayout.FloatField(playgroundLanguage.brushSizeMin, playgroundSettings.minimumAllowedBrushScale);
                    playgroundSettings.maximumAllowedBrushScale = EditorGUILayout.FloatField(playgroundLanguage.brushSizeMax, playgroundSettings.maximumAllowedBrushScale);
                    playgroundSettings.minimumEraserRadius = EditorGUILayout.FloatField(playgroundLanguage.eraserSizeMin, playgroundSettings.minimumEraserRadius);
                    playgroundSettings.maximumEraserRadius = EditorGUILayout.FloatField(playgroundLanguage.eraserSizeMax, playgroundSettings.maximumEraserRadius);
                    playgroundSettings.maximumAllowedPaintSpacing = EditorGUILayout.FloatField(playgroundLanguage.paintSpacing, playgroundSettings.maximumAllowedPaintSpacing);
                    EditorGUILayout.Separator();
                    playgroundSettings.maximumAllowedManipulatorSize = EditorGUILayout.FloatField(playgroundLanguage.manipulatorSize, playgroundSettings.maximumAllowedManipulatorSize);
                    playgroundSettings.maximumAllowedManipulatorStrength = EditorGUILayout.FloatField(playgroundLanguage.manipulatorStrength, playgroundSettings.maximumAllowedManipulatorStrength);
                    playgroundSettings.maximumAllowedManipulatorStrengthEffectors = EditorGUILayout.FloatField(playgroundLanguage.manipulatorStrengthEffectors, playgroundSettings.maximumAllowedManipulatorStrengthEffectors);
                    playgroundSettings.maximumAllowedManipulatorZeroVelocity = EditorGUILayout.FloatField(playgroundLanguage.manipulatorZeroVelocityStrength, playgroundSettings.maximumAllowedManipulatorZeroVelocity);
                    EditorGUILayout.Separator();
                }
                EditorGUILayout.EndVertical();

                // Paths
                EditorGUILayout.BeginVertical(boxStyle);
                playgroundSettings.settingsPathFoldout = GUILayout.Toggle(playgroundSettings.settingsPathFoldout, playgroundLanguage.paths, EditorStyles.foldout);
                if ( playgroundSettings.settingsPathFoldout ) {
                    string currentPlaygroundPath = playgroundSettings.playgroundPath;
                    string currentExamplePresetPath = playgroundSettings.examplePresetPath;
                    string currentPresetPath = playgroundSettings.presetPath;

                    playgroundSettings.playgroundPath = EditorGUILayout.TextField(playgroundLanguage.playgroundPath, playgroundSettings.playgroundPath);
                    playgroundSettings.languagePath = EditorGUILayout.TextField(playgroundLanguage.languagesPath, playgroundSettings.languagePath);
                    playgroundSettings.presetPath = EditorGUILayout.TextField(playgroundLanguage.userPresetPath, playgroundSettings.presetPath);
                    playgroundSettings.examplePresetPath = EditorGUILayout.TextField(playgroundLanguage.examplePresetPath, playgroundSettings.examplePresetPath);
                    playgroundSettings.iconPath = EditorGUILayout.TextField(playgroundLanguage.presetIconPath, playgroundSettings.iconPath);
                    playgroundSettings.brushPath = EditorGUILayout.TextField(playgroundLanguage.brushPath, playgroundSettings.brushPath);
                    playgroundSettings.scriptPath = EditorGUILayout.TextField(playgroundLanguage.scriptPath, playgroundSettings.scriptPath);
                    playgroundSettings.versionUrl = EditorGUILayout.TextField(playgroundLanguage.updateUrl, playgroundSettings.versionUrl);
                    playgroundSettings.extensionsUrl = EditorGUILayout.TextField(playgroundLanguage.extensionsUrl, playgroundSettings.extensionsUrl);

                    if ( currentPlaygroundPath != playgroundSettings.playgroundPath || currentExamplePresetPath != playgroundSettings.examplePresetPath || currentPresetPath != playgroundSettings.presetPath )
                        Initialize();
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndVertical();
        }
        EditorGUILayout.EndVertical();

        GUILayout.FlexibleSpace();

        EditorGUILayout.BeginVertical(boxStyle);
        EditorGUILayout.BeginHorizontal();
        if ( GUILayout.Button(playgroundLanguage.officialSite, EditorStyles.toolbarButton) ) {
            Application.OpenURL("http://playground.polyfied.com/");
        }
        if ( GUILayout.Button(playgroundLanguage.assetStore, EditorStyles.toolbarButton) ) {
            Application.OpenURL("com.unity3d.kharma:content/13325");
        }
        if ( GUILayout.Button(playgroundLanguage.manual, EditorStyles.toolbarButton) ) {
            Application.OpenURL("http://www.polyfied.com/products/Particle-Playground-2-Next-Manual.pdf");
        }
        if ( GUILayout.Button(playgroundLanguage.supportForum, EditorStyles.toolbarButton) ) {
            Application.OpenURL("http://forum.unity3d.com/threads/215154-Particle-Playground");
        }
        if ( GUILayout.Button(playgroundLanguage.mailSupport, EditorStyles.toolbarButton) ) {
            Application.OpenURL("mailto:[email protected]");
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        GUILayout.EndScrollView();
        EditorGUILayout.EndVertical();

        if ( GUI.changed )
            EditorUtility.SetDirty(playgroundSettings);
    }
    public void Initialize()
    {
        presetButtonStyle = new GUIStyle();
        presetButtonStyle.stretchWidth = true;
        presetButtonStyle.stretchHeight = true;

        // Load settings
        playgroundSettings = PlaygroundSettingsC.SetReference();
        PlaygroundInspectorC.playgroundSettings = playgroundSettings;
        PlaygroundParticleSystemInspectorC.playgroundSettings = playgroundSettings;

        // Load language
        playgroundLanguage = PlaygroundSettingsC.GetLanguage();
        PlaygroundInspectorC.playgroundLanguage = playgroundLanguage;
        PlaygroundParticleSystemInspectorC.playgroundLanguage = playgroundLanguage;

        List<Object> particlePrefabs = new List<Object>();

        // Get all user presets (bound to Resources)
        int userPrefabCount = 0;
        Object[] resourcePrefabs = (Object[]) Resources.LoadAll("Presets", typeof(GameObject));
        foreach ( Object thisResourcePrefab in resourcePrefabs ) {
            particlePrefabs.Add(thisResourcePrefab);
            userPrefabCount++;
        }

        // Get all example presets
        string assetsDataPath = Application.dataPath;
        string editorPresetPath = assetsDataPath + "/" + playgroundSettings.playgroundPath + playgroundSettings.examplePresetPath;
        string[] editorPresetPaths = new string[0];

        if ( Directory.Exists(assetsDataPath + "/" + playgroundSettings.playgroundPath) ) {
            if ( Directory.Exists(editorPresetPath) )
                editorPresetPaths = Directory.GetFiles(editorPresetPath);
            assetsFound = true;
        } else {
            assetsFound = false;
            playgroundSettings.settingsFoldout = true;
            playgroundSettings.settingsPathFoldout = true;
            return;
        }

        if ( editorPresetPaths != null ) {
            foreach ( string thisPresetPath in editorPresetPaths ) {
                string convertedPresetPath = thisPresetPath.Substring(assetsDataPath.Length - 6);
                Object presetPathObject = (Object) AssetDatabase.LoadAssetAtPath(convertedPresetPath, typeof(Object));
                if ( presetPathObject != null && (presetPathObject.GetType().Name) == "GameObject" ) {
                    particlePrefabs.Add(presetPathObject);
                }
            }
        }

        Texture2D particleImageDefault = AssetDatabase.LoadAssetAtPath("Assets/" + playgroundSettings.playgroundPath + playgroundSettings.iconPath + "Default.png", typeof(Texture2D)) as Texture2D;
        Texture2D particleImage;

        presetObjects = new List<PresetObjectC>();
        int i = 0;
        for ( ; i < particlePrefabs.Count; i++ ) {
            presetObjects.Add(new PresetObjectC());
            presetObjects[i].presetObject = particlePrefabs[i];
            presetObjects[i].example = (i >= userPrefabCount);
            particleImage = AssetDatabase.LoadAssetAtPath("Assets/" + playgroundSettings.playgroundPath + playgroundSettings.iconPath + presetObjects[i].presetObject.name + ".png", typeof(Texture2D)) as Texture2D;

            // Try the asset location if we didn't find it in regular editor folder
            if ( particleImage == null ) {
                particleImage = AssetDatabase.LoadAssetAtPath(Path.GetDirectoryName(AssetDatabase.GetAssetPath(presetObjects[i].presetObject as UnityEngine.Object)) + "/" + presetObjects[i].presetObject.name + ".png", typeof(Texture2D)) as Texture2D;
            }

            // Finally use the specified icon (or the default)
            if ( particleImage != null )
                presetObjects[i].presetImage = particleImage;
            else if ( particleImageDefault != null )
                presetObjects[i].presetImage = particleImageDefault;
        }
        presetNames = new string[presetObjects.Count];
        for ( i = 0; i < presetNames.Length; i++ ) {
            presetNames[i] = presetObjects[i].presetObject.name;

            // Filter on previous search
            presetObjects[i].unfiltered = (searchString == "" ? true : presetNames[i].ToLower().Contains(searchString.ToLower()));
        }

        if ( playgroundSettings.checkForUpdates && !didSendVersionCheck )
            versionRequest = new WWW(playgroundSettings.versionUrl);

        if ( playgroundSettings.enableExtensions && !didSendExtensionsCheck ) {
            extensionsRequest = new WWW(playgroundSettings.extensionsUrl);
        }
    }
 public static void ShowWindow()
 {
     playgroundLanguage = PlaygroundSettingsC.GetLanguage();
     window = EditorWindow.GetWindow<PlaygroundCreatePresetWindowC>(true, playgroundLanguage.presetWizard);
     window.Show();
 }
示例#11
0
	public static void RenderPlaygroundSettings () {
		if (boxStyle==null)
			boxStyle = GUI.skin.FindStyle("box");
		EditorGUILayout.BeginVertical(boxStyle);
		
		if (playgroundSettings==null) {
			playgroundSettings = PlaygroundSettingsC.GetReference();
			playgroundLanguage = PlaygroundSettingsC.GetLanguage();
		}
		playgroundSettings.playgroundManagerFoldout = GUILayout.Toggle(playgroundSettings.playgroundManagerFoldout, playgroundLanguage.playgroundManager, EditorStyles.foldout);
		if (playgroundSettings.playgroundManagerFoldout) {
			
			EditorGUILayout.BeginVertical(boxStyle);
			if (playgroundScriptReference==null) {
				playgroundScriptReference = GameObject.FindObjectOfType<PlaygroundC>();
				if (playgroundScriptReference)
					Initialize(playgroundScriptReference);
			}
			
			if (playgroundSettings.playgroundFoldout && playgroundScriptReference!=null) {
				playground.Update();
				
				// Particle System List
				if (GUILayout.Button(playgroundLanguage.particleSystems+" ("+playgroundScriptReference.particleSystems.Count+")", EditorStyles.toolbarDropDown)) playgroundSettings.particleSystemsFoldout=!playgroundSettings.particleSystemsFoldout;
				if (playgroundSettings.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+" ("+playgroundScriptReference.particleSystems[ps].particleCount+")", EditorStyles.label)) {
								Selection.activeGameObject = playgroundScriptReference.particleSystems[ps].particleSystemGameObject;
							}
							EditorGUILayout.Separator();
							if (playgroundScriptReference.particleSystems[ps].threadMethod!=ThreadMethodLocal.Inherit) {
								GUILayout.Label(playgroundLanguage.thread+": "+playgroundScriptReference.particleSystems[ps].threadMethod.ToString(), EditorStyles.miniLabel);
							}
							GUI.enabled = (playgroundScriptReference.particleSystems.Count>1);
							if(GUILayout.Button(playgroundLanguage.upSymbol, EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
								particleSystems.MoveArrayElement(ps, ps==0?playgroundScriptReference.particleSystems.Count-1:ps-1);
							}
							if(GUILayout.Button(playgroundLanguage.downSymbol, 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>();
								
								// Add this to Manager
								if (PlaygroundC.reference!=null) {
									PlaygroundC.particlesQuantity++;
									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(
									playgroundLanguage.remove+" "+playgroundScriptReference.particleSystems[ps].particleSystemGameObject.name+"?",
									playgroundLanguage.removeParticlePlaygroundSystem, 
									playgroundLanguage.yes, playgroundLanguage.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(playgroundLanguage.noParticleSystems, MessageType.Info);
					}
					
					if(GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
						PlaygroundParticlesC createdParticles = PlaygroundC.Particle();
						Selection.activeGameObject = createdParticles.particleSystemGameObject;
					}
					
					EditorGUILayout.Separator();
				}
				
				// Manipulators
				if (GUILayout.Button(playgroundLanguage.globalManipulators+" ("+playgroundScriptReference.manipulators.Count+")", EditorStyles.toolbarDropDown)) playgroundSettings.globalManipulatorsFoldout=!playgroundSettings.globalManipulatorsFoldout;
				if (playgroundSettings.globalManipulatorsFoldout) {
					
					EditorGUILayout.Separator();
					
					if (manipulators.arraySize>0) {
						
						for (int i = 0; i<manipulators.arraySize; i++) {
							if (!playgroundScriptReference.manipulators[i].enabled)
								GUI.contentColor = Color.gray;
							string mName;
							if (playgroundScriptReference.manipulators[i].transform.available) {
								mName = playgroundScriptReference.manipulators[i].transform.transform.name;
								if (mName.Length>24)
									mName = mName.Substring(0, 24)+"...";
							} else {
								GUI.color = Color.red;
								mName = "("+playgroundLanguage.missingTransform+")";
							}
							
							EditorGUILayout.BeginVertical(boxStyle);
							
							EditorGUILayout.BeginHorizontal();
							
							GUILayout.Label(i.ToString(), EditorStyles.miniLabel, GUILayout.Width(18));
							playgroundScriptReference.manipulators[i].unfolded = GUILayout.Toggle(playgroundScriptReference.manipulators[i].unfolded, ManipulatorTypeName(playgroundScriptReference.manipulators[i].type), EditorStyles.foldout, GUILayout.Width(Screen.width/4));
							if (playgroundScriptReference.manipulators[i].transform.available) {
								if (GUILayout.Button(" ("+mName+")", EditorStyles.label)) {
									Selection.activeGameObject = playgroundScriptReference.manipulators[i].transform.transform.gameObject;
								}
							} else {
								GUILayout.Button(ManipulatorTypeName(playgroundScriptReference.manipulators[i].type)+" ("+playgroundLanguage.missingTransform+")", EditorStyles.label);
							}
							GUI.contentColor = Color.white;
							EditorGUILayout.Separator();
							GUI.enabled = (playgroundScriptReference.manipulators.Count>1);
							if(GUILayout.Button(playgroundLanguage.upSymbol, EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
								manipulators.MoveArrayElement(i, i==0?playgroundScriptReference.manipulators.Count-1:i-1);
							}
							if(GUILayout.Button(playgroundLanguage.downSymbol, 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());
							}
							if(GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(16)})){
								
								if (EditorUtility.DisplayDialog(
									playgroundLanguage.remove+" "+ManipulatorTypeName(playgroundScriptReference.manipulators[i].type)+" "+playgroundLanguage.manipulator+" "+i+"?",
									playgroundLanguage.removeManipulator+" "+mName+"? "+playgroundLanguage.gameObjectIntact, 
									playgroundLanguage.yes, playgroundLanguage.no)) {
									manipulators.DeleteArrayElementAtIndex(i);
									playground.ApplyModifiedProperties();
									return;
								}
							}
							
							GUI.color = Color.white;
							
							EditorGUILayout.EndHorizontal();
							
							if (playgroundScriptReference.manipulators[i].unfolded && i<manipulators.arraySize) {
								RenderManipulatorSettings(playgroundScriptReference.manipulators[i], manipulators.GetArrayElementAtIndex(i), true);
							}
							
							GUI.enabled = true;
							EditorGUILayout.Separator();
							EditorGUILayout.EndVertical();
						}
						
					} else {
						EditorGUILayout.HelpBox(playgroundLanguage.noManipulators, MessageType.Info);
					}
					
					if(GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
						
						if (Selection.gameObjects.Length>0 && Selection.activeGameObject.transform && Selection.activeTransform!=null) {
							Transform mTrans = new GameObject().transform;
							mTrans.parent = PlaygroundC.referenceTransform;
							mTrans.position = Selection.activeGameObject.transform.position+Vector3.up;
							if (manipulators.arraySize>0)
								mTrans.name = "Global Manipulator "+(manipulators.arraySize+1);
							else mTrans.name = "Global Manipulator";
							PlaygroundC.ManipulatorObject(mTrans);
						} else
							manipulators.InsertArrayElementAtIndex(manipulators.arraySize);
						SceneView.RepaintAll();
					}
					
					EditorGUILayout.Separator();
					
				}
				
				// Advanced Settings
				if (GUILayout.Button(playgroundLanguage.advanced, EditorStyles.toolbarDropDown)) playgroundSettings.advancedSettingsFoldout=!playgroundSettings.advancedSettingsFoldout;
				if (playgroundSettings.advancedSettingsFoldout) {
					
					showSnapshotsSettings = PlaygroundC.reference.showSnapshotsInHierarchy;
					
					EditorGUILayout.Separator();
					EditorGUILayout.PropertyField(calculate, new GUIContent(playgroundLanguage.calculateParticles, playgroundLanguage.calculateParticlesDescription));
					EditorGUILayout.PropertyField(autoGroup, new GUIContent(playgroundLanguage.groupAutomatically, playgroundLanguage.groupAutomaticallyDescription));
					EditorGUILayout.PropertyField(buildZeroAlphaPixels, new GUIContent(playgroundLanguage.buildZeroAlphaPixels, playgroundLanguage.buildZeroAlphaPixelsDescription));
					EditorGUILayout.PropertyField(drawGizmos, new GUIContent(playgroundLanguage.sceneGizmos, playgroundLanguage.sceneGizmosDescription));
					GUI.enabled = drawGizmos.boolValue;
					EditorGUILayout.PropertyField(drawSourcePositions, new GUIContent(playgroundLanguage.sourcePositions, playgroundLanguage.sourcePositionsDescription));
					EditorGUILayout.PropertyField(drawSplinePreview, new GUIContent(playgroundLanguage.drawSplinePreview, playgroundLanguage.drawSplinePreviewDescription));
					PlaygroundSpline.drawSplinePreviews = drawSplinePreview.boolValue;
					GUI.enabled = true;
					EditorGUILayout.PropertyField(drawWireframe, new GUIContent(playgroundLanguage.wireframes, playgroundLanguage.wireframesDescription));
					EditorGUILayout.PropertyField(paintToolbox, new GUIContent(playgroundLanguage.paintToolbox, playgroundLanguage.paintToolboxDescription));
					EditorGUILayout.PropertyField(showShuriken, new GUIContent(playgroundLanguage.showShuriken, playgroundLanguage.showShurikenDescription));
					EditorGUILayout.PropertyField(showSnapshots, new GUIContent(playgroundLanguage.advancedSnapshots, playgroundLanguage.advancedSnapshotsDescription));
					EditorGUILayout.PropertyField(pixelFilterMode, new GUIContent(playgroundLanguage.pixelFilterMode, playgroundLanguage.pixelFilterModeDescription));
					EditorGUILayout.Separator();
					GUILayout.BeginVertical(boxStyle);
					EditorGUILayout.LabelField(playgroundLanguage.multithreading+" ("+PlaygroundC.ActiveThreads().ToString()+" "+playgroundLanguage.activeThreads+", "+PlaygroundC.ProcessorCount()+" "+playgroundLanguage.processors+")", EditorStyles.miniLabel);
					EditorGUILayout.PropertyField(threads, new GUIContent(playgroundLanguage.particleThreadMethod, playgroundLanguage.threadMethodDescription));
					EditorGUILayout.PropertyField(threadsTurbulence, new GUIContent(playgroundLanguage.turbulenceThreadMethod, playgroundLanguage.threadMethodDescription));
					EditorGUILayout.PropertyField(threadsSkinned, new GUIContent(playgroundLanguage.skinnedMeshThreadMethod, playgroundLanguage.threadMethodDescription));
					GUI.enabled = playgroundScriptReference.threadMethod==ThreadMethod.Automatic; 
					EditorGUILayout.PropertyField(maxThreads, new GUIContent(playgroundLanguage.maxThreads, playgroundLanguage.maxThreadsDescription));
					GUI.enabled = true;
					switch (playgroundScriptReference.threadMethod) {
					case ThreadMethod.NoThreads:EditorGUILayout.HelpBox(playgroundLanguage.threadInfo01, MessageType.Info);break;
					case ThreadMethod.OnePerSystem:EditorGUILayout.HelpBox(playgroundLanguage.threadInfo02, MessageType.Info);break;
					case ThreadMethod.OneForAll:EditorGUILayout.HelpBox(playgroundLanguage.threadInfo03, MessageType.Info);break;
					case ThreadMethod.Automatic:EditorGUILayout.HelpBox(playgroundLanguage.threadInfo04, MessageType.Info);break;
					}
					GUILayout.EndHorizontal();
					
					EditorGUILayout.Separator();
					
					// Update snapshot visibility
					if (showSnapshots.boolValue != showSnapshotsSettings) {
						UpdateSnapshots();
					}
					
					// Time reset
					GUILayout.BeginHorizontal();
					EditorGUILayout.PrefixLabel(playgroundLanguage.timeSimulation);
					if(GUILayout.Button(playgroundLanguage.reset, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
						PlaygroundC.TimeReset();
						for (int p = 0; p<playgroundScriptReference.particleSystems.Count; p++)
							playgroundScriptReference.particleSystems[p].Boot();
					}
					GUILayout.EndHorizontal();
					
				}
				
				
				
				playground.ApplyModifiedProperties();
				EditorGUILayout.EndVertical();
			} else {
				EditorGUILayout.HelpBox(playgroundLanguage.noPlaygroundManager, MessageType.Info);
				if(GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))){
					PlaygroundC.ResourceInstantiate("Playground Manager");
				}
				EditorGUILayout.EndVertical();
			}
			
		}
		EditorGUILayout.EndVertical();
	}
    public static void ExportLanguage(PlaygroundLanguageC selectedLanguage)
    {
        string xmlPath = EditorUtility.SaveFilePanel (selectedLanguage.saveLanguage, "", "Particle Playground Language - "+selectedLanguage.languageNameSeenByEnglish+".xml", "xml");

        if (xmlPath.Length!=0) {
            XmlDocument xml = new XmlDocument();
            XmlNode rootNode = xml.CreateElement ("Playground");
            xml.AppendChild (rootNode);
            SerializedObject serializedLanguage = new SerializedObject(selectedLanguage);
            SerializedProperty languageProperty = serializedLanguage.GetIterator();
            while (languageProperty.Next(true)) {
                if (languageProperty.propertyType==SerializedPropertyType.String) {
                    XmlNode newNode = xml.CreateElement(languageProperty.propertyPath);
                    newNode.InnerText = languageProperty.stringValue;
                    rootNode.AppendChild (newNode);
                }
            }
            xml.Save (xmlPath);
        }
    }
	void OnEnable () {

		lastActiveTool = Tools.current;
		isEditingInHierarchy = Selection.activeTransform!=null;

		// Load settings
		playgroundSettings = PlaygroundSettingsC.GetReference();
		
		// Load language
		playgroundLanguage = PlaygroundSettingsC.GetLanguage();
		
		// Playground Particles
		playgroundParticlesScriptReference = target as PlaygroundParticlesC;
		if (playgroundParticlesScriptReference==null) return;
		playgroundParticles = new SerializedObject(playgroundParticlesScriptReference);
		
		shurikenRenderer = playgroundParticlesScriptReference.particleSystemGameObject.GetComponent<ParticleSystem>().GetComponent<Renderer>() as ParticleSystemRenderer;

		// Sorting layers
		Type internalEditorUtilityType = typeof(InternalEditorUtility);
		PropertyInfo sortingLayersProperty = internalEditorUtilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic);
		rendererSortingLayers = (string[])sortingLayersProperty.GetValue(null, new object[0]);
		for (int i = 0; i<rendererSortingLayers.Length; i++) {
			if (shurikenRenderer.sortingLayerName == rendererSortingLayers[i])
				selectedSortingLayer = i;
		}

		// UV Module (Texture Sheet Animation)
		shuriken = new SerializedObject(playgroundParticlesScriptReference.shurikenParticleSystem);
		uvModule = shuriken.FindProperty("UVModule");
		uvModule_enabled = uvModule.FindPropertyRelative("enabled");
		uvModule_frameOverTime_scalar = uvModule.FindPropertyRelative("frameOverTime.scalar");
		uvModule_frameOverTime_minCurve = uvModule.FindPropertyRelative("frameOverTime.minCurve");
		uvModule_frameOverTime_maxCurve = uvModule.FindPropertyRelative("frameOverTime.maxCurve");
		uvModule_frameOverTime_minMaxState = uvModule.FindPropertyRelative("frameOverTime.minMaxState");
		uvModule_tilesX = uvModule.FindPropertyRelative("tilesX");
		uvModule_tilesY = uvModule.FindPropertyRelative("tilesY");
		uvModule_animationType = uvModule.FindPropertyRelative("animationType");
		uvModule_rowIndex = uvModule.FindPropertyRelative("rowIndex");
		uvModule_cycles = uvModule.FindPropertyRelative("cycles");
		uvModule_randomRow = uvModule.FindPropertyRelative("randomRow");
		uv_animationType = (AnimationType)uvModule_animationType.intValue;
		uv_minMaxState = (MinMaxState)uvModule_frameOverTime_minMaxState.intValue;


		shurikenRendererSO = new SerializedObject(shurikenRenderer);
		sortingMode = shurikenRendererSO.FindProperty("m_SortMode");
		sortingFudge = shurikenRendererSO.FindProperty("m_SortingFudge");
		sortMode = (SortMode)sortingMode.intValue;

		manipulators = playgroundParticles.FindProperty("manipulators");
		events = playgroundParticles.FindProperty("events");
		snapshots = playgroundParticles.FindProperty("snapshots");
		source = playgroundParticles.FindProperty("source");
		sorting = playgroundParticles.FindProperty("sorting");
		lifetimeSorting = playgroundParticles.FindProperty("lifetimeSorting");
		activeState = playgroundParticles.FindProperty("activeState");
		particleCount = playgroundParticles.FindProperty("particleCount");
		emissionRate = playgroundParticles.FindProperty("emissionRate");
		updateRate = playgroundParticles.FindProperty("updateRate");
		emit = playgroundParticles.FindProperty("emit");
		loop = playgroundParticles.FindProperty("loop");
		disableOnDone = playgroundParticles.FindProperty("disableOnDone");
		disableOnDoneRoutine = playgroundParticles.FindProperty("disableOnDoneRoutine");
		calculate = playgroundParticles.FindProperty("calculate");
		deltaMovementStrength = playgroundParticles.FindProperty("deltaMovementStrength");
		particleTimescale = playgroundParticles.FindProperty("particleTimescale");
		sizeMin = playgroundParticles.FindProperty("sizeMin");
		sizeMax = playgroundParticles.FindProperty("sizeMax");
		overflowOffset = playgroundParticles.FindProperty("overflowOffset");
		overflowMode = playgroundParticles.FindProperty("overflowMode");
		lifetime = playgroundParticles.FindProperty("lifetime");
		lifetimeSize = playgroundParticles.FindProperty("lifetimeSize");
		arraySize = playgroundParticles.FindProperty("particleArraySize");
		turbulenceLifetimeStrength = playgroundParticles.FindProperty("turbulenceLifetimeStrength");
		lifetimeVelocity = playgroundParticles.FindProperty("lifetimeVelocity");
		initialVelocityShape = playgroundParticles.FindProperty("initialVelocityShape");
		initialVelocityMin = playgroundParticles.FindProperty("initialVelocityMin");
		initialVelocityMax = playgroundParticles.FindProperty("initialVelocityMax");
		initialLocalVelocityMin = playgroundParticles.FindProperty("initialLocalVelocityMin");
		initialLocalVelocityMax = playgroundParticles.FindProperty("initialLocalVelocityMax");
		lifetimeColor = playgroundParticles.FindProperty("lifetimeColor");
		lifetimeColors = playgroundParticles.FindProperty ("lifetimeColors");
		arrayColor = playgroundParticles.FindProperty("arrayColorAlpha");
		colorSource = playgroundParticles.FindProperty("colorSource");
		collision = playgroundParticles.FindProperty("collision");
		affectRigidbodies = playgroundParticles.FindProperty("affectRigidbodies");
		mass = playgroundParticles.FindProperty("mass");
		collisionRadius = playgroundParticles.FindProperty("collisionRadius");
		collisionMask = playgroundParticles.FindProperty("collisionMask");
		collisionType = playgroundParticles.FindProperty("collisionType");
		bounciness = playgroundParticles.FindProperty("bounciness");
		states = playgroundParticles.FindProperty("states");
		worldObject = playgroundParticles.FindProperty("worldObject");
		skinnedWorldObject = playgroundParticles.FindProperty("skinnedWorldObject");
		forceSkinnedMeshUpdateOnMainThread = playgroundParticles.FindProperty ("forceSkinnedMeshUpdateOnMainThread");
		sourceTransform = playgroundParticles.FindProperty("sourceTransform");
		worldObjectUpdateVertices = playgroundParticles.FindProperty ("worldObjectUpdateVertices");
		worldObjectUpdateNormals = playgroundParticles.FindProperty("worldObjectUpdateNormals");
		sourcePaint = playgroundParticles.FindProperty("paint");
		sourceProjection = playgroundParticles.FindProperty("projection");
		sourceSplines = playgroundParticles.FindProperty("splines");
		sourceTransforms = playgroundParticles.FindProperty("sourceTransforms");
		lifetimeStretching = playgroundParticles.FindProperty("stretchLifetime");
		threadMethod = playgroundParticles.FindProperty("threadMethod");

		playgroundParticlesScriptReference.shurikenParticleSystem = playgroundParticlesScriptReference.GetComponent<ParticleSystem>();
		playgroundParticlesScriptReference.particleSystemRenderer = playgroundParticlesScriptReference.shurikenParticleSystem.GetComponent<Renderer>();
		particleMaterial = playgroundParticlesScriptReference.particleSystemRenderer.sharedMaterial;
		
		onlySourcePositioning = playgroundParticles.FindProperty("onlySourcePositioning");

		lifetimePositioning = playgroundParticles.FindProperty("lifetimePositioning");
		lifetimePositioningX = lifetimePositioning.FindPropertyRelative("x");
		lifetimePositioningY = lifetimePositioning.FindPropertyRelative("y");
		lifetimePositioningZ = lifetimePositioning.FindPropertyRelative("z");
		lifetimePositioningTimeScale = playgroundParticles.FindProperty ("lifetimePositioningTimeScale");
		lifetimePositioningPositionScale = playgroundParticles.FindProperty ("lifetimePositioningPositionScale");

		applyLifetimeVelocity = playgroundParticles.FindProperty("applyLifetimeVelocity");
		lifeTimeVelocityX = lifetimeVelocity.FindPropertyRelative("x");
		lifeTimeVelocityY = lifetimeVelocity.FindPropertyRelative("y");
		lifeTimeVelocityZ = lifetimeVelocity.FindPropertyRelative("z");
		
		initialVelocityShapeX = initialVelocityShape.FindPropertyRelative("x");
		initialVelocityShapeY = initialVelocityShape.FindPropertyRelative("y");
		initialVelocityShapeZ = initialVelocityShape.FindPropertyRelative("z");
		
		applyInitialVelocity = playgroundParticles.FindProperty("applyInitialVelocity");
		applyInitialLocalVelocity = playgroundParticles.FindProperty("applyInitialLocalVelocity");
		applyVelocityBending = playgroundParticles.FindProperty("applyVelocityBending");
		velocityBendingType = playgroundParticles.FindProperty("velocityBendingType");

		movementCompensationLifetimeStrength = playgroundParticles.FindProperty ("movementCompensationLifetimeStrength");
		
		worldObjectGameObject = worldObject.FindPropertyRelative("gameObject");
		skinnedWorldObjectGameObject = skinnedWorldObject.FindPropertyRelative("gameObject");

		// Lifetime colors
		if (playgroundParticlesScriptReference.lifetimeColors==null)
			playgroundParticlesScriptReference.lifetimeColors = new List<PlaygroundGradientC>();

		// Sorting
		prevLifetimeSortingKeys = playgroundParticlesScriptReference.lifetimeSorting.keys;

		// Events list
		eventListFoldout = new List<bool>();
		eventListFoldout.AddRange(new bool[playgroundParticlesScriptReference.events.Count]);

		// States foldout
		statesListFoldout = new List<bool>();
		statesListFoldout.AddRange(new bool[playgroundParticlesScriptReference.states.Count]);

		previousSource = playgroundParticlesScriptReference.source;
		
		// Playground
		playgroundScriptReference = FindObjectOfType<PlaygroundC>();
		
		
		// Create a manager if no existing instance is in the scene
		if (!playgroundScriptReference && Selection.activeTransform!=null) {
			PlaygroundC.ResourceInstantiate("Playground Manager");
			playgroundScriptReference = FindObjectOfType<PlaygroundC>();
		}
		
		if (playgroundScriptReference!=null) {

			PlaygroundC.reference = playgroundScriptReference;

			// Serialize Playground
			playground = new SerializedObject(playgroundScriptReference);
			
			PlaygroundInspectorC.Initialize(playgroundScriptReference);
			
			
			// Add this PlaygroundParticles if not existing in Playground list
			if (!playgroundParticlesScriptReference.isSnapshot && !playgroundScriptReference.particleSystems.Contains(playgroundParticlesScriptReference) && Selection.activeTransform!=null)
				playgroundScriptReference.particleSystems.Add(playgroundParticlesScriptReference);
				
			// Cache components
			playgroundParticlesScriptReference.particleSystemGameObject = playgroundParticlesScriptReference.gameObject;
			playgroundParticlesScriptReference.particleSystemTransform = playgroundParticlesScriptReference.transform;
			playgroundParticlesScriptReference.particleSystemRenderer = playgroundParticlesScriptReference.GetComponent<Renderer>();
			playgroundParticlesScriptReference.shurikenParticleSystem = playgroundParticlesScriptReference.particleSystemGameObject.GetComponent<ParticleSystem>();
			playgroundParticlesScriptReference.particleSystemRenderer2 = playgroundParticlesScriptReference.particleSystemGameObject.GetComponent<ParticleSystem>().GetComponent<Renderer>() as ParticleSystemRenderer;
			
			// Set manager as parent 
			//if (PlaygroundC.reference.autoGroup && playgroundParticlesScriptReference.particleSystemTransform!=null && playgroundParticlesScriptReference.particleSystemTransform.parent == null && Selection.activeTransform!=null)
			//	playgroundParticlesScriptReference.particleSystemTransform.parent = PlaygroundC.referenceTransform;
			
			// Issue a quick refresh

			if (!EditorApplication.isPlaying && isEditingInHierarchy) {
				foreach (PlaygroundParticlesC p in PlaygroundC.reference.particleSystems) {
					p.Start();
				}
			}
		}

		selectedSort = sorting.intValue;

		// State initial values
		if (addStateTransform==null)
			addStateTransform = (Transform)playgroundParticlesScriptReference.particleSystemTransform;
		
		// Visiblity of Shuriken component in Inspector
		if (!playgroundScriptReference || playgroundScriptReference && !playgroundScriptReference.showShuriken)
			playgroundParticlesScriptReference.shurikenParticleSystem.hideFlags = HideFlags.HideInInspector;
		else
			playgroundParticlesScriptReference.shurikenParticleSystem.hideFlags = HideFlags.None;

		SetWireframeVisibility();

		// Set paint init
		paintLayerMask = sourcePaint.FindPropertyRelative("layerMask");
		paintCollisionType = sourcePaint.FindPropertyRelative("collisionType");
		
		// Set projection init
		projectionMask = sourceProjection.FindPropertyRelative("projectionMask");
		projectionCollisionType = sourceProjection.FindPropertyRelative("collisionType");

		// Snapshots
		if (playgroundParticlesScriptReference.snapshots.Count>0) {
			if (playgroundParticlesScriptReference.snapshots.Count>0) {
				for (int i = 0; i<playgroundParticlesScriptReference.snapshots.Count; i++)
					if (playgroundParticlesScriptReference.snapshots[i].settings==null)
						playgroundParticlesScriptReference.snapshots.RemoveAt(i);
			}
			saveName += " "+(playgroundParticlesScriptReference.snapshots.Count+1).ToString();
		}

		SetMissingKeys();
	}
	public void Initialize () {
		presetButtonStyle = new GUIStyle();
		presetButtonStyle.stretchWidth = true;
		presetButtonStyle.stretchHeight = true;

		// Load settings
		playgroundSettings = PlaygroundSettingsC.SetReference();
		PlaygroundInspectorC.playgroundSettings = playgroundSettings;
		PlaygroundParticleSystemInspectorC.playgroundSettings = playgroundSettings;

		// Load language
		playgroundLanguage = PlaygroundSettingsC.GetLanguage();
		PlaygroundInspectorC.playgroundLanguage = playgroundLanguage;
		PlaygroundParticleSystemInspectorC.playgroundLanguage = playgroundLanguage;

		// Get all asset presets
		string assetsDataPath = Application.dataPath;
		if (Directory.Exists (assetsDataPath+"/"+playgroundSettings.playgroundPath+playgroundSettings.examplePresetPath)) {
			assetsFound = true;
		} else {
			assetsFound = false;
			playgroundSettings.settingsFoldout = true;
			playgroundSettings.settingsPathFoldout = true;
			return;
		}

		// Set default particle image
		Texture2D particleImageDefault = AssetDatabase.LoadAssetAtPath("Assets/"+playgroundSettings.playgroundPath+playgroundSettings.iconPath+"Default.png", typeof(Texture2D)) as Texture2D;

		// Prepare any previously entered search words to filter presets
		string[] searchSplits = searchString.Split(new string[]{" "}, System.StringSplitOptions.None);

		// Get the list of categories and presets
		string[] editorPresetCategories = Directory.GetDirectories(assetsDataPath+"/"+playgroundSettings.playgroundPath+playgroundSettings.examplePresetPath);
		presetCategories = new List<PresetCategory>();

		// A linear list of preset objects is kept for easier access
		presetObjects = new List<PresetObjectC>();

		// A linear list of preset names is kept for easier access
		presetNames = new List<string>();

		// List all categories in asset folders
		for (int i = 0; i<editorPresetCategories.Length; i++)
		{
			// Create the category
			string categoryName = editorPresetCategories[i].Substring(editorPresetCategories[i].LastIndexOf('/')+1);
			presetCategories.Add(new PresetCategory(categoryName));

			// Assign the preset objects to the category
			string[] presetsInCategory = Directory.GetFiles (editorPresetCategories[i]);
			for (int x = 0; x<presetsInCategory.Length; x++)
			{
				string convertedPresetPath = presetsInCategory[x].Substring(assetsDataPath.Length-6);
				Object presetPathObject = (Object)AssetDatabase.LoadAssetAtPath(convertedPresetPath, typeof(Object));
				if (presetPathObject!=null && (presetPathObject.GetType().Name)=="GameObject") {
					presetCategories[i].presetObjects.Add (new PresetObjectC(presetPathObject));

					int presetCountInCategory = presetCategories[i].presetObjects.Count-1;

					// Add to list of preset names
					presetNames.Add (categoryName+" - "+presetCategories[i].presetObjects[presetCountInCategory].presetObject.name);

					// Assign an image to the preset object
					Texture2D particleImage = AssetDatabase.LoadAssetAtPath("Assets/"+playgroundSettings.playgroundPath+playgroundSettings.iconPath+presetCategories[i].presetObjects[presetCountInCategory].presetObject.name+".png", typeof(Texture2D)) as Texture2D;

					// Try the asset location if we didn't find an image in regular editor folder
					if (particleImage==null)
						particleImage = AssetDatabase.LoadAssetAtPath(Path.GetDirectoryName(AssetDatabase.GetAssetPath(presetCategories[i].presetObjects[presetCountInCategory].presetObject as UnityEngine.Object))+"/"+presetCategories[i].presetObjects[presetCountInCategory].presetObject.name+".png", typeof(Texture2D)) as Texture2D;
					
					// Finally use the specified icon (or the default)
					if (particleImage!=null)
						presetCategories[i].presetObjects[presetCountInCategory].presetImage = particleImage;
					else if (particleImageDefault!=null)
						presetCategories[i].presetObjects[presetCountInCategory].presetImage = particleImageDefault;

					// Set this to Asset
					presetCategories[i].presetObjects[presetCountInCategory].example = true;

					// Filter the previous search
					foreach (string split in searchSplits)
						presetCategories[i].presetObjects[presetCountInCategory].unfiltered = (searchString.Length==0?true:presetNames[i].ToLower().Contains(split.ToLower()));

					// Add to linear list of preset objects
					presetObjects.Add (presetCategories[i].presetObjects[presetCountInCategory]);
				}
			}
		}

		// List any loose presets
		string[] loosePresets = Directory.GetFiles (assetsDataPath+"/"+playgroundSettings.playgroundPath+playgroundSettings.examplePresetPath);
		bool loosePresetsHasGo = false;
		for (int i = 0; i<loosePresets.Length; i++)
		{
			string convertedPresetPath = loosePresets[i].Substring(assetsDataPath.Length-6);
			Object obj = (Object)AssetDatabase.LoadAssetAtPath(convertedPresetPath, typeof(Object));
			if (obj!= null && obj.GetType().Name=="GameObject")
			{
				loosePresetsHasGo = true;
				break;
			}
		}
		if (loosePresets.Length>0 && loosePresetsHasGo) {
			presetCategories.Add(new PresetCategory("Uncategorized"));
			int categoryCount = presetCategories.Count-1;
			for (int x = 0; x<loosePresets.Length; x++)
			{
				string convertedPresetPath = loosePresets[x].Substring(assetsDataPath.Length-6);
				Object presetPathObject = (Object)AssetDatabase.LoadAssetAtPath(convertedPresetPath, typeof(Object));
				if (presetPathObject!=null && (presetPathObject.GetType().Name)=="GameObject") {
					presetCategories[categoryCount].presetObjects.Add (new PresetObjectC(presetPathObject));
					int presetCountInCategory = presetCategories[categoryCount].presetObjects.Count-1;
					presetNames.Add ("Uncategorized - "+presetCategories[categoryCount].presetObjects[presetCountInCategory].presetObject.name);
					Texture2D particleImage = AssetDatabase.LoadAssetAtPath("Assets/"+playgroundSettings.playgroundPath+playgroundSettings.iconPath+presetCategories[categoryCount].presetObjects[presetCountInCategory].presetObject.name+".png", typeof(Texture2D)) as Texture2D;
					if (particleImage==null)
						particleImage = AssetDatabase.LoadAssetAtPath(Path.GetDirectoryName(AssetDatabase.GetAssetPath(presetCategories[categoryCount].presetObjects[presetCountInCategory].presetObject as UnityEngine.Object))+"/"+presetCategories[categoryCount].presetObjects[presetCountInCategory].presetObject.name+".png", typeof(Texture2D)) as Texture2D;
					if (particleImage!=null)
						presetCategories[categoryCount].presetObjects[presetCountInCategory].presetImage = particleImage;
					else if (particleImageDefault!=null)
						presetCategories[categoryCount].presetObjects[presetCountInCategory].presetImage = particleImageDefault;
					presetCategories[categoryCount].presetObjects[presetCountInCategory].example = true;
					foreach (string split in searchSplits)
						presetCategories[categoryCount].presetObjects[presetCountInCategory].unfiltered = (searchString==""?true:presetNames[categoryCount].ToLower().Contains(split.ToLower()));
					presetObjects.Add (presetCategories[categoryCount].presetObjects[presetCountInCategory]);
				}
			}
		}

		// List any resources presets
		Object[] resourcePrefabs = (Object[])Resources.LoadAll ("Presets", typeof(GameObject));
		if (resourcePrefabs.Length > 0) {
			presetCategories.Add(new PresetCategory("Resources"));
			int categoryCount = presetCategories.Count-1;
			for (int i = 0; i<resourcePrefabs.Length; i++)
			{
				presetCategories[categoryCount].presetObjects.Add (new PresetObjectC(resourcePrefabs[i]));
				int presetCountInCategory = presetCategories[categoryCount].presetObjects.Count-1;
				presetNames.Add ("Resources - "+presetCategories[categoryCount].presetObjects[presetCountInCategory].presetObject.name);
				Texture2D particleImage = AssetDatabase.LoadAssetAtPath("Assets/"+playgroundSettings.playgroundPath+playgroundSettings.iconPath+presetCategories[categoryCount].presetObjects[presetCountInCategory].presetObject.name+".png", typeof(Texture2D)) as Texture2D;
				if (particleImage==null)
					particleImage = AssetDatabase.LoadAssetAtPath(Path.GetDirectoryName(AssetDatabase.GetAssetPath(presetCategories[categoryCount].presetObjects[presetCountInCategory].presetObject as UnityEngine.Object))+"/"+presetCategories[categoryCount].presetObjects[presetCountInCategory].presetObject.name+".png", typeof(Texture2D)) as Texture2D;
				if (particleImage!=null)
					presetCategories[categoryCount].presetObjects[presetCountInCategory].presetImage = particleImage;
				else if (particleImageDefault!=null)
					presetCategories[categoryCount].presetObjects[presetCountInCategory].presetImage = particleImageDefault;
				presetCategories[categoryCount].presetObjects[presetCountInCategory].example = false;
				foreach (string split in searchSplits)
					presetCategories[categoryCount].presetObjects[presetCountInCategory].unfiltered = (searchString==""?true:presetNames[categoryCount].ToLower().Contains(split.ToLower()));
				presetObjects.Add (presetCategories[categoryCount].presetObjects[presetCountInCategory]);
			}
		}

		// Check for internet connection
		hasInternet = CheckForInternetConnection();
	}