Exemple #1
0
    void OnEnable()
    {
        _instance = this;
        autoRepaintOnSceneChange = true;

        mGizmos = (MBGizmoFlags)System.Enum.Parse(typeof(MBGizmoFlags), EditorPrefs.GetInt("MagicalBox_DrawGizmos").ToString());
        mGizmosSelected = (MBGizmoFlags)System.Enum.Parse(typeof(MBGizmoFlags), EditorPrefs.GetInt("MagicalBox_DrawGizmosSelected").ToString());
        mAutoSelect=EditorPrefs.GetBool("MagicalBox_AutoSelect");
        mEditorUpdateInterval = EditorPrefs.GetFloat("MagicalBox_EditorUpdateInterval");
        mParametersAutoToggleSelected = EditorPrefs.GetBool("MagicalBox_AutoToggleParams");
        mTexLifeAnimated = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/LifeAnim.png", typeof(Texture)) as Texture;
        mTexBirthAnimated = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/BirthAnim.png", typeof(Texture)) as Texture;
        mTexClose = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/Close.png", typeof(Texture)) as Texture;
        mTexPlay = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/Play.png", typeof(Texture)) as Texture;
        mTexStop = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/Stop.png", typeof(Texture)) as Texture;
        mTexHalt = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/Halt.png", typeof(Texture)) as Texture;
        mTexSynchronize = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/Synchronize.png", typeof(Texture)) as Texture;
        mTexToggleZoom = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/ToggleZoom.png", typeof(Texture)) as Texture;
        mTexEMTrail = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/MBEmitterTrail.png", typeof(Texture)) as Texture;
        mTexMuted = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/Mute.png", typeof(Texture)) as Texture;
        mTexUnMuted = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/UnMute.png", typeof(Texture)) as Texture;
        mTexHourglass = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/Hourglass.png", typeof(Texture)) as Texture;
        mTexAutoSelect = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/AutoSelect.png", typeof(Texture)) as Texture;
        mTexUpdateInterval = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/UpdateInterval.png", typeof(Texture)) as Texture;
        mTexParamOrderUp = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/ParamOrderUp.png", typeof(Texture)) as Texture;
        mTexParamOrderDown = Resources.LoadAssetAtPath("Assets/Magical Box/Editor/Resources/ParamOrderDown.png", typeof(Texture)) as Texture;

        // Get a list of classes that derive from MBObject
        Assembly asm = Assembly.GetAssembly(typeof(MBParameter));
        System.Type[] types = asm.GetTypes();

        foreach (System.Type T in types) {
            if (T.BaseType == typeof(MBObject)) {
                Texture tex = Resources.LoadAssetAtPath("Assets/Gizmos/" + T.Name + ".png", typeof(Texture)) as Texture;
                if (tex)
                    mObjectIcons.Add(T, tex);
            }
        }
        Initialize();
    }
Exemple #2
0
    void DoToolbarGUI()
    {
        if (MBGUI.DoButton(new GUIContent(mTexClose,"Close Magical Box editor"), true, false))
            Close();
        GUILayout.Space(10);
        if (MBGUI.DoButton(new GUIContent(mTexPlay, "Play ParticleSystem"), SelectedParticleSystem != null, false)) {
            if (!SelectedParticleSystem.Paused)
                SelectedParticleSystem.Halt();
            SelectedParticleSystem.Play();
        }
        if (MBGUI.DoButton(new GUIContent(mTexStop, "Stop ParticleSystem"), SelectedParticleSystem != null && SelectedParticleSystem.Playing, false))
            SelectedParticleSystem.Stop();
        if (MBGUI.DoButton(new GUIContent(mTexHalt, "Halt ParticleSystem"), SelectedParticleSystem != null && SelectedParticleSystem.Playing, false))
            SelectedParticleSystem.Halt();
        GUILayout.Space(10);
        if (MBGUI.DoButton(new GUIContent(mTexPlay, "Play Selected"), MBEditorCommands.CanPlayObject(), false))
            MBEditorCommands.PlayObject();

        if (MBGUI.DoButton(new GUIContent(mTexStop, "Stop Selected"), MBEditorCommands.CanStopObject(), false))
            MBEditorCommands.StopObject();
        if (MBGUI.DoButton(new GUIContent(mTexHalt, "Halt Selected"), MBEditorCommands.CanHaltObject(), false))
            MBEditorCommands.HaltObject();
        GUILayout.Space(10);
        if (MBGUI.DoButton(new GUIContent(mTexSynchronize, "Resync"), SelectedParticleSystem != null, false))
            MBEditorCommands.SyncHierarchy();

        // DrawGizmo-Flags
        MBGUI.DoLabel("Gizmos:");
        bool sys = (mGizmos & MBGizmoFlags.MBParticleSystem) == MBGizmoFlags.MBParticleSystem;
        bool anc = (mGizmos & MBGizmoFlags.MBAnchor) == MBGizmoFlags.MBAnchor;
        bool em = (mGizmos & MBGizmoFlags.MBEmitter) == MBGizmoFlags.MBEmitter;
        bool par = (mGizmos & MBGizmoFlags.MBParameter) == MBGizmoFlags.MBParameter;
        sys = MBGUI.DoToggleButton(new GUIContent(ObjectIcon(typeof(MBParticleSystem)), "All ParticleSystems"), sys);
        anc = MBGUI.DoToggleButton(new GUIContent(ObjectIcon(typeof(MBAnchor)), "All Anchors"), anc);
        em = MBGUI.DoToggleButton(new GUIContent(ObjectIcon(typeof(MBEmitter)), "All Emitters"), em);
        par = MBGUI.DoToggleButton(new GUIContent(ObjectIcon(typeof(MBParameter)), "All Parameters"), par);
        if (sys)
            mGizmos |= MBGizmoFlags.MBParticleSystem;
        else
            mGizmos &= ~MBGizmoFlags.MBParticleSystem;
        if (anc)
            mGizmos |= MBGizmoFlags.MBAnchor;
        else
            mGizmos &= ~MBGizmoFlags.MBAnchor;
        if (em)
            mGizmos |= MBGizmoFlags.MBEmitter;
        else
            mGizmos &= ~MBGizmoFlags.MBEmitter;
        if (par)
            mGizmos |= MBGizmoFlags.MBParameter;
        else
            mGizmos &= ~MBGizmoFlags.MBParameter;

        // DrawGizmoSelected-Flags
        MBGUI.DoLabel("Selected:");
        sys = (mGizmosSelected & MBGizmoFlags.MBParticleSystem) == MBGizmoFlags.MBParticleSystem;
        anc = (mGizmosSelected & MBGizmoFlags.MBAnchor) == MBGizmoFlags.MBAnchor;
        em = (mGizmosSelected & MBGizmoFlags.MBEmitter) == MBGizmoFlags.MBEmitter;
        par = (mGizmosSelected & MBGizmoFlags.MBParameter) == MBGizmoFlags.MBParameter;
        sys = MBGUI.DoToggleButton(new GUIContent(ObjectIcon(typeof(MBParticleSystem)), "Selected ParticleSystem"), sys);
        anc = MBGUI.DoToggleButton(new GUIContent(ObjectIcon(typeof(MBAnchor)), "Selected Anchor"), anc);
        em = MBGUI.DoToggleButton(new GUIContent(ObjectIcon(typeof(MBEmitter)), "Selected Emitter"), em);
        par = MBGUI.DoToggleButton(new GUIContent(ObjectIcon(typeof(MBParameter)), "Selected Parameter"), par);
        if (sys)
            mGizmosSelected |= MBGizmoFlags.MBParticleSystem;
        else
            mGizmosSelected &= ~MBGizmoFlags.MBParticleSystem;
        if (anc)
            mGizmosSelected |= MBGizmoFlags.MBAnchor;
        else
            mGizmosSelected &= ~MBGizmoFlags.MBAnchor;
        if (em)
            mGizmosSelected |= MBGizmoFlags.MBEmitter;
        else
            mGizmosSelected &= ~MBGizmoFlags.MBEmitter;
        if (par)
            mGizmosSelected |= MBGizmoFlags.MBParameter;
        else
            mGizmosSelected &= ~MBGizmoFlags.MBParameter;

        GUILayout.Space(10);
        mAutoSelect = MBGUI.DoToggleButton(new GUIContent(mTexAutoSelect, "Synchronize Hierarchy when using the Overview"), mAutoSelect);
        GUILayout.Space(10);
        mSlowMotion = MBGUI.DoFloatSliderSmall(new GUIContent(mTexHourglass, "Slow Motion %"), mSlowMotion, 0f, 1f);
        mEditorUpdateInterval = MBGUI.DoFloatFieldSmall(new GUIContent(mTexUpdateInterval, "Editor update interval in seconds (0=instant)"), mEditorUpdateInterval,true);

        SelectedParticleSystem.mbDrawGizmos = mGizmos;
        SelectedParticleSystem.mbDrawGizmosSelected = mGizmosSelected;
    }