UnityEditor.ParticleEffectUI.CreateParticleSystem C# (CSharp) Method

CreateParticleSystem() public method

public CreateParticleSystem ( ParticleSystem parentOfNewParticleSystem, SubModuleUI defaultType ) : GameObject
parentOfNewParticleSystem UnityEngine.ParticleSystem
defaultType SubModuleUI
return UnityEngine.GameObject
        public GameObject CreateParticleSystem(ParticleSystem parentOfNewParticleSystem, SubModuleUI.SubEmitterType defaultType)
        {
            Type[] components = new Type[] { typeof(ParticleSystem) };
            GameObject obj2 = new GameObject(this.GetNextParticleSystemName(), components);
            if (obj2 != null)
            {
                if (parentOfNewParticleSystem != null)
                {
                    obj2.transform.parent = parentOfNewParticleSystem.transform;
                }
                obj2.transform.localPosition = Vector3.zero;
                obj2.transform.localRotation = Quaternion.identity;
                ParticleSystem component = obj2.GetComponent<ParticleSystem>();
                if (defaultType != SubModuleUI.SubEmitterType.None)
                {
                    component.SetupDefaultType((int) defaultType);
                }
                SessionState.SetFloat("CurrentEmitterAreaScroll", this.m_EmitterAreaScrollPos.x);
                Material[] materialArray1 = new Material[2];
                materialArray1[0] = AssetDatabase.GetBuiltinExtraResource<Material>("Default-Particle.mat");
                obj2.GetComponent<ParticleSystemRenderer>().materials = materialArray1;
                return obj2;
            }
            return null;
        }

Usage Example

        void EmitterMenuCallback(object obj)
        {
            int userData = (int)obj;

            switch (userData)
            {
            case 0:
                m_ParticleEffectUI.CreateParticleSystem(m_ParticleSystems[0], SubModuleUI.SubEmitterType.None);
                break;

            case 1:
                ResetModules();
                break;

            case 2:
                EditorGUIUtility.PingObject(m_ParticleSystems[0]);
                break;

            default:
                System.Diagnostics.Debug.Assert("Enum not handled!".Length == 0);
                break;
            }
        }