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();
	}
    public static PlaygroundSettingsC SetReference()
    {
        reference = (PlaygroundSettingsC)AssetDatabase.LoadAssetAtPath("Assets/" + settingsPath, typeof(PlaygroundSettingsC));

        // If reference is null - look in the PlaygroundCache for new file path
        if (reference == null)
        {
            if (Directory.Exists("PlaygroundCache") && File.Exists(playgroundCacheSettingsLocation))
            {
                string text = File.ReadAllText(playgroundCacheSettingsLocation);
                if (text.Length > 0)
                {
                    settingsPath = text;
                    reference    = (PlaygroundSettingsC)AssetDatabase.LoadAssetAtPath(settingsPath, typeof(PlaygroundSettingsC));
                    if (reference != null)
                    {
                        reference.isInstance = false;
                    }
                }
            }
        }

        // If reference still is null - create a temporary settings instance
        if (reference == null)
        {
            reference            = ScriptableObject.CreateInstance <PlaygroundSettingsC>();
            reference.isInstance = true;
        }
        else
        {
            reference.isInstance = false;
        }

        return(reference);
    }
Example #3
0
 public static void ShowWindow()
 {
     playgroundSettings = PlaygroundSettingsC.GetReference();
     playgroundLanguage = PlaygroundSettingsC.GetLanguage();
     window             = EditorWindow.GetWindow <PlaygroundCreatePresetWindowC>(true, playgroundLanguage.presetWizard);
     window.Show();
 }
    public static void New()
    {
        PlaygroundSettingsC newSettings = ScriptableObject.CreateInstance <PlaygroundSettingsC>();

        AssetDatabase.CreateAsset(newSettings, "Assets/" + settingsPath);
        AssetDatabase.SaveAssets();
    }
 public static void ShowWindow()
 {
     playgroundSettings = PlaygroundSettingsC.GetReference();
     playgroundLanguage = PlaygroundSettingsC.GetLanguage();
     window             = EditorWindow.GetWindow <PlaygroundPresetCategoryWindowC>(true, playgroundLanguage.presetManager);
     window.Show();
 }
Example #6
0
    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 || UNITY_4_7
        s_castShadows = s_trails.FindProperty("castShadows");
#else
        s_castShadows = s_trails.FindProperty("shadowCastingMode");
#endif
        s_layer = s_trails.FindProperty("layer");

        s_trails.Update();
        if (s_layer.intValue < 0)
        {
            s_layer.intValue = trails.playgroundSystem.gameObject.layer;
        }
        s_layer.intValue = Mathf.Clamp(s_layer.intValue, 0, 32);
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
        s_trails.ApplyModifiedProperties();
#else
        s_trails.ApplyModifiedPropertiesWithoutUndo();
#endif
        playgroundSettings = PlaygroundSettingsC.GetReference();
        playgroundLanguage = PlaygroundSettingsC.GetLanguage();

        // Issue a quick refresh
        if (!EditorApplication.isPlaying && Selection.activeTransform != null)
        {
            trails.ResetTrails();
        }
    }
Example #7
0
    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();
    }
	void OnEnable () {
		spline = target as PlaygroundSpline;
		
		playgroundSettings = PlaygroundSettingsC.GetReference();
		playgroundLanguage = PlaygroundSettingsC.GetLanguage();
		
		lastActiveTool = UnityEditor.Tools.current;
		
		UpdateUserList();
	}
    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();
	}
    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>();
	}
	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();
		}
	}
Example #15
0
    public static PlaygroundSettingsC SetReference()
    {
        reference = (PlaygroundSettingsC)AssetDatabase.LoadAssetAtPath("Assets/" + settingsPath, typeof(PlaygroundSettingsC));

        // If reference is null - search for the settings file
        if (reference == null)
        {
            UnityEngine.Object[] settingsFiles = GetAssetsOfType(typeof(PlaygroundSettingsC), ".asset");
            if (settingsFiles.Length > 0)
            {
                reference = (PlaygroundSettingsC)settingsFiles[0];
            }
        }

        // If reference still is null - create a temporary settings instance
        if (reference == null)
        {
            reference            = ScriptableObject.CreateInstance <PlaygroundSettingsC>();
            reference.isInstance = true;
        }
        else
        {
            reference.isInstance = false;
        }

        // Look up textures in case package is upgrading, not clean installing
        if (reference.playgroundIcon == null)
        {
            reference.playgroundIcon = GetGraphicsAsset("Assets/" + reference.playgroundPath + reference.iconPath, "Playground-Icon.png");
        }
        if (reference.playgroundIconInactive == null)
        {
            reference.playgroundIconInactive = GetGraphicsAsset("Assets/" + reference.playgroundPath + reference.iconPath, "Playground-Inactive-Icon.png");
        }
        if (reference.playgroundIconHeavy == null)
        {
            reference.playgroundIconHeavy = GetGraphicsAsset("Assets/" + reference.playgroundPath + reference.iconPath, "Playground-Warning-Icon.png");
        }

        return(reference);
    }
    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>();
        }
    }
    public static bool SetPlaygroundSettingsLocation()
    {
        UnityEngine.Object[] settingsFiles = GetAssetsOfType(typeof(PlaygroundSettingsC), ".asset");
        if (settingsFiles.Length > 0)
        {
            reference            = (PlaygroundSettingsC)settingsFiles[0];
            reference.isInstance = false;

            // Write this to file so we don't have to search next time
            if (!Directory.Exists("PlaygroundCache"))
            {
                Directory.CreateDirectory("PlaygroundCache");
            }
            if (!File.Exists(playgroundCacheSettingsLocation))
            {
                File.WriteAllText(playgroundCacheSettingsLocation, AssetDatabase.GetAssetPath((UnityEngine.Object)reference));
            }

            return(true);
        }
        return(false);
    }
	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();
	}
Example #19
0
	public static void Set () {
		playgroundSettings = PlaygroundSettingsC.GetReference();
		if (playgroundSettings.hierarchyIcon) {
			iconActive = playgroundSettings.playgroundIcon;
			iconInactive = playgroundSettings.playgroundIconInactive;
			iconHeavy = playgroundSettings.playgroundIconHeavy;
			if (iconActive!=null&&iconInactive!=null&&iconHeavy!=null) {
				EditorApplication.hierarchyWindowItemOnGUI -= DrawHierarchyIcon;
				EditorApplication.hierarchyWindowItemOnGUI += DrawHierarchyIcon;
			}
		} else EditorApplication.hierarchyWindowItemOnGUI -= DrawHierarchyIcon;
		EditorApplication.RepaintHierarchyWindow();
	}
    public static PlaygroundSettingsC SetReference()
    {
        reference = (PlaygroundSettingsC)AssetDatabase.LoadAssetAtPath ("Assets/"+settingsPath, typeof(PlaygroundSettingsC));

        // If reference is null - search for the settings file
        if (reference==null) {
            UnityEngine.Object[] settingsFiles = GetAssetsOfType(typeof(PlaygroundSettingsC), ".asset");
            if (settingsFiles.Length>0) {
                reference = (PlaygroundSettingsC)settingsFiles[0];
            }
        }

        // If reference still is null - create a temporary settings instance
        if (reference==null) {
            reference = ScriptableObject.CreateInstance<PlaygroundSettingsC>();
            reference.isInstance = true;
        } else reference.isInstance = false;

        return reference;
    }
	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();
	}
Example #22
0
 public static void ShowWindow()
 {
     playgroundLanguage = PlaygroundSettingsC.GetLanguage();
     window             = EditorWindow.GetWindow <PlaygroundCreateBrushWindowC>(true, playgroundLanguage.brushWizard);
     window.Show();
 }
	public static bool SetPlaygroundSettingsLocation ()
	{
		UnityEngine.Object[] settingsFiles = GetAssetsOfType(typeof(PlaygroundSettingsC), ".asset");
		if (settingsFiles.Length>0) {
			reference = (PlaygroundSettingsC)settingsFiles[0];
			reference.isInstance = false;

			// Write this to file so we don't have to search next time
			if (!Directory.Exists("PlaygroundCache"))
				Directory.CreateDirectory("PlaygroundCache");
			if (!File.Exists(playgroundCacheSettingsLocation))
			{
				File.WriteAllText(playgroundCacheSettingsLocation, AssetDatabase.GetAssetPath((UnityEngine.Object)reference));
			}
			
			return true;
		}
		return false;
	}
	public static PlaygroundSettingsC SetReference () {
		reference = (PlaygroundSettingsC)AssetDatabase.LoadAssetAtPath ("Assets/"+settingsPath, typeof(PlaygroundSettingsC));

		// If reference is null - look in the PlaygroundCache for new file path
		if (reference==null)
		{
			if (Directory.Exists("PlaygroundCache") && File.Exists(playgroundCacheSettingsLocation))
			{
				string text = File.ReadAllText(playgroundCacheSettingsLocation);
				if (text.Length>0)
				{
					settingsPath = text;
					reference = (PlaygroundSettingsC)AssetDatabase.LoadAssetAtPath (settingsPath, typeof(PlaygroundSettingsC));
					if (reference != null)
						reference.isInstance = false;
				}
			}
		}

		// If reference still is null - create a temporary settings instance
		if (reference==null) {
			reference = ScriptableObject.CreateInstance<PlaygroundSettingsC>();
			reference.isInstance = true;
		} else reference.isInstance = false;

		return reference;
	}
    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 SetReference(object thisRef)
 {
     reference = (PlaygroundSettingsC)thisRef;
     reference.isInstance = false;
 }
 public static void SetReference(object thisRef)
 {
     reference            = (PlaygroundSettingsC)thisRef;
     reference.isInstance = false;
 }
Example #28
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 ShowWindow () {
		playgroundSettings = PlaygroundSettingsC.GetReference();
		playgroundLanguage = PlaygroundSettingsC.GetLanguage();
		window = EditorWindow.GetWindow<PlaygroundCreatePresetWindowC>(true, playgroundLanguage.presetWizard);
        window.Show();
	}
	public static PlaygroundSettingsC SetReference () {
		reference = (PlaygroundSettingsC)AssetDatabase.LoadAssetAtPath ("Assets/"+settingsPath, typeof(PlaygroundSettingsC));

		// If reference is null - search for the settings file
		if (reference==null) {
			UnityEngine.Object[] settingsFiles = GetAssetsOfType(typeof(PlaygroundSettingsC), ".asset");
			if (settingsFiles.Length>0) {
				reference = (PlaygroundSettingsC)settingsFiles[0];
			}
		}

		// If reference still is null - create a temporary settings instance
		if (reference==null) {
			reference = ScriptableObject.CreateInstance<PlaygroundSettingsC>();
			reference.isInstance = true;
		} else reference.isInstance = false;

		// Look up textures in case package is upgrading, not clean installing
		if (reference.playgroundIcon==null)
			reference.playgroundIcon = GetGraphicsAsset("Assets/"+reference.playgroundPath+reference.iconPath,"Playground-Icon.png");
		if (reference.playgroundIconInactive==null)
			reference.playgroundIconInactive = GetGraphicsAsset("Assets/"+reference.playgroundPath+reference.iconPath,"Playground-Inactive-Icon.png");
		if (reference.playgroundIconHeavy==null)
			reference.playgroundIconHeavy = GetGraphicsAsset("Assets/"+reference.playgroundPath+reference.iconPath,"Playground-Warning-Icon.png");

		return reference;
	}