private void OnInspectorGUI_Single() { Undo.RecordObject(model, "Particle Model"); bool isAnyChanged = false; EditorGUI.BeginChangeCheck(); model.mainParticleSystem = EditorGUILayout.ObjectField("Main Particle System", model.mainParticleSystem, typeof(ParticleSystem), true) as ParticleSystem; if (EditorGUI.EndChangeCheck()) { model.targetChecked = false; } if (model.mainParticleSystem == null) { model.TrySetMainParticleSystem(); } if (model.mainParticleSystem != null) { if (!model.targetChecked) { model.CheckModel(); } if (model.animationClip != null) { EditorGUI.indentLevel++; GUI.enabled = false; EditorGUILayout.FloatField("Duration", model.mainParticleSystem.main.duration, EditorStyles.label); GUI.enabled = true; EditorGUI.indentLevel--; } } EditorGUILayout.Space(); model.isGroundPivot = DrawGroundPivotField(model, out isAnyChanged); EditorGUILayout.Space(); model.isLooping = DrawLoopingField(model, out isAnyChanged); if (model.isLooping) { EditorGUI.indentLevel++; model.isPrewarm = DrawPrewarmField(model, out isAnyChanged); EditorGUI.indentLevel--; } EditorGUILayout.Space(); model.spritePrefab = DrawSpritePrefabField(model, out isAnyChanged); if (model.spritePrefab != null) { EditorGUI.indentLevel++; model.prefabBuilder = DrawPrefabBuilderField(model, out isAnyChanged); EditorGUI.indentLevel--; } EditorGUILayout.Space(); bool isNameSuffixChanged; model.nameSuffix = DrawModelNameSuffix(model, out isNameSuffixChanged); if (isNameSuffixChanged) { PathHelper.CorrectPathString(ref model.nameSuffix); } EditorGUILayout.Space(); if (DrawingHelper.DrawWideButton("Add to the model list")) { AddToModelList(model); } }
private static void MakeParticleModels() { GameObject groupObject = null; List <ParticleModel> models = null; string[] selectedPathes = GetSelectedPathes(); string[] allAssetPaths = AssetDatabase.GetAllAssetPaths(); foreach (string assetPath in allAssetPaths) { if (!IsInAnyPathes(assetPath, selectedPathes)) { continue; } GameObject prefab = AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject)) as GameObject; if (prefab == null) { continue; } ParticleSystem particleSystem = prefab.GetComponentInChildren <ParticleSystem>(); if (particleSystem == null) { continue; } if (groupObject == null) { groupObject = new GameObject("Particle Model Group"); models = new List <ParticleModel>(); } GameObject obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, groupObject.transform); obj.name = prefab.name; ParticleModel model = obj.GetComponent <ParticleModel>(); if (model == null) { model = obj.AddComponent <ParticleModel>(); } if (model.TrySetMainParticleSystem()) { model.CheckModel(); } models.Add(model); } if (models != null) { const float PARTICLE_LENGTH = 10; foreach (ParticleModel model in models) { float rangeX = PARTICLE_LENGTH * models.Count; float rangeZ = PARTICLE_LENGTH * models.Count; model.transform.position = new Vector3(Random.Range(-rangeX, rangeX), 0, Random.Range(-rangeZ, rangeZ)); } } }