public ParticleSampler(Model model, Studio studio) : base(model, studio) { particleModel = model as ParticleModel; vecFromCameraToModel = model.transform.position - Camera.main.transform.position; }
void OnEnable() { model = target as ParticleModel; }
protected void OnInspectorGUI_Multi() { EditorGUILayout.HelpBox("Displayed information is of the first selected model,\nbut any change affects all selected models.", MessageType.Info); ParticleModel[] models = new ParticleModel[targets.Length]; for (int i = 0; i < models.Length; ++i) { models[i] = targets[i] as ParticleModel; } ParticleModel firstModel = models[0]; EditorGUILayout.Space(); bool isGroundPivotChanged; bool isGroundPivot = DrawGroundPivotField(firstModel, out isGroundPivotChanged); EditorGUILayout.Space(); bool isLoopingChanged; bool isLooping = DrawLoopingField(firstModel, out isLoopingChanged); bool isAllLooping = true; foreach (ParticleModel model in models) { isAllLooping &= model.isLooping; } bool isPrewarmChanged = false; bool isPrewarm = false; if (isAllLooping) { EditorGUI.indentLevel++; isPrewarm = DrawPrewarmField(firstModel, out isPrewarmChanged); EditorGUI.indentLevel--; } EditorGUILayout.Space(); bool isSpritePrefabChanged; GameObject spritePrefab = DrawSpritePrefabField(firstModel, out isSpritePrefabChanged); bool hasAllSpritePrefab = true; foreach (ParticleModel model in models) { hasAllSpritePrefab &= (model.spritePrefab != null); } PrefabBuilder prefabBuilder = null; bool isPrefabBuilderChanged = false; if (hasAllSpritePrefab) { EditorGUI.indentLevel++; prefabBuilder = DrawPrefabBuilderField(model, out isPrefabBuilderChanged); EditorGUI.indentLevel--; } EditorGUILayout.Space(); bool isNameSuffixChanged; string nameSuffix = DrawModelNameSuffix(firstModel, out isNameSuffixChanged); if (isNameSuffixChanged) { PathHelper.CorrectPathString(ref nameSuffix); } if (isGroundPivotChanged || isLoopingChanged || isPrewarmChanged || isSpritePrefabChanged || isPrefabBuilderChanged || isNameSuffixChanged) { foreach (ParticleModel model in models) { Undo.RecordObject(model, "Particle Model"); if (isGroundPivotChanged) { model.isGroundPivot = isGroundPivot; } if (isLoopingChanged) { model.isLooping = isLooping; } if (isPrewarmChanged) { model.isPrewarm = isPrewarm; } if (isSpritePrefabChanged) { model.spritePrefab = spritePrefab; } if (hasAllSpritePrefab && isPrefabBuilderChanged) { model.prefabBuilder = prefabBuilder; } if (isNameSuffixChanged) { model.nameSuffix = nameSuffix; } } } Studio studio = FindObjectOfType <Studio>(); if (studio == null) { return; } EditorGUILayout.Space(); if (DrawingHelper.DrawWideButton("Add all to the model list")) { foreach (ParticleModel model in models) { 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)); } } }