Exemple #1
0
    public static MBParticleSystem CreateParticleSystem(string defaultName)
    {
        MBParticleSystem sys = null;
        // Ask for atlas file
        string atlasPath=EditorUtility.SaveFilePanelInProject("Each ParticleSystem needs a texture atlas", defaultName + ".png", "png", "Please enter the name of the texture atlas");
        if (string.IsNullOrEmpty(atlasPath)) return null;

        Material mat = CreateMaterialQuestion(System.IO.Path.GetFileNameWithoutExtension(atlasPath));

        if (mat) {
            sys = new GameObject("ParticleSystem", new System.Type[] { typeof(MBParticleSystem) }).GetComponent<MBParticleSystem>();
            sys.AddLayer(mat);
            // Add a default emitter
            MBEmitter em=sys.AddEmitter();
            Texture2D deftex=Resources.LoadAssetAtPath("Assets/Magical Box/Base/default.png",typeof(Texture2D)) as Texture2D;
            if (em && deftex) {
                em.SetTexture(deftex);
            }
            sys.SetTextureAtlas(atlasPath);
            AssetDatabase.Refresh();
        }
        return sys;
    }