ShowSelectPrefabPopup() 공개 메소드

public ShowSelectPrefabPopup ( NcEffectBehaviour, selCom, bool bShowByInspector, int nArgIndex ) : void
selCom NcEffectBehaviour,
bShowByInspector bool
nArgIndex int
리턴 void
예제 #1
0
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);
        m_UndoManager.CheckUndo();

        Rect rect;

        m_FxmPopupManager = GetFxmPopupManager();

        // --------------------------------------------------------------
        bool bClickButton = false;

        EditorGUI.BeginChangeCheck();
        {
//			DrawDefaultInspector();
            m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

            m_Sel.m_AttachType = (NcParticleEmit.AttachType)EditorGUILayout.EnumPopup(GetHelpContent("m_AttachType"), m_Sel.m_AttachType, GUILayout.MaxWidth(Screen.width));

            if (m_Sel.m_AttachType == NcParticleEmit.AttachType.Active)
            {
                m_Sel.m_fDelayTime  = EditorGUILayout.FloatField(GetHelpContent("m_fDelayTime"), m_Sel.m_fDelayTime);
                m_Sel.m_fRepeatTime = EditorGUILayout.FloatField(GetHelpContent("m_fRepeatTime"), m_Sel.m_fRepeatTime);
            }

            m_Sel.m_nRepeatCount   = EditorGUILayout.IntField(GetHelpContent("m_nRepeatCount"), m_Sel.m_nRepeatCount);
            m_Sel.m_ParticlePrefab = (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_ParticlePrefab"), m_Sel.m_ParticlePrefab, typeof(GameObject), false, null);
            // --------------------------------------------------------------
            EditorGUILayout.Space();
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
            {
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 0, 2), GetHelpContent("SelectParticlePrefab"), (m_FxmPopupManager != null)))
                {
                    m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, true, 0);
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 2, 1), GetHelpContent("ClearPrefab"), (m_Sel.m_ParticlePrefab != null)))
                {
                    bClickButton           = true;
                    m_Sel.m_ParticlePrefab = null;
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 3, 1), GetHelpContent("OpenPrefab"), (m_FxmPopupManager != null) && (m_Sel.m_ParticlePrefab != null)))
                {
                    bClickButton = true;
                    GetFXMakerMain().OpenPrefab(m_Sel.m_ParticlePrefab);
                    return;
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            // --------------------------------------------------------------

            if (m_Sel.m_AttachType == NcParticleEmit.AttachType.Destroy)
            {
                SetMinValue(ref m_Sel.m_nRepeatCount, 1);
            }
            FXMakerLayout.GUIEnableBackup(false);
            EditorGUILayout.Toggle(GetHelpContent("m_bWorldSpace"), true);
            FXMakerLayout.GUIEnableRestore();

            m_Sel.m_EmitCount   = EditorGUILayout.IntField("m_EmitCount", m_Sel.m_EmitCount);
            m_Sel.m_RandomRange = EditorGUILayout.Vector3Field("m_RandomRange", m_Sel.m_RandomRange, null);
            m_Sel.m_AddStartPos = EditorGUILayout.Vector3Field("m_AddStartPos", m_Sel.m_AddStartPos, null);

            // check
            SetMinValue(ref m_Sel.m_EmitCount, 1);
            SetMinValue(ref m_Sel.m_fDelayTime, 0);
            SetMinValue(ref m_Sel.m_fRepeatTime, 0);
            SetMinValue(ref m_Sel.m_nRepeatCount, 0);
        }
        m_UndoManager.CheckDirty();
        // --------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
        {
            OnEditComponent();
        }
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
        {
            m_LastTooltip = GUI.tooltip;
        }
        HelpBox(m_LastTooltip);
    }
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);

        int  nClickIndex  = -1;
        int  nClickButton = 0;
        Rect rect;
        int  nLeftWidth    = 34;
        int  nAddHeight    = 30;
        int  nDelWidth     = 35;
        int  nLineHeight   = 18;
        int  nSpriteHeight = nLeftWidth;
        List <NcSpriteFactory.NcSpriteNode> spriteList = m_Sel.m_SpriteList;

        m_FxmPopupManager = GetFxmPopupManager();

        // --------------------------------------------------------------
        bool bClickButton = false;

        EditorGUI.BeginChangeCheck();
        {
            m_UndoManager.CheckUndo();
            // --------------------------------------------------------------
            m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

            EditorGUILayout.Space();
            m_Sel.m_SpriteType = (NcSpriteFactory.SPRITE_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_SpriteType"), m_Sel.m_SpriteType);

            // --------------------------------------------------------------
            if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && m_Sel.gameObject.GetComponent("NcSpriteAnimation") == null)
            {
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
                {
                    if (FXMakerLayout.GUIButton(rect, GetHelpContent("Add NcSpriteAnimation Component"), true))
                    {
                        m_Sel.gameObject.AddComponent("NcSpriteAnimation");
                    }
                    GUILayout.Label("");
                }
                EditorGUILayout.EndHorizontal();
            }
            // --------------------------------------------------------------
            if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteTexture && m_Sel.gameObject.GetComponent("NcSpriteTexture") == null)
            {
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
                {
                    if (FXMakerLayout.GUIButton(rect, GetHelpContent("Add NcSpriteTexture Component"), true))
                    {
                        m_Sel.gameObject.AddComponent("NcSpriteTexture");
                    }
                    GUILayout.Label("");
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.Space();

            // --------------------------------------------------------------
            int   nSelIndex = EditorGUILayout.IntSlider(GetHelpContent("m_nCurrentIndex"), m_Sel.m_nCurrentIndex, 0, (spriteList == null ? 0 : spriteList.Count - 1));
            float fUvScale  = EditorGUILayout.FloatField(GetHelpContent("m_fUvScale"), m_Sel.m_fUvScale);
            if (m_Sel.m_nCurrentIndex != nSelIndex || fUvScale != m_Sel.m_fUvScale)
            {
                m_Sel.m_nCurrentIndex = nSelIndex;
                m_Sel.m_fUvScale      = fUvScale;
                m_Sel.SetSprite(nSelIndex, false);
            }

            // Rebuild Check
            EditorGUI.BeginChangeCheck();
            m_Sel.m_bTrimBlack           = EditorGUILayout.Toggle(GetHelpContent("m_bTrimBlack"), m_Sel.m_bTrimBlack);
            m_Sel.m_bTrimAlpha           = EditorGUILayout.Toggle(GetHelpContent("m_bTrimAlpha"), m_Sel.m_bTrimAlpha);
            m_Sel.m_nMaxAtlasTextureSize = EditorGUILayout.IntPopup("nMaxAtlasTextureSize", m_Sel.m_nMaxAtlasTextureSize, NgEnum.m_TextureSizeStrings, NgEnum.m_TextureSizeIntters);
//          m_Sel.m_AtlasMaterial		= (Material)EditorGUILayout.ObjectField(GetHelpContent("m_AtlasMaterial")	, m_Sel.m_AtlasMaterial, typeof(Material), false);
            if (EditorGUI.EndChangeCheck())
            {
                m_Sel.m_bNeedRebuild = true;
            }

            // check

            // Add Button ------------------------------------------------------
            EditorGUILayout.Space();
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nAddHeight * 2));
            {
                Rect lineRect = FXMakerLayout.GetInnerVerticalRect(rect, 2, 0, 1);
                if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 0, 1), GetHelpContent("Add Sprite")))
                {
                    bClickButton = true;
                    m_Sel.AddSpriteNode();
                }

                bool bHighLight = m_Sel.m_bNeedRebuild;
                if (bHighLight)
                {
                    FXMakerLayout.GUIColorBackup(FXMakerLayout.m_ColorHelpBox);
                }
                if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 1, 1), GetHelpContent("Build Sprite")))
                {
#if UNITY_WEBPLAYER
                    Debug.LogError("In WEB_PLAYER mode, you cannot run the FXMaker.");
                    Debug.Break();
#else
                    bClickButton = true;
                    CreateSpriteAtlas(m_Sel.renderer.sharedMaterial);
                    m_Sel.m_bNeedRebuild = false;
#endif
                }
                if (bHighLight)
                {
                    FXMakerLayout.GUIColorRestore();
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 2, 1), GetHelpContent("Clear All"), (0 < m_Sel.GetSpriteNodeCount())))
                {
                    bClickButton = true;
                    if (m_FxmPopupManager != null)
                    {
                        m_FxmPopupManager.CloseNcPrefabPopup();
                    }
                    m_Sel.ClearAllSpriteNode();
                }
                lineRect = FXMakerLayout.GetInnerVerticalRect(rect, 2, 1, 1);
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 0, 1), GetHelpContent("Sequence"), (0 < m_Sel.GetSpriteNodeCount())))
                {
                    m_Sel.m_bSequenceMode = true;
                    bClickButton          = true;
                    m_Sel.SetSprite(0, false);
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 1, 1), GetHelpContent("NewMaterial"), true))
                {
                    Material newMat  = new Material(m_Sel.renderer.sharedMaterial);
                    string   matPath = AssetDatabase.GetAssetPath(m_Sel.renderer.sharedMaterial);
                    NgMaterial.SaveMaterial(newMat, NgFile.TrimFilenameExt(matPath), m_Sel.name);
                    m_Sel.renderer.sharedMaterial = newMat;
//                  m_Sel.renderer.sharedMaterial = (Material)AssetDatabase.LoadAssetAtPath(savePath, typeof(Material));
                }

                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();

            // Select ShotType -------------------------------------------------
//			showType		= (NcSpriteFactory.SHOW_TYPE)EditorGUILayout.EnumPopup		(GetHelpContent("m_ShowType")	, showType);
            // --------------------------------------------------------------
            EditorGUILayout.Space();
            NcSpriteFactory.SHOW_TYPE showType = (NcSpriteFactory.SHOW_TYPE)EditorPrefs.GetInt("NcSpriteFactory.SHOW_TYPE", 0);

            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
            {
                showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 0, 1), showType == NcSpriteFactory.SHOW_TYPE.NONE, GetHelpContent("NONE"), true) ? NcSpriteFactory.SHOW_TYPE.NONE        : showType;
                showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 1, 1), showType == NcSpriteFactory.SHOW_TYPE.ALL, GetHelpContent("ALL"), true) ? NcSpriteFactory.SHOW_TYPE.ALL         : showType;
                if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation)
                {
                    showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 2, 1), showType == NcSpriteFactory.SHOW_TYPE.SPRITE, GetHelpContent("SPRITE"), true) ? NcSpriteFactory.SHOW_TYPE.SPRITE              : showType;
                    showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 3, 1), showType == NcSpriteFactory.SHOW_TYPE.ANIMATION, GetHelpContent("ANIMATION"), true) ? NcSpriteFactory.SHOW_TYPE.ANIMATION   : showType;
                }
                showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 4, 1), showType == NcSpriteFactory.SHOW_TYPE.EFFECT, GetHelpContent("EFFECT"), true) ? NcSpriteFactory.SHOW_TYPE.EFFECT              : showType;
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();

            EditorPrefs.SetInt("NcSpriteFactory.SHOW_TYPE", ((int)showType));

            // Show Option -------------------------------------------------
            EditorGUILayout.Space();
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
            {
                m_Sel.m_bShowEffect = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 0, 1), m_Sel.m_bShowEffect, GetHelpContent("m_bShowEffect"), true);
                if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation)
                {
                    m_Sel.m_bTestMode     = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 1, 1), m_Sel.m_bTestMode, GetHelpContent("m_bTestMode"), true);
                    m_Sel.m_bSequenceMode = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 2, 1), m_Sel.m_bSequenceMode, GetHelpContent("m_bSequenceMode"), true);
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();

            // Node List ------------------------------------------------------
            for (int n = 0; n < (spriteList != null ? spriteList.Count : 0); n++)
            {
                EditorGUILayout.Space();

                EditorGUI.BeginChangeCheck();
                // Load Texture ---------------------------------------------------------
                Texture2D selTexture = null;
                if (spriteList[n].m_TextureGUID != "")
                {
                    selTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(spriteList[n].m_TextureGUID), typeof(Texture2D));
                }

                // Enabled --------------------------------------------------------------
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                {
                    Rect subRect;
                    EditorGUI.BeginChangeCheck();
                    // enable
                    spriteList[n].m_bIncludedAtlas = GUILayout.Toggle(spriteList[n].m_bIncludedAtlas, "Idx", GUILayout.Width(nLeftWidth));
                    // change index
                    subRect       = rect;
                    subRect.x    += nLeftWidth;
                    subRect.width = nLineHeight * 2;
                    int newPos = EditorGUI.IntPopup(subRect, n, NgConvert.GetIntStrings(0, spriteList.Count), NgConvert.GetIntegers(0, spriteList.Count));
                    if (newPos != n)
                    {
                        NcSpriteFactory.NcSpriteNode node = spriteList[n];
                        m_Sel.m_SpriteList.Remove(node);
                        m_Sel.m_SpriteList.Insert(newPos, node);
                        return;
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_Sel.m_bNeedRebuild = true;
                    }

                    // name
                    subRect        = rect;
                    subRect.x     += nLeftWidth + nLineHeight * 2;
                    subRect.width -= nLeftWidth + nLineHeight * 2;
                    spriteList[n].m_TextureName = selTexture == null ? "" : selTexture.name;
                    GUI.Label(subRect, (selTexture == null ? "" : "(" + spriteList[n].m_nFrameCount + ") " + selTexture.name));
                    GUI.Box(subRect, "");
                    GUI.Box(rect, "");

                    // delete
                    if (GUI.Button(new Rect(subRect.x + subRect.width - nDelWidth, subRect.y, nDelWidth, subRect.height), GetHelpContent("Del")))
                    {
                        m_Sel.m_bNeedRebuild = true;
                        bClickButton         = true;
                        if (m_FxmPopupManager != null)
                        {
                            m_FxmPopupManager.CloseNcPrefabPopup();
                        }
                        m_Sel.DeleteSpriteNode(n);
                        return;
                    }
                }
                EditorGUILayout.EndHorizontal();

                // SpriteName MaxAlpha -----------------------------------------------------------
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                {
                    GUILayout.Label("", GUILayout.Width(nLineHeight));
                    GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 7, 0, 2), "Name,fMaxAlpha");
                    spriteList[n].m_SpriteName       = EditorGUI.TextField(FXMakerLayout.GetInnerHorizontalRect(rect, 7, 2, 4), spriteList[n].m_SpriteName);
                    spriteList[n].m_fMaxTextureAlpha = EditorGUI.FloatField(FXMakerLayout.GetInnerHorizontalRect(rect, 7, 6, 1), spriteList[n].m_fMaxTextureAlpha);
                }
                EditorGUILayout.EndHorizontal();

                // Texture --------------------------------------------------------------
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nSpriteHeight / (selTexture == null ? 2 : 1)));
                {
                    GUILayout.Label("", GUILayout.Width(nLeftWidth));

                    Rect subRect = rect;
                    subRect.width = nLeftWidth;
                    FXMakerLayout.GetOffsetRect(rect, 0, 5, 0, -5);
                    EditorGUI.BeginChangeCheck();
                    selTexture = (Texture2D)EditorGUI.ObjectField(subRect, GetHelpContent(""), selTexture, typeof(Texture2D), false);
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (selTexture != null)
                        {
                            spriteList[n].m_TextureGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(selTexture));
                        }
                        m_Sel.m_bNeedRebuild = true;
                    }

                    // draw texture
                    subRect = FXMakerLayout.GetOffsetRect(rect, nLeftWidth + 4, 0, 0, -4);
                    Rect drawRect = FXMakerLayout.GetOffsetRect(subRect, 0, 0, -nDelWidth, 0);

                    if (selTexture != null)
                    {
                        // draw texture
                        GUI.DrawTexture(drawRect, selTexture, ScaleMode.ScaleToFit, true, selTexture.width / selTexture.height);

                        // draw tile
                        float fDrawRatio  = drawRect.width / drawRect.height;
                        float fImageRatio = selTexture.width / selTexture.height;
                        if (fDrawRatio < fImageRatio)
                        {
                            drawRect = FXMakerLayout.GetVOffsetRect(drawRect, drawRect.height * -(1 - (fDrawRatio / fImageRatio)) / 2);
                        }
                        else
                        {
                            drawRect = FXMakerLayout.GetHOffsetRect(drawRect, drawRect.width * -(1 - (fImageRatio / fDrawRatio)) / 2);
                        }
                        float tileWidth  = (drawRect.width / spriteList[n].m_nTilingX);
                        float tileHeight = (drawRect.height / spriteList[n].m_nTilingY);

                        for (int tn = spriteList[n].m_nStartFrame; tn < Mathf.Min(spriteList[n].m_nStartFrame + spriteList[n].m_nFrameCount, spriteList[n].m_nTilingX * spriteList[n].m_nTilingY); tn++)
                        {
                            int  posx     = tn % spriteList[n].m_nTilingX;
                            int  posy     = tn / spriteList[n].m_nTilingX;
                            Rect tileRect = new Rect(drawRect.x + posx * tileWidth, drawRect.y + posy * tileHeight, tileWidth, tileHeight);
                            NgGUIDraw.DrawBox(FXMakerLayout.GetOffsetRect(tileRect, -1), Color.green, 1, false);
                        }
                    }

                    // delete
                    if (GUI.Button(new Rect(subRect.x + subRect.width - nDelWidth, subRect.y, nDelWidth, subRect.height), GetHelpContent("Rmv")))
                    {
                        spriteList[n].SetEmpty();
                    }
                    GUI.Box(rect, "");
                }
                EditorGUILayout.EndHorizontal();

                // Change selIndex
                Event e = Event.current;
                if (e.type == EventType.MouseDown && rect.Contains(e.mousePosition))
                {
                    nClickIndex  = n;
                    nClickButton = e.button;
                }

                // -----------------------------------------------------------------------------------------------------------------------------------------------
                if (spriteList[n].IsEmptyTexture() == false)
                {
                    // Frame tile
                    rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                    {
                        GUILayout.Label("", GUILayout.Width(nLineHeight));
                        GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 0, 4), "nTileXY,Start,Count");

                        // m_nTilingX, m_nTilingY
                        EditorGUI.BeginChangeCheck();
                        spriteList[n].m_nTilingX = EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 4, 1), spriteList[n].m_nTilingX);
                        spriteList[n].m_nTilingY = EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 5, 1), spriteList[n].m_nTilingY);
                        SetMinValue(ref spriteList[n].m_nTilingX, 1);
                        SetMinValue(ref spriteList[n].m_nTilingY, 1);
                        if (EditorGUI.EndChangeCheck())
                        {
                            spriteList[n].m_nFrameCount = spriteList[n].m_nTilingX * spriteList[n].m_nTilingY - spriteList[n].m_nStartFrame;
                            m_Sel.m_bNeedRebuild        = true;
                        }

                        // m_nStartFrame, m_nFrameCount
                        EditorGUI.BeginChangeCheck();
                        spriteList[n].m_nStartFrame = EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 6, 1), spriteList[n].m_nStartFrame);
                        spriteList[n].m_nFrameCount = EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 7, 1), spriteList[n].m_nFrameCount);
                        SetMaxValue(ref spriteList[n].m_nStartFrame, spriteList[n].m_nTilingX * spriteList[n].m_nTilingY - 1);
                        SetMinValue(ref spriteList[n].m_nStartFrame, 0);
                        SetMaxValue(ref spriteList[n].m_nFrameCount, spriteList[n].m_nTilingX * spriteList[n].m_nTilingY - spriteList[n].m_nStartFrame);
                        SetMinValue(ref spriteList[n].m_nFrameCount, 1);
                        if (EditorGUI.EndChangeCheck())
                        {
                            m_Sel.m_bNeedRebuild = true;
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    // SpriteNode ----------------------------------------------------------
                    if (bClickButton == false)
                    {
                        if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && (showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.SPRITE))
                        {
                            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                            {
                                GUILayout.Label("", GUILayout.Width(nLineHeight));
                                GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 0, 4), "Loop,Start,FCnt,LCnt");

                                bool bOldLoop = spriteList[n].m_bLoop;
                                spriteList[n].m_bLoop = EditorGUI.Toggle(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 4, 1), spriteList[n].m_bLoop);
                                if (!bOldLoop && spriteList[n].m_bLoop)
                                {
                                    spriteList[n].m_nLoopStartFrame = 0;
                                    spriteList[n].m_nLoopFrameCount = spriteList[n].m_nFrameCount;
                                    spriteList[n].m_nLoopingCount   = 0;
                                }
                                if (spriteList[n].m_bLoop)
                                {
                                    spriteList[n].m_nLoopStartFrame = EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 5, 1), spriteList[n].m_nLoopStartFrame);
                                    spriteList[n].m_nLoopFrameCount = EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 6, 1), spriteList[n].m_nLoopFrameCount);
                                    spriteList[n].m_nLoopingCount   = EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 7, 1), spriteList[n].m_nLoopingCount);
                                }
                                // check
                                SetMaxValue(ref spriteList[n].m_nLoopStartFrame, spriteList[n].m_nFrameCount - 1);
                                SetMinValue(ref spriteList[n].m_nLoopStartFrame, 0);
                                SetMaxValue(ref spriteList[n].m_nLoopFrameCount, spriteList[n].m_nFrameCount - spriteList[n].m_nLoopStartFrame);
                                SetMinValue(ref spriteList[n].m_nLoopingCount, 0);
                            }
                            EditorGUILayout.EndHorizontal();

                            spriteList[n].m_fTime = EditorGUILayout.Slider(GetHelpContent("m_fTime"), spriteList[n].m_nFrameCount / spriteList[n].m_fFps, 0, 5, null);
                            spriteList[n].m_fFps  = EditorGUILayout.Slider(GetHelpContent("m_fFps"), spriteList[n].m_nFrameCount / spriteList[n].m_fTime, 50, 1, null);
                        }

                        if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && (showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.ANIMATION))
                        {
                            spriteList[n].m_nNextSpriteIndex = EditorGUILayout.Popup("m_nNextSpriteIndex", spriteList[n].m_nNextSpriteIndex + 1, GetSpriteNodeNames()) - 1;
                            if (0 <= spriteList[n].m_nNextSpriteIndex)
                            {
                                spriteList[n].m_nTestMode  = EditorGUILayout.Popup("m_nTestMode", spriteList[n].m_nTestMode, NgConvert.ContentsToStrings(FxmTestControls.GetHcEffectControls_Trans(FxmTestControls.AXIS.Z)), GUILayout.MaxWidth(Screen.width));
                                spriteList[n].m_fTestSpeed = EditorGUILayout.FloatField("m_fTestSpeed", spriteList[n].m_fTestSpeed);

                                SetMinValue(ref spriteList[n].m_fTestSpeed, 0.01f);
                            }
                        }

                        if (showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.EFFECT)
                        {
                            EditorGUILayout.Separator();
                            // char effect -------------------------------------------------------------
                            spriteList[n].m_EffectPrefab = (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_EffectPrefab"), spriteList[n].m_EffectPrefab, typeof(GameObject), false, null);

                            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight * 0.7f));
                            {
                                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("SelEffect"), (m_FxmPopupManager != null)))
                                {
                                    m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, n, 0, true);
                                }
                                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("ClearEffect"), (spriteList[n].m_EffectPrefab != null)))
                                {
                                    bClickButton = true;
                                    spriteList[n].m_EffectPrefab = null;
                                }
                                GUILayout.Label("");
                            }
                            EditorGUILayout.EndHorizontal();

                            if (spriteList[n].m_EffectPrefab != null)
                            {
                                if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation)
                                {
                                    spriteList[n].m_nEffectFrame = EditorGUILayout.IntSlider(GetHelpContent("m_nEffectFrame"), spriteList[n].m_nEffectFrame, 0, spriteList[n].m_nFrameCount, null);

                                    rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                                    {
                                        GUILayout.Label("", GUILayout.Width(nLineHeight));
                                        GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 0, 2), "bOnlyFirst,bEffDetach");
                                        spriteList[n].m_bEffectOnlyFirst = EditorGUI.Toggle(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 2, 1), spriteList[n].m_bEffectOnlyFirst);
                                        spriteList[n].m_bEffectDetach    = EditorGUI.Toggle(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 3, 1), spriteList[n].m_bEffectDetach);
                                    }
                                    EditorGUILayout.EndHorizontal();
                                }
                                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                                {
                                    GUILayout.Label("", GUILayout.Width(nLineHeight));
                                    GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 0, 2), "fSpeed, fScale");
                                    spriteList[n].m_fEffectSpeed = EditorGUI.FloatField(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 2, 1), spriteList[n].m_fEffectSpeed);
                                    spriteList[n].m_fEffectScale = EditorGUI.FloatField(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 3, 1), spriteList[n].m_fEffectScale);
                                }
                                EditorGUILayout.EndHorizontal();

                                spriteList[n].m_EffectPos = EditorGUILayout.Vector3Field("m_EffectPos", spriteList[n].m_EffectPos, null);
                                spriteList[n].m_EffectRot = EditorGUILayout.Vector3Field("m_EffectRot", spriteList[n].m_EffectRot, null);

                                SetMinValue(ref spriteList[n].m_fEffectScale, 0.001f);
                            }

                            EditorGUILayout.Space();

                            // char sound -------------------------------------------------------------
                            spriteList[n].m_AudioClip = (AudioClip)EditorGUILayout.ObjectField(GetHelpContent("m_AudioClip"), spriteList[n].m_AudioClip, typeof(AudioClip), false, null);

                            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight * 0.7f));
                            {
                                //                          if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("SelAudio"), (m_FxmPopupManager != null)))
                                //								m_FxmPopupManager.ShowSelectAudioClipPopup(m_Sel);
                                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("ClearAudio"), (spriteList[n].m_AudioClip != null)))
                                {
                                    bClickButton = true;
                                    spriteList[n].m_AudioClip = null;
                                }
                                GUILayout.Label("");
                            }
                            EditorGUILayout.EndHorizontal();

                            if (spriteList[n].m_AudioClip != null)
                            {
                                if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation)
                                {
                                    spriteList[n].m_nSoundFrame     = EditorGUILayout.IntSlider(GetHelpContent("m_nSoundFrame"), spriteList[n].m_nSoundFrame, 0, spriteList[n].m_nFrameCount, null);
                                    spriteList[n].m_bSoundOnlyFirst = EditorGUILayout.Toggle(GetHelpContent("m_bSoundOnlyFirst"), spriteList[n].m_bSoundOnlyFirst);
                                }
                                spriteList[n].m_bSoundLoop   = EditorGUILayout.Toggle(GetHelpContent("m_bSoundLoop"), spriteList[n].m_bSoundLoop);
                                spriteList[n].m_fSoundVolume = EditorGUILayout.Slider(GetHelpContent("m_fSoundVolume"), spriteList[n].m_fSoundVolume, 0, 1.0f, null);
                                spriteList[n].m_fSoundPitch  = EditorGUILayout.Slider(GetHelpContent("m_fSoundPitch"), spriteList[n].m_fSoundPitch, -3, 3.0f, null);
                            }
                        }
                    }
                }

                if (EditorGUI.EndChangeCheck())
                {
                    nClickIndex = n;
                }

                selTexture = null;
            }

            // Select Node ----------------------------------------------------
            if (0 <= nClickIndex)
            {
                m_Sel.SetSprite(nClickIndex, false);
                if (m_Sel.m_bTestMode && 0 <= spriteList[nClickIndex].m_nTestMode && GetFXMakerMain())
                {
                    GetFXMakerMain().GetFXMakerControls().SetTransIndex(spriteList[nClickIndex].m_nTestMode, (4 <= spriteList[nClickIndex].m_nTestMode ? 1.8f : 1.0f), spriteList[nClickIndex].m_fTestSpeed);
                }
                // Rotate
                if (nClickButton == 1)
                {
                    m_Sel.transform.Rotate(0, 180, 0);
                }
                nClickIndex  = -1;
                bClickButton = true;
            }

            m_UndoManager.CheckDirty();
        }
        // --------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
        {
            OnEditComponent();
        }
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
        {
            m_LastTooltip = GUI.tooltip;
        }
        HelpBox(m_LastTooltip);
    }
	public override void OnInspectorGUI()
	{
		AddScriptNameField(m_Sel);

		int				nClickIndex		= -1;
		int				nClickButton	= 0;
		Rect			rect;
		int				nLeftWidth		= 35;
		int				nAddHeight		= 30;
		int				nDelWidth		= 35;
		int				nLineHeight		= 18;
		int				nSpriteHeight	= nLeftWidth;
		List<NcSpriteFactory.NcSpriteNode>	spriteList = m_Sel.m_SpriteList;

		m_FxmPopupManager = GetFxmPopupManager();

		// --------------------------------------------------------------
		bool bClickButton = false;
		EditorGUI.BeginChangeCheck();
		{
			m_UndoManager.CheckUndo();
			// --------------------------------------------------------------
			m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

			EditorGUILayout.Space();
			m_Sel.m_SpriteType			= (NcSpriteFactory.SPRITE_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_SpriteType"), m_Sel.m_SpriteType);

			// --------------------------------------------------------------
			if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && m_Sel.gameObject.GetComponent("NcSpriteAnimation") == null)
			{
				rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
				{
					if (FXMakerLayout.GUIButton(rect, GetHelpContent("Add NcSpriteAnimation Component"), true))
						m_Sel.gameObject.AddComponent("NcSpriteAnimation");
					GUILayout.Label("");
				}
				EditorGUILayout.EndHorizontal();
			}
			// --------------------------------------------------------------
			if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteTexture && m_Sel.gameObject.GetComponent("NcSpriteTexture") == null)
			{
				rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
				{
					if (FXMakerLayout.GUIButton(rect, GetHelpContent("Add NcSpriteTexture Component"), true))
						m_Sel.gameObject.AddComponent("NcSpriteTexture");
					GUILayout.Label("");
				}
				EditorGUILayout.EndHorizontal();
			}
			EditorGUILayout.Space();

			// --------------------------------------------------------------
			int nSelIndex				= EditorGUILayout.IntSlider(GetHelpContent("m_nCurrentIndex")				, m_Sel.m_nCurrentIndex, 0, (spriteList==null ? 0 : spriteList.Count));
			if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteTexture)
			{
				m_Sel.m_fUvScale		= EditorGUILayout.FloatField(GetHelpContent("m_fUvScale")					, m_Sel.m_fUvScale);
			}
			m_Sel.m_nMaxAtlasTextureSize= EditorGUILayout.IntPopup("nMaxAtlasTextureSize", m_Sel.m_nMaxAtlasTextureSize, NgEnum.m_TextureSizeStrings, NgEnum.m_TextureSizeIntters);
// 			m_Sel.m_AtlasMaterial		= (Material)EditorGUILayout.ObjectField(GetHelpContent("m_AtlasMaterial")	, m_Sel.m_AtlasMaterial, typeof(Material), false);

			if (m_Sel.m_nCurrentIndex != nSelIndex)
			{
				m_Sel.m_nCurrentIndex = nSelIndex;
				m_Sel.SetSprite(nSelIndex, false);
			}

			// check

			// Add Button ------------------------------------------------------
			EditorGUILayout.Space();
			rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nAddHeight*2));
			{
				Rect lineRect = FXMakerLayout.GetInnerVerticalRect(rect, 2, 0, 1);
				if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 0, 1), GetHelpContent("Add Sprite")))
				{
					bClickButton	= true;
					m_Sel.AddSpriteNode();
				}
				if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 1, 1), GetHelpContent("Build Sprite")))
				{
					bClickButton	= true;
					BuildSpriteAtlas(m_Sel.renderer.sharedMaterial);
				}
				if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 2, 1), GetHelpContent("Clear All"), (0 < m_Sel.GetSpriteNodeCount())))
				{
					bClickButton	= true;
					if (m_FxmPopupManager != null)
						m_FxmPopupManager.CloseNcPrefabPopup();
					m_Sel.ClearAllSpriteNode();
				}
				lineRect = FXMakerLayout.GetInnerVerticalRect(rect, 2, 1, 1);
				if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 0, 1), GetHelpContent("Sequence"), (0 < m_Sel.GetSpriteNodeCount())))
				{
					m_Sel.m_bSequenceMode	= true;
					bClickButton			= true;
					m_Sel.SetSprite(0, false);
				}
				if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 1, 1), GetHelpContent("NewMaterial"), true))
				{
					Material	newMat		= new Material(m_Sel.renderer.sharedMaterial);
					string		matPath		= AssetDatabase.GetAssetPath(m_Sel.renderer.sharedMaterial);
					NgMaterial.SaveMaterial(newMat, NgFile.TrimFilenameExt(matPath), m_Sel.name); 
					m_Sel.renderer.sharedMaterial = newMat;
// 					m_Sel.renderer.sharedMaterial = (Material)AssetDatabase.LoadAssetAtPath(savePath, typeof(Material));
				}

 				GUILayout.Label("");
			}
			EditorGUILayout.EndHorizontal();

			// Select ShotType -------------------------------------------------
//			showType		= (NcSpriteFactory.SHOW_TYPE)EditorGUILayout.EnumPopup		(GetHelpContent("m_ShowType")	, showType);
			// --------------------------------------------------------------
			EditorGUILayout.Space();
			NcSpriteFactory.SHOW_TYPE showType = (NcSpriteFactory.SHOW_TYPE)EditorPrefs.GetInt("NcSpriteFactory.SHOW_TYPE", 0);
	
			rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
			{
				showType	= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 0, 1), showType==NcSpriteFactory.SHOW_TYPE.NONE		, GetHelpContent("NONE")		, true) ? NcSpriteFactory.SHOW_TYPE.NONE	: showType;
				showType	= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 1, 1), showType==NcSpriteFactory.SHOW_TYPE.ALL		, GetHelpContent("ALL")			, true) ? NcSpriteFactory.SHOW_TYPE.ALL		: showType;
				if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation)
				{
					showType= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 2, 1), showType==NcSpriteFactory.SHOW_TYPE.SPRITE	, GetHelpContent("SPRITE")		, true) ? NcSpriteFactory.SHOW_TYPE.SPRITE		: showType;
					showType= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 3, 1), showType==NcSpriteFactory.SHOW_TYPE.ANIMATION, GetHelpContent("ANIMATION")	, true) ? NcSpriteFactory.SHOW_TYPE.ANIMATION	: showType;
				}
				showType	= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 4, 1), showType==NcSpriteFactory.SHOW_TYPE.EFFECT	, GetHelpContent("EFFECT")		, true) ? NcSpriteFactory.SHOW_TYPE.EFFECT		: showType;
				GUILayout.Label("");
			}
			EditorGUILayout.EndHorizontal();

			EditorPrefs.SetInt("NcSpriteFactory.SHOW_TYPE", ((int)showType));

			// Show Option -------------------------------------------------
			EditorGUILayout.Space();
			rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
			{
				m_Sel.m_bShowEffect			= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 0, 1), m_Sel.m_bShowEffect	, GetHelpContent("m_bShowEffect")	, true);
				if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation)
				{
					m_Sel.m_bTestMode		= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 1, 1), m_Sel.m_bTestMode		, GetHelpContent("m_bTestMode")		, true);
					m_Sel.m_bSequenceMode	= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 2, 1), m_Sel.m_bSequenceMode	, GetHelpContent("m_bSequenceMode")	, true);
				}
				GUILayout.Label("");
			}
			EditorGUILayout.EndHorizontal();

			// Node List ------------------------------------------------------
			for (int n = 0; n < (spriteList != null ? spriteList.Count : 0); n++)
			{
				EditorGUILayout.Space();

				EditorGUI.BeginChangeCheck();
				// Load Texture ---------------------------------------------------------
				Texture2D	selTexture = null;
				if (spriteList[n].m_TextureGUID != "")
					selTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(spriteList[n].m_TextureGUID), typeof(Texture2D));

				// Enabled --------------------------------------------------------------
				rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
				{
					Rect subRect;
					// enable
					spriteList[n].m_bIncludedAtlas = GUILayout.Toggle(spriteList[n].m_bIncludedAtlas, "Idx", GUILayout.Width(nLeftWidth));
					// change index
					subRect = rect;
					subRect.x += nLeftWidth;
					subRect.width = nLineHeight*2;
					int newPos = EditorGUI.IntPopup(subRect, n, NgConvert.GetIntStrings(0, spriteList.Count), NgConvert.GetIntegers(0, spriteList.Count));
					if (newPos != n)
					{
						NcSpriteFactory.NcSpriteNode node = spriteList[n];
						m_Sel.m_SpriteList.Remove(node);
						m_Sel.m_SpriteList.Insert(newPos, node);
						return;
					}

					// name
					subRect = rect;
					subRect.x += nLeftWidth+nLineHeight*2;
					subRect.width -= nLeftWidth+nLineHeight*2;
 					spriteList[n].m_TextureName = selTexture==null ? "" : selTexture.name;
 					GUI.Label(subRect, (selTexture==null ? "" : "(" + spriteList[n].m_nFrameCount + ") " + selTexture.name));
					GUI.Box(subRect, "");
					GUI.Box(rect, "");

					// delete
					if (GUI.Button(new Rect(subRect.x+subRect.width-nDelWidth, subRect.y, nDelWidth, subRect.height), GetHelpContent("Del")))
					{
						bClickButton	= true;
						if (m_FxmPopupManager != null)
							m_FxmPopupManager.CloseNcPrefabPopup();
						m_Sel.DeleteSpriteNode(n);
						return;
					}
				}
				EditorGUILayout.EndHorizontal();

				// MaxAlpha -------------------------------------------------------------
				spriteList[n].m_fMaxTextureAlpha = EditorGUILayout.FloatField(GetHelpContent("m_fMaxTextureAlpha"), spriteList[n].m_fMaxTextureAlpha);

				// Texture --------------------------------------------------------------
				rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nSpriteHeight));
				{
					GUILayout.Label("", GUILayout.Width(nLeftWidth));

					Rect subRect = rect;
					subRect.width = nLeftWidth;
					FXMakerLayout.GetOffsetRect(rect, 0, 5, 0, -5);
					EditorGUI.BeginChangeCheck();
					selTexture	= (Texture2D)EditorGUI.ObjectField(subRect, GetHelpContent(""), selTexture, typeof(Texture2D), false);
					if (EditorGUI.EndChangeCheck())
					{
						if (selTexture != null)
							spriteList[n].m_TextureGUID	= AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(selTexture));
					}
					if (selTexture != null)
					{
						if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation)
						{
							spriteList[n].m_nFrameCount = selTexture.width / selTexture.height;
							spriteList[n].m_nFrameSize	= selTexture.height;
							m_Sel.m_nFrameSize = spriteList[n].m_nFrameSize;
						} else {
							spriteList[n].m_nFrameCount = 1;
							spriteList[n].m_nFrameSize	= 1;
							m_Sel.m_nFrameSize = 1;
						}
					}

					// draw texture
					subRect = FXMakerLayout.GetOffsetRect(rect, nLeftWidth+4, 0, 0, -4);
					if (selTexture != null)
						GUI.DrawTexture(FXMakerLayout.GetOffsetRect(subRect, 0, 0, -nDelWidth, 0), selTexture, ScaleMode.ScaleToFit, true, selTexture.width/selTexture.height);

					// delete
					if (GUI.Button(new Rect(subRect.x+subRect.width-nDelWidth, subRect.y, nDelWidth, subRect.height), GetHelpContent("Rmv")))
					{
						spriteList[n].m_TextureGUID	= "";
						spriteList[n].m_nFrameCount = 0;
						spriteList[n].m_nFrameSize	= 0;
					}
					GUI.Box(rect, "");
				}
				EditorGUILayout.EndHorizontal();

				// Change selIndex
				Event e = Event.current;
				if (e.type == EventType.MouseDown)
					if (rect.Contains(e.mousePosition))
					{
						nClickIndex = n;
						nClickButton = e.button;
					}

				// SpriteNode ----------------------------------------------------------
				if (bClickButton == false)
				{
					if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.SPRITE)
					{
						spriteList[n].m_bLoop			= EditorGUILayout.Toggle	(GetHelpContent("m_bLoop")	, spriteList[n].m_bLoop);
						spriteList[n].m_fTime			= EditorGUILayout.Slider	(GetHelpContent("m_fTime")	, spriteList[n].m_nFrameCount/spriteList[n].m_fFps, 0, 5, null);
						spriteList[n].m_fFps			= EditorGUILayout.Slider	(GetHelpContent("m_fFps")	, spriteList[n].m_nFrameCount/spriteList[n].m_fTime, 50, 1, null);
					}

					if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.ANIMATION)
					{
						spriteList[n].m_nNextSpriteIndex= EditorGUILayout.Popup			("m_nNextSpriteIndex"	, spriteList[n].m_nNextSpriteIndex+1, GetSpriteNodeNames()) - 1;
						spriteList[n].m_nTestMode		= EditorGUILayout.Popup			("m_nTestMode"			, spriteList[n].m_nTestMode, NgConvert.ContentsToStrings(FxmTestControls.GetHcEffectControls_Trans(FxmTestControls.AXIS.Z)), GUILayout.MaxWidth(Screen.width));
						spriteList[n].m_fTestSpeed		= EditorGUILayout.FloatField	("m_fTestSpeed"			, spriteList[n].m_fTestSpeed);

						SetMinValue(ref spriteList[n].m_fTestSpeed, 0.01f);
						SetMinValue(ref spriteList[n].m_fTestSpeed, 0.01f);
					}

					if (showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.EFFECT)
					{
						// char effect -------------------------------------------------------------
						spriteList[n].m_EffectPrefab	= (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_EffectPrefab")	, spriteList[n].m_EffectPrefab, typeof(GameObject), false, null);

						rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight*0.7f));
						{
							if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("SelEffect"), (m_FxmPopupManager != null)))
								m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, n, 0, true);
							if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("ClearEffect"), (spriteList[n].m_EffectPrefab != null)))
							{
								bClickButton = true;
								spriteList[n].m_EffectPrefab = null;
							}
							GUILayout.Label("");
						}
						EditorGUILayout.EndHorizontal();

						if (spriteList[n].m_EffectPrefab != null)
						{
							if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation)
							{
								spriteList[n].m_nEffectFrame	= EditorGUILayout.IntSlider		(GetHelpContent("m_nEffectFrame")		, spriteList[n].m_nEffectFrame, 0, spriteList[n].m_nFrameCount, null);
								spriteList[n].m_bEffectOnlyFirst= EditorGUILayout.Toggle		(GetHelpContent("m_bEffectOnlyFirst")	, spriteList[n].m_bEffectOnlyFirst);
							}
							spriteList[n].m_fEffectSpeed		= EditorGUILayout.FloatField	("m_fEffectSpeed"		, spriteList[n].m_fEffectSpeed);
							spriteList[n].m_fEffectScale		= EditorGUILayout.FloatField	("m_fEffectScale"		, spriteList[n].m_fEffectScale);
							spriteList[n].m_EffectPos			= EditorGUILayout.Vector3Field	("m_EffectPos"			, spriteList[n].m_EffectPos, null);
							spriteList[n].m_EffectRot			= EditorGUILayout.Vector3Field	("m_EffectRot"			, spriteList[n].m_EffectRot, null);

							SetMinValue(ref spriteList[n].m_fEffectScale, 0.001f);
						}

						EditorGUILayout.Space();

						// char sound -------------------------------------------------------------
						spriteList[n].m_AudioClip		= (AudioClip)EditorGUILayout.ObjectField(GetHelpContent("m_AudioClip")		, spriteList[n].m_AudioClip, typeof(AudioClip), false, null);

						rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight*0.7f));
						{
// 							if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("SelAudio"), (m_FxmPopupManager != null)))
//								m_FxmPopupManager.ShowSelectAudioClipPopup(m_Sel);
							if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("ClearAudio"), (spriteList[n].m_AudioClip != null)))
							{
								bClickButton = true;
								spriteList[n].m_AudioClip = null;
							}
							GUILayout.Label("");
						}
						EditorGUILayout.EndHorizontal();

						if (spriteList[n].m_AudioClip != null)
						{
							if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation)
							{
								spriteList[n].m_nSoundFrame		= EditorGUILayout.IntSlider	(GetHelpContent("m_nSoundFrame")		, spriteList[n].m_nSoundFrame, 0, spriteList[n].m_nFrameCount, null);
								spriteList[n].m_bSoundOnlyFirst	= EditorGUILayout.Toggle	(GetHelpContent("m_bSoundOnlyFirst")	, spriteList[n].m_bSoundOnlyFirst);
							}
							spriteList[n].m_bSoundLoop			= EditorGUILayout.Toggle	(GetHelpContent("m_bSoundLoop")			, spriteList[n].m_bSoundLoop);
							spriteList[n].m_fSoundVolume		= EditorGUILayout.Slider	(GetHelpContent("m_fSoundVolume")		, spriteList[n].m_fSoundVolume, 0, 1.0f, null);
							spriteList[n].m_fSoundPitch			= EditorGUILayout.Slider	(GetHelpContent("m_fSoundPitch")		, spriteList[n].m_fSoundPitch, -3, 3.0f, null);
						}
					}
				}

				if (EditorGUI.EndChangeCheck())
					nClickIndex = n;

				selTexture = null;
			}

			// Select Node ----------------------------------------------------
			if (0 <= nClickIndex)
			{
				m_Sel.SetSprite(nClickIndex, false);
				if (m_Sel.m_bTestMode && 0 <= spriteList[nClickIndex].m_nTestMode && GetFXMakerMain())
					GetFXMakerMain().GetFXMakerControls().SetTransIndex(spriteList[nClickIndex].m_nTestMode, (4 <= spriteList[nClickIndex].m_nTestMode ? 1.8f : 1.0f), spriteList[nClickIndex].m_fTestSpeed);
				// Rotate
				if (nClickButton == 1)
					m_Sel.transform.Rotate(0, 180, 0);
				nClickIndex		= -1;
				bClickButton	= true;
			}

			m_UndoManager.CheckDirty();
		}
		// --------------------------------------------------------------
		if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
			GetFXMakerMain().CreateCurrentInstanceEffect(true);
		// ---------------------------------------------------------------------
		if (GUI.tooltip != "")
			m_LastTooltip	= GUI.tooltip;
		HelpBox(m_LastTooltip);
	}
예제 #4
0
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);
        m_UndoManager.CheckUndo();

        m_FxmPopupManager = GetFxmPopupManager();

        bool bClickButton	= false;
        EditorGUI.BeginChangeCheck();
        {
            m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

            m_Sel.m_fStartDelayTime				= EditorGUILayout.FloatField(GetHelpContent("m_fStartDelayTime")				, m_Sel.m_fStartDelayTime);
            m_Sel.m_bBurst						= EditorGUILayout.Toggle(GetHelpContent("m_bBurst")								, m_Sel.m_bBurst);
            if (m_Sel.m_bBurst)
            {
                m_Sel.m_fBurstRepeatTime		= EditorGUILayout.FloatField(GetHelpContent("m_fBurstRepeatTime")				, m_Sel.m_fBurstRepeatTime);
                m_Sel.m_nBurstRepeatCount		= EditorGUILayout.IntField	(GetHelpContent("m_nBurstRepeatCount")				, m_Sel.m_nBurstRepeatCount);
                m_Sel.m_fBurstEmissionCount		= EditorGUILayout.IntField  (GetHelpContent("m_fBurstEmissionCount")			, m_Sel.m_fBurstEmissionCount);
                SetMinValue(ref m_Sel.m_fBurstRepeatTime, 0.1f);
            } else {
                m_Sel.m_fEmitTime				= EditorGUILayout.FloatField(GetHelpContent("m_fEmitTime")						, m_Sel.m_fEmitTime);
                m_Sel.m_fSleepTime				= EditorGUILayout.FloatField(GetHelpContent("m_fSleepTime")						, m_Sel.m_fSleepTime);
            }

            m_Sel.m_bScaleWithTransform			= EditorGUILayout.Toggle	(GetHelpContent("m_bScaleWithTransform")			, m_Sel.m_bScaleWithTransform);
            // --------------------------------------------------------------------------------------------------------------------------------------------
            if (m_Sel.particleEmitter != null && m_Sel.m_bScaleWithTransform && m_Sel.transform.lossyScale != Vector3.one)
            {
                Rect butRect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
                {
                    if (FXMakerLayout.GUIButton(butRect, GetHelpContent("Convert To Static Scale"), true))
                    {
                        ConvertToStaticScale(m_Sel.particleEmitter, m_Sel.GetComponent<ParticleAnimator>());
                        m_Sel.m_bScaleWithTransform	= false;
                        return;
                    }
                    GUILayout.Label("");
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
            }

            // --------------------------------------------------------------------------------------------------------------------------------------------
            bool	bWorldSpace					= EditorGUILayout.Toggle	(GetHelpContent("m_bWorldSpace")					, m_Sel.m_bWorldSpace);
            // Set bWorldSpace
            if (m_Sel.m_bWorldSpace != bWorldSpace)
            {
                m_Sel.m_bWorldSpace	= bWorldSpace;
         				NgSerialized.SetSimulationSpaceWorld(m_Sel.transform, bWorldSpace);
            }
         			// Update bWorldSpace
         			if (m_Sel.m_bWorldSpace != NgSerialized.GetSimulationSpaceWorld(m_Sel.transform))
         				m_Sel.m_bWorldSpace	= !m_Sel.m_bWorldSpace;
            // --------------------------------------------------------------------------------------------------------------------------------------------

            m_Sel.m_fStartSizeRate				= EditorGUILayout.FloatField(GetHelpContent("m_fStartSizeRate")					, m_Sel.m_fStartSizeRate);
            m_Sel.m_fStartLifeTimeRate			= EditorGUILayout.FloatField(GetHelpContent("m_fStartLifeTimeRate")				, m_Sel.m_fStartLifeTimeRate);
            m_Sel.m_fStartEmissionRate			= EditorGUILayout.FloatField(GetHelpContent("m_fStartEmissionRate")				, m_Sel.m_fStartEmissionRate);
            m_Sel.m_fStartSpeedRate				= EditorGUILayout.FloatField(GetHelpContent("m_fStartSpeedRate")				, m_Sel.m_fStartSpeedRate);
            m_Sel.m_fRenderLengthRate			= EditorGUILayout.FloatField(GetHelpContent("m_fRenderLengthRate")				, m_Sel.m_fRenderLengthRate);

            if (m_Sel.particleEmitter != null && NgSerialized.IsMeshParticleEmitter(m_Sel.particleEmitter))
            {
                m_Sel.m_fLegacyMinMeshNormalVelocity= EditorGUILayout.FloatField(GetHelpContent("m_fLegacyMinMeshNormalVelocity")	, m_Sel.m_fLegacyMinMeshNormalVelocity);
                m_Sel.m_fLegacyMaxMeshNormalVelocity= EditorGUILayout.FloatField(GetHelpContent("m_fLegacyMaxMeshNormalVelocity")	, m_Sel.m_fLegacyMaxMeshNormalVelocity);
            }

            if (m_Sel.particleSystem != null)
            {
                float	fShurikenSpeedRate		= EditorGUILayout.FloatField(GetHelpContent("m_fShurikenSpeedRate")				, m_Sel.m_fShurikenSpeedRate);
                // Set particleSystem.speed
                if (m_Sel.m_fShurikenSpeedRate != fShurikenSpeedRate)
                {
                    m_Sel.m_fShurikenSpeedRate = fShurikenSpeedRate;
                    m_Sel.SaveShurikenSpeed();
                }
            }

            // m_ParticleDestruct
            m_Sel.m_ParticleDestruct			= (NcParticleSystem.ParticleDestruct)EditorGUILayout.EnumPopup(GetHelpContent("m_ParticleDestruct"), m_Sel.m_ParticleDestruct, GUILayout.MaxWidth(Screen.width));
            if (m_Sel.m_ParticleDestruct != NcParticleSystem.ParticleDestruct.NONE)
            {
                if (m_Sel.m_ParticleDestruct == NcParticleSystem.ParticleDestruct.COLLISION)
                {
                    m_Sel.m_CollisionLayer		= LayerMaskField				(GetHelpContent("m_CollisionLayer")				, m_Sel.m_CollisionLayer);
                    m_Sel.m_fCollisionRadius	= EditorGUILayout.FloatField	(GetHelpContent("m_fCollisionRadius")			, m_Sel.m_fCollisionRadius);
                }
                if (m_Sel.m_ParticleDestruct == NcParticleSystem.ParticleDestruct.WORLD_Y)
                {
                    m_Sel.m_fDestructPosY		= EditorGUILayout.FloatField	(GetHelpContent("m_fDestructPosY")				, m_Sel.m_fDestructPosY);
                }
                m_Sel.m_AttachPrefab			= (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_AttachPrefab")		, m_Sel.m_AttachPrefab, typeof(GameObject), false, null);
                m_Sel.m_fPrefabScale			= EditorGUILayout.FloatField	(GetHelpContent("m_fPrefabScale")				, m_Sel.m_fPrefabScale);
                m_Sel.m_fPrefabSpeed			= EditorGUILayout.FloatField	(GetHelpContent("m_fPrefabSpeed")				, m_Sel.m_fPrefabSpeed);
                m_Sel.m_fPrefabLifeTime			= EditorGUILayout.FloatField	(GetHelpContent("m_fPrefabLifeTime")			, m_Sel.m_fPrefabLifeTime);

                SetMinValue(ref m_Sel.m_fCollisionRadius, 0.01f);
                SetMinValue(ref m_Sel.m_fPrefabScale, 0.01f);
                SetMinValue(ref m_Sel.m_fPrefabSpeed, 0.01f);
                SetMinValue(ref m_Sel.m_fPrefabLifeTime, 0);

                // --------------------------------------------------------------
                EditorGUILayout.Space();
                Rect attRect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
                {
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(attRect, 3, 0, 1), GetHelpContent("Select Prefab"), (m_FxmPopupManager != null)))
                        m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, true, 0);
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(attRect, 3, 1, 1), GetHelpContent("Clear Prefab"), (m_Sel.m_AttachPrefab != null)))
                    {
                        bClickButton = true;
                        m_Sel.m_AttachPrefab = null;
                    }
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(attRect, 3, 2, 1), GetHelpContent("Open Prefab"), (m_FxmPopupManager != null) && (m_Sel.m_AttachPrefab != null)))
                    {
                        bClickButton = true;
                        GetFXMakerMain().OpenPrefab(m_Sel.m_AttachPrefab);
                        return;
                    }
                    GUILayout.Label("");
                }
                EditorGUILayout.EndHorizontal();
            }

            // ---------------------------------------------------------------------
            // current ParticleSystem
            EditorGUILayout.Space();
            Component	currentParticle = null;
            Rect		rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight * 3));
            {
                if ((currentParticle = m_Sel.gameObject.GetComponent<ParticleSystem>()) != null)
                {
                    ParticleSystemRenderer	psr = m_Sel.gameObject.GetComponent<ParticleSystemRenderer>();
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 0, 2), GetHelpContent("Delete Shuriken Components"), true))
                    {
                        bClickButton = true;
                        Object.DestroyImmediate(currentParticle);
                        if (psr != null)
                            Object.DestroyImmediate(psr);
                    }
                    if (psr == null)
                    {
             			FXMakerLayout.GUIColorBackup(FXMakerLayout.m_ColorHelpBox);
                        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 2, 1), GetHelpContent("Add ParticleSystemRenderer"), true))
                        {
                            bClickButton = true;
                            m_Sel.gameObject.AddComponent<ParticleSystemRenderer>();
                        }
         						FXMakerLayout.GUIColorRestore();
                    } else FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 2, 1),"ParticleSystemRenderer", false);
                } else {
                    if ((currentParticle = m_Sel.gameObject.GetComponent<ParticleEmitter>()) != null)
                    {
                        ParticleAnimator	pa = m_Sel.gameObject.GetComponent<ParticleAnimator>();
                        ParticleRenderer	pr = m_Sel.gameObject.GetComponent<ParticleRenderer>();

                        if (currentParticle.ToString().Contains("EllipsoidParticleEmitter"))
                        {
                            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 0, 1), GetHelpContent("Delete Legacy(Ellipsoid) Components"), true))
                            {
                                bClickButton = true;
                                Object.DestroyImmediate(currentParticle);
                                if (pa != null)	Object.DestroyImmediate(pa);
                                if (pr != null)	Object.DestroyImmediate(pr);
                            }
                        } else {
                            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 0, 1), GetHelpContent("Delete Legacy(Mesh) Components"), true))
                            {
                                bClickButton = true;
                                Object.DestroyImmediate(currentParticle);
                                if (pa != null)	Object.DestroyImmediate(pa);
                                if (pr != null)	Object.DestroyImmediate(pr);
                            }
                        }

                        if (pa == null)
                        {
             				FXMakerLayout.GUIColorBackup(FXMakerLayout.m_ColorHelpBox);
                            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 1, 1), GetHelpContent("Add ParticleAnimator"), true))
                            {
                                bClickButton = true;
                                m_Sel.gameObject.AddComponent<ParticleAnimator>();
                            }
         							FXMakerLayout.GUIColorRestore();
                        } else FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 1, 1),"ParticleAnimator", false);
                        if (pr == null)
                        {
             				FXMakerLayout.GUIColorBackup(FXMakerLayout.m_ColorHelpBox);
                            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 2, 1), GetHelpContent("Add ParticleRenderer"), true))
                            {
                                bClickButton = true;
                                m_Sel.gameObject.AddComponent<ParticleRenderer>();
                            }
         							FXMakerLayout.GUIColorRestore();
                        } else FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 2, 1),"ParticleRenderer", false);
                    }
                }

                // ---------------------------------------------------------------------
                // Create ParticleSystem
                if (currentParticle == null)
                {
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 0, 1), GetHelpContent("Add Shuriken Components"), true))
                    {
                        bClickButton = true;
                        m_Sel.gameObject.AddComponent("ParticleSystem");
                        if (m_Sel.gameObject.GetComponent<ParticleSystemRenderer>() == null)
                            m_Sel.gameObject.AddComponent("ParticleSystemRenderer");
                    }
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 1, 1), GetHelpContent("Add Legacy(Ellipsoid) Components"), true))
                    {
                        bClickButton = true;
                        m_Sel.gameObject.AddComponent("EllipsoidParticleEmitter");
                        if (m_Sel.gameObject.GetComponent<ParticleAnimator>() == null)
                            m_Sel.gameObject.AddComponent("ParticleAnimator");
                        if (m_Sel.gameObject.GetComponent<ParticleRenderer>() == null)
                            m_Sel.gameObject.AddComponent("ParticleRenderer");
                    }
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 2, 1), GetHelpContent("Add Legacy(Mesh) Components"), true))
                    {
                        bClickButton = true;
                        m_Sel.gameObject.AddComponent("MeshParticleEmitter");
                        if (m_Sel.gameObject.GetComponent<ParticleAnimator>() == null)
                            m_Sel.gameObject.AddComponent("ParticleAnimator");
                        if (m_Sel.gameObject.GetComponent<ParticleRenderer>() == null)
                            m_Sel.gameObject.AddComponent("ParticleRenderer");
                    }
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();
        }
        m_UndoManager.CheckDirty();
        // ---------------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
            OnEditComponent();
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
            m_LastTooltip	= GUI.tooltip;
        HelpBox(m_LastTooltip);
    }
예제 #5
0
    public override void OnInspectorGUI()
    {
        Rect rect;

        AddScriptNameField(m_Sel);
        m_UndoManager.CheckUndo();
        m_FxmPopupManager = GetFxmPopupManager();

//		test code
//      if (GUILayout.Button("Pause"))
//          FxmInfoIndexing.FindInstanceIndexing(m_Sel.transform, false).GetComponent<NcSpriteAnimation>().PauseAnimation();
//      if (GUILayout.Button("Resume"))
//          FxmInfoIndexing.FindInstanceIndexing(m_Sel.transform, false).GetComponent<NcSpriteAnimation>().ResumeAnimation();

        // --------------------------------------------------------------
        bool bClickButton = false;

        EditorGUI.BeginChangeCheck();
        {
//			DrawDefaultInspector();
            m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

            m_Sel.m_TextureType = (NcSpriteAnimation.TEXTURE_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_TextureType"), m_Sel.m_TextureType);

            EditorGUILayout.Space();

            if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.TileTexture)
            {
                if (GUILayout.Button(GetHelpContent("ConvertTo : TrimTexture")))
                {
                    m_Sel.m_NcSpriteFrameInfos = NgAtlas.TileToTrimTexture(m_Sel.renderer.sharedMaterial, m_Sel.m_nTilingX, m_Sel.m_nTilingY, 0, m_Sel.m_nFrameCount, 4096);
                    if (m_Sel.m_NcSpriteFrameInfos != null)
                    {
                        m_Sel.m_TextureType = NcSpriteAnimation.TEXTURE_TYPE.TrimTexture;
                    }
                }
                if (GUILayout.Button(GetHelpContent("ExportTo : SplitTexture")))
                {
                    string path = FXMakerCapture.GetExportSlitDir();
                    path = NgAtlas.ExportSplitTexture(path, m_Sel.renderer.sharedMaterial.mainTexture, m_Sel.m_nTilingX, m_Sel.m_nTilingY, 0, m_Sel.m_nFrameCount);
                    if (path != "")
                    {
                        Debug.Log(path);
                        EditorUtility.OpenWithDefaultApp(path);
                    }
                }
            }
            else
            if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.TrimTexture)
            {
                if (GUILayout.Button(GetHelpContent("ExportTo : SplitTexture")))
                {
                    string path = FXMakerCapture.GetExportSlitDir();
                    path = NgAtlas.ExportSplitTexture(path, m_Sel.renderer.sharedMaterial.mainTexture, m_Sel.m_NcSpriteFrameInfos);
                    if (path != "")
                    {
                        Debug.Log(path);
                        EditorUtility.OpenWithDefaultApp(path);
                    }
                }
            }
            else
            if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.SpriteFactory)
            {
            }
            EditorGUILayout.Space();

            if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.TileTexture)
            {
                m_Sel.m_nTilingX = EditorGUILayout.IntField(GetHelpContent("m_nTilingX"), m_Sel.m_nTilingX);
                m_Sel.m_nTilingY = EditorGUILayout.IntField(GetHelpContent("m_nTilingY"), m_Sel.m_nTilingY);
            }
            else
            if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.TrimTexture)
            {
                m_Sel.m_MeshType         = (NcSpriteFactory.MESH_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_MeshType"), m_Sel.m_MeshType);
                m_Sel.m_AlignType        = (NcSpriteFactory.ALIGN_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_AlignType"), m_Sel.m_AlignType);
                m_Sel.m_bTrimCenterAlign = EditorGUILayout.Toggle("m_bTrimCenterAlign", m_Sel.m_bTrimCenterAlign);
            }
            else
            if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.SpriteFactory)
            {
                m_Sel.m_NcSpriteFactoryPrefab = (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_NcSpriteFactoryPrefab"), m_Sel.m_NcSpriteFactoryPrefab, typeof(GameObject), false, null);
                // --------------------------------------------------------------
                EditorGUILayout.Space();
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
                {
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("Select SpriteFactory"), (m_FxmPopupManager != null)))
                    {
                        m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, true, 0);
                    }
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("Clear SpriteFactory"), (m_Sel.m_NcSpriteFactoryPrefab != null)))
                    {
                        bClickButton = true;
                        m_Sel.m_NcSpriteFactoryPrefab = null;
                    }
                    GUILayout.Label("");
                }
                EditorGUILayout.EndHorizontal();

                // --------------------------------------------------------------
                if (m_Sel.m_NcSpriteFactoryPrefab != null && m_Sel.m_NcSpriteFactoryPrefab.renderer != null && m_Sel.renderer)
                {
                    if (m_Sel.m_NcSpriteFactoryPrefab.renderer.sharedMaterial != m_Sel.renderer.sharedMaterial)
                    {
                        m_Sel.UpdateFactoryMaterial();
                    }
                }

                // --------------------------------------------------------------
                NcSpriteFactory ncSpriteFactory = (m_Sel.m_NcSpriteFactoryPrefab == null ? null : m_Sel.m_NcSpriteFactoryPrefab.GetComponent <NcSpriteFactory>());
                if (ncSpriteFactory != null)
                {
                    int nSelIndex = EditorGUILayout.IntSlider(GetHelpContent("m_nSpriteFactoryIndex"), m_Sel.m_nSpriteFactoryIndex, 0, ncSpriteFactory.GetSpriteNodeCount() - 1);
                    if (m_Sel.m_nSpriteFactoryIndex != nSelIndex)
                    {
                        m_Sel.SetSpriteFactoryIndex(nSelIndex, false);
                    }
                }

                m_Sel.m_MeshType         = (NcSpriteFactory.MESH_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_MeshType"), m_Sel.m_MeshType);
                m_Sel.m_AlignType        = (NcSpriteFactory.ALIGN_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_AlignType"), m_Sel.m_AlignType);
                m_Sel.m_bTrimCenterAlign = EditorGUILayout.Toggle("m_bTrimCenterAlign", m_Sel.m_bTrimCenterAlign);
            }

            m_Sel.m_PlayMode = (NcSpriteAnimation.PLAYMODE)EditorGUILayout.EnumPopup(GetHelpContent("m_PlayMode"), m_Sel.m_PlayMode, GUILayout.MaxWidth(Screen.width));
            if (m_Sel.m_PlayMode != NcSpriteAnimation.PLAYMODE.SELECT)
            {
                m_Sel.m_fDelayTime = EditorGUILayout.FloatField(GetHelpContent("m_fDelayTime"), m_Sel.m_fDelayTime);
            }

            m_Sel.m_nStartFrame = EditorGUILayout.IntField(GetHelpContent("m_nStartFrame"), m_Sel.m_nStartFrame);
            m_Sel.m_nFrameCount = EditorGUILayout.IntField(GetHelpContent("m_nFrameCount"), m_Sel.m_nFrameCount);

            if (m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.SELECT)
            {
                m_Sel.m_nSelectFrame = EditorGUILayout.IntField(GetHelpContent("m_nSelectFrame"), m_Sel.m_nSelectFrame);
            }

            if (m_Sel.m_PlayMode != NcSpriteAnimation.PLAYMODE.RANDOM && m_Sel.m_PlayMode != NcSpriteAnimation.PLAYMODE.SELECT)
            {
                bool bOldLoop = m_Sel.m_bLoop;
                m_Sel.m_bLoop = EditorGUILayout.Toggle(GetHelpContent("m_bLoop"), m_Sel.m_bLoop);
                if (!bOldLoop && m_Sel.m_bLoop)
                {
                    m_Sel.m_nLoopStartFrame = 0;
                    m_Sel.m_nLoopFrameCount = m_Sel.m_nFrameCount;
                    m_Sel.m_nLoopingCount   = 0;
                }
                if (m_Sel.m_bLoop && m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.DEFAULT)
                {
                    m_Sel.m_nLoopStartFrame = EditorGUILayout.IntField("  nLoopStartFrame", m_Sel.m_nLoopStartFrame);
                    m_Sel.m_nLoopFrameCount = EditorGUILayout.IntField("  nLoopFrameCount", m_Sel.m_nLoopFrameCount);
                    m_Sel.m_nLoopingCount   = EditorGUILayout.IntField("  nLoopingCount", m_Sel.m_nLoopingCount);
                }

                if (m_Sel.m_bLoop == false || 0 < m_Sel.m_nLoopingCount)
                {
                    m_Sel.m_bAutoDestruct = EditorGUILayout.Toggle(GetHelpContent("m_bAutoDestruct"), m_Sel.m_bAutoDestruct);
                }
                m_Sel.m_fFps = EditorGUILayout.FloatField(GetHelpContent("m_fFps"), m_Sel.m_fFps);
            }

            // check
            SetMinValue(ref m_Sel.m_nTilingX, 1);
            SetMinValue(ref m_Sel.m_nTilingY, 1);
            SetMinValue(ref m_Sel.m_fFps, 0.1f);
            SetMinValue(ref m_Sel.m_fDelayTime, 0);
            SetMaxValue(ref m_Sel.m_nStartFrame, m_Sel.GetMaxFrameCount() - 1);
            SetMinValue(ref m_Sel.m_nStartFrame, 0);
            SetMaxValue(ref m_Sel.m_nFrameCount, m_Sel.GetValidFrameCount());
            SetMinValue(ref m_Sel.m_nFrameCount, 1);
            SetMaxValue(ref m_Sel.m_nSelectFrame, (0 < m_Sel.m_nFrameCount ? m_Sel.m_nFrameCount - 1 : m_Sel.m_nTilingX *m_Sel.m_nTilingY - 1));
            SetMinValue(ref m_Sel.m_nSelectFrame, 0);

            SetMaxValue(ref m_Sel.m_nLoopStartFrame, m_Sel.m_nFrameCount - 1);
            SetMinValue(ref m_Sel.m_nLoopStartFrame, 0);
            SetMinValue(ref m_Sel.m_nLoopFrameCount, 0);
            SetMaxValue(ref m_Sel.m_nLoopFrameCount, m_Sel.m_nFrameCount - m_Sel.m_nLoopStartFrame);
            SetMinValue(ref m_Sel.m_nLoopingCount, 0);

            if (m_Sel.m_PlayMode != NcSpriteAnimation.PLAYMODE.RANDOM && m_Sel.m_PlayMode != NcSpriteAnimation.PLAYMODE.SELECT)
            {
                EditorGUILayout.TextField(GetHelpContent("DurationTime"), m_Sel.GetDurationTime().ToString());
            }


            // Texture --------------------------------------------------------------
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(150));
            {
                GUI.Box(rect, "");
                GUILayout.Label("");

                Rect subRect = rect;

                // draw texture
                if (m_Sel.renderer != null && m_Sel.renderer.sharedMaterial != null && m_Sel.renderer.sharedMaterial.mainTexture != null)
                {
                    int nClickFrameIndex;
                    if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.TileTexture)
                    {
                        if (DrawTileTexture(subRect, (m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.SELECT), m_Sel.renderer.sharedMaterial, m_Sel.m_nTilingX, m_Sel.m_nTilingY, m_Sel.m_nStartFrame, m_Sel.m_nFrameCount, m_Sel.m_nSelectFrame, out nClickFrameIndex))
                        {
                            bClickButton = true;
                            if (bClickButton && m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.SELECT)
                            {
                                m_Sel.m_nSelectFrame = nClickFrameIndex;
                            }
                        }
                    }

                    if (m_Sel.m_TextureType != NcSpriteAnimation.TEXTURE_TYPE.TileTexture)
                    {
                        if (DrawTrimTexture(subRect, (m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.SELECT), m_Sel.renderer.sharedMaterial, m_Sel.m_NcSpriteFrameInfos, m_Sel.m_nStartFrame, m_Sel.m_nFrameCount, m_Sel.m_nSelectFrame, out nClickFrameIndex))
                        {
                            bClickButton = true;
                            if (bClickButton && m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.SELECT)
                            {
                                m_Sel.m_nSelectFrame = nClickFrameIndex;
                            }
                        }
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
            m_UndoManager.CheckDirty();

            EditorGUILayout.Space();
            // Remove AlphaChannel
            if (GUILayout.Button(GetHelpContent("Remove AlphaChannel")))
            {
                NgAtlas.ConvertAlphaTexture(m_Sel.renderer.sharedMaterial, false, m_Sel.m_curveAlphaWeight, 1, 1, 1);
            }
            // AlphaWeight
            if ((m_Sel.m_curveAlphaWeight == null || m_Sel.m_curveAlphaWeight.length <= 0) && FXMakerOption.inst != null)
            {
                m_Sel.m_curveAlphaWeight = FXMakerOption.inst.m_AlphaWeightCurve;
            }
            if (m_Sel.m_curveAlphaWeight != null)
            {
                bool bHighLight = m_Sel.m_bNeedRebuildAlphaChannel;
                if (bHighLight)
                {
                    FXMakerLayout.GUIColorBackup(FXMakerLayout.m_ColorHelpBox);
                }
                if (GUILayout.Button(GetHelpContent("Adjust the alpha channel with AlphaWeight")))
                {
                    m_Sel.m_bNeedRebuildAlphaChannel = false;
                    NgAtlas.ConvertAlphaTexture(m_Sel.renderer.sharedMaterial, true, m_Sel.m_curveAlphaWeight, 1, 1, 1);
//					NgAtlas.ConvertAlphaTexture(m_Sel.renderer.sharedMaterial, m_Sel.m_curveAlphaWeight, m_Sel.m_fRedAlphaWeight, m_Sel.m_fGreenAlphaWeight, m_Sel.m_fBlueAlphaWeight);
                }
                if (bHighLight)
                {
                    FXMakerLayout.GUIColorRestore();
                }

                EditorGUI.BeginChangeCheck();
                m_Sel.m_curveAlphaWeight = EditorGUILayout.CurveField(GetHelpContent("m_curveAlphaWeight"), m_Sel.m_curveAlphaWeight);
                if (EditorGUI.EndChangeCheck())
                {
                    m_Sel.m_bNeedRebuildAlphaChannel = true;
                }
//              m_Sel.m_fRedAlphaWeight		= EditorGUILayout.Slider("", m_Sel.m_fRedAlphaWeight	, 0, 1.0f);
//              m_Sel.m_fGreenAlphaWeight	= EditorGUILayout.Slider("", m_Sel.m_fGreenAlphaWeight	, 0, 1.0f);
//	            m_Sel.m_fBlueAlphaWeight	= EditorGUILayout.Slider("", m_Sel.m_fBlueAlphaWeight	, 0, 1.0f);
            }

            EditorGUILayout.Space();
        }
        // --------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
        {
            OnEditComponent();
        }
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
        {
            m_LastTooltip = GUI.tooltip;
        }
        HelpBox(m_LastTooltip);
    }
예제 #6
0
    public override void OnInspectorGUI()
    {
        Rect rect;
        AddScriptNameField(m_Sel);
        m_UndoManager.CheckUndo();
        m_FxmPopupManager = GetFxmPopupManager();

        //		test code
        // 		if (GUILayout.Button("Pause"))
        // 			FxmInfoIndexing.FindInstanceIndexing(m_Sel.transform, false).GetComponent<NcSpriteAnimation>().PauseAnimation();
        // 		if (GUILayout.Button("Resume"))
        // 			FxmInfoIndexing.FindInstanceIndexing(m_Sel.transform, false).GetComponent<NcSpriteAnimation>().ResumeAnimation();

        // --------------------------------------------------------------
        bool bClickButton = false;
        EditorGUI.BeginChangeCheck();
        {
        //			DrawDefaultInspector();
            m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

            m_Sel.m_TextureType		= (NcSpriteAnimation.TEXTURE_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_TextureType"), m_Sel.m_TextureType);

            EditorGUILayout.Space();

            if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.TileTexture)
            {
                if (GUILayout.Button(GetHelpContent("ConvertTo : TrimTexture")))
                {
                    m_Sel.m_NcSpriteFrameInfos = NgAtlas.TileToTrimTexture(m_Sel.renderer.sharedMaterial, m_Sel.m_nTilingX, m_Sel.m_nTilingY, 0, m_Sel.m_nFrameCount, 4096);
                    if (m_Sel.m_NcSpriteFrameInfos != null)
                        m_Sel.m_TextureType = NcSpriteAnimation.TEXTURE_TYPE.TrimTexture;
                }
                if (GUILayout.Button(GetHelpContent("ExportTo : SplitTexture")))
                {
                    string path = FXMakerCapture.GetExportSlitDir();
                    path = NgAtlas.ExportSplitTexture(path, m_Sel.renderer.sharedMaterial.mainTexture, m_Sel.m_nTilingX, m_Sel.m_nTilingY, 0, m_Sel.m_nFrameCount);
                    if (path != "")
                    {
                        Debug.Log(path);
                        EditorUtility.OpenWithDefaultApp(path);
                    }
                }
            } else
            if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.TrimTexture)
            {
                if (GUILayout.Button(GetHelpContent("ExportTo : SplitTexture")))
                {
                    string path = FXMakerCapture.GetExportSlitDir();
                    path = NgAtlas.ExportSplitTexture(path, m_Sel.renderer.sharedMaterial.mainTexture, m_Sel.m_NcSpriteFrameInfos);
                    if (path != "")
                    {
                        Debug.Log(path);
                        EditorUtility.OpenWithDefaultApp(path);
                    }
                }
            } else
            if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.SpriteFactory)
            {
            }
            EditorGUILayout.Space();

            if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.TileTexture)
            {
                m_Sel.m_nTilingX	= EditorGUILayout.IntField	(GetHelpContent("m_nTilingX")		, m_Sel.m_nTilingX);
                m_Sel.m_nTilingY	= EditorGUILayout.IntField	(GetHelpContent("m_nTilingY")		, m_Sel.m_nTilingY);
            } else
            if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.TrimTexture)
            {
                m_Sel.m_MeshType	= (NcSpriteFactory.MESH_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_MeshType"), m_Sel.m_MeshType);
                m_Sel.m_AlignType	= (NcSpriteFactory.ALIGN_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_AlignType"), m_Sel.m_AlignType);
            } else
            if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.SpriteFactory)
            {
                m_Sel.m_NcSpriteFactoryPrefab	= (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_NcSpriteFactoryPrefab"), m_Sel.m_NcSpriteFactoryPrefab, typeof(GameObject), false, null);
                // --------------------------------------------------------------
                EditorGUILayout.Space();
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
                {
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("Select SpriteFactory"), (m_FxmPopupManager != null)))
                        m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, true, 0);
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("Clear SpriteFactory"), (m_Sel.m_NcSpriteFactoryPrefab != null)))
                    {
                        bClickButton = true;
                        m_Sel.m_NcSpriteFactoryPrefab = null;
                    }
                    GUILayout.Label("");
                }
                EditorGUILayout.EndHorizontal();

                // --------------------------------------------------------------
                if (m_Sel.m_NcSpriteFactoryPrefab != null && m_Sel.m_NcSpriteFactoryPrefab.renderer != null && m_Sel.renderer)
                    if (m_Sel.m_NcSpriteFactoryPrefab.renderer.sharedMaterial != m_Sel.renderer.sharedMaterial)
                        m_Sel.UpdateFactoryMaterial();

                // --------------------------------------------------------------
                NcSpriteFactory ncSpriteFactory	= (m_Sel.m_NcSpriteFactoryPrefab == null ? null : m_Sel.m_NcSpriteFactoryPrefab.GetComponent<NcSpriteFactory>());
                if (ncSpriteFactory != null)
                {
                    int nSelIndex	= EditorGUILayout.IntSlider(GetHelpContent("m_nSpriteFactoryIndex")	, m_Sel.m_nSpriteFactoryIndex, 0, ncSpriteFactory.GetSpriteNodeCount()-1);
                    if (m_Sel.m_nSpriteFactoryIndex != nSelIndex)
                        m_Sel.SetSpriteFactoryIndex(nSelIndex, false);
                }

                m_Sel.m_MeshType	= (NcSpriteFactory.MESH_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_MeshType"), m_Sel.m_MeshType);
                m_Sel.m_AlignType	= (NcSpriteFactory.ALIGN_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_AlignType"), m_Sel.m_AlignType);
            }

            m_Sel.m_PlayMode				= (NcSpriteAnimation.PLAYMODE)EditorGUILayout.EnumPopup (GetHelpContent("m_PlayMode")		, m_Sel.m_PlayMode, GUILayout.MaxWidth(Screen.width));
            if (m_Sel.m_PlayMode != NcSpriteAnimation.PLAYMODE.SELECT)
                m_Sel.m_fDelayTime			= EditorGUILayout.FloatField(GetHelpContent("m_fDelayTime")		, m_Sel.m_fDelayTime);

            if (m_Sel.m_PlayMode != NcSpriteAnimation.PLAYMODE.RANDOM && m_Sel.m_PlayMode != NcSpriteAnimation.PLAYMODE.SELECT)
            {
                m_Sel.m_bLoop				= EditorGUILayout.Toggle	(GetHelpContent("m_bLoop")			, m_Sel.m_bLoop);
                if (m_Sel.m_bLoop == false)
                    m_Sel.m_bAutoDestruct	= EditorGUILayout.Toggle	(GetHelpContent("m_bAutoDestruct")	, m_Sel.m_bAutoDestruct);
                m_Sel.m_fFps				= EditorGUILayout.FloatField(GetHelpContent("m_fFps")			, m_Sel.m_fFps);
            }

            m_Sel.m_nStartFrame	= EditorGUILayout.IntField	(GetHelpContent("m_nStartFrame")	, m_Sel.m_nStartFrame);
            m_Sel.m_nFrameCount	= EditorGUILayout.IntField	(GetHelpContent("m_nFrameCount")	, m_Sel.m_nFrameCount);

            if (m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.SELECT)
                m_Sel.m_nSelectFrame		= EditorGUILayout.IntField	(GetHelpContent("m_nSelectFrame")	, m_Sel.m_nSelectFrame);

            // check
            SetMinValue(ref m_Sel.m_nTilingX, 1);
            SetMinValue(ref m_Sel.m_nTilingY, 1);
            SetMinValue(ref m_Sel.m_fFps, 0.1f);
            SetMinValue(ref m_Sel.m_fDelayTime, 0);
            SetMinValue(ref m_Sel.m_nStartFrame, 0);
            SetMaxValue(ref m_Sel.m_nStartFrame, m_Sel.GetMaxFrameCount()-1);
            SetMinValue(ref m_Sel.m_nFrameCount, 1);
            SetMaxValue(ref m_Sel.m_nFrameCount, m_Sel.GetValidFrameCount());
            SetMinValue(ref m_Sel.m_nSelectFrame, 0);
            SetMaxValue(ref m_Sel.m_nSelectFrame, (0 < m_Sel.m_nFrameCount ? m_Sel.m_nFrameCount-1 : m_Sel.m_nTilingX*m_Sel.m_nTilingY-1));

            if (m_Sel.m_PlayMode != NcSpriteAnimation.PLAYMODE.RANDOM && m_Sel.m_PlayMode != NcSpriteAnimation.PLAYMODE.SELECT)
                EditorGUILayout.TextField(GetHelpContent("DurationTime"), m_Sel.GetDurationTime().ToString());

            // Texture --------------------------------------------------------------
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(150));
            {
                GUI.Box(rect, "");
                GUILayout.Label("");

                Rect subRect = rect;

                // draw texture
                if (m_Sel.renderer != null && m_Sel.renderer.sharedMaterial != null && m_Sel.renderer.sharedMaterial.mainTexture != null)
                {
                    int nClickFrameIndex;
                    if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.TileTexture)
                    {
                        if (DrawTileTexture(subRect, (m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.SELECT), m_Sel.renderer.sharedMaterial, m_Sel.m_nTilingX, m_Sel.m_nTilingY, m_Sel.m_nStartFrame, m_Sel.m_nFrameCount, m_Sel.m_nSelectFrame, out nClickFrameIndex))
                        {
                            bClickButton	= true;
                            if (bClickButton && m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.SELECT)
                                m_Sel.m_nSelectFrame = nClickFrameIndex;
                        }
                    }

                    if (m_Sel.m_TextureType != NcSpriteAnimation.TEXTURE_TYPE.TileTexture)
                    {
                        if (DrawTrimTexture(subRect, (m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.SELECT), m_Sel.renderer.sharedMaterial, m_Sel.m_NcSpriteFrameInfos, m_Sel.m_nStartFrame, m_Sel.m_nFrameCount, m_Sel.m_nSelectFrame, out nClickFrameIndex))
                        {
                            bClickButton	= true;
                            if (bClickButton && m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.SELECT)
                                m_Sel.m_nSelectFrame = nClickFrameIndex;
                        }
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
            m_UndoManager.CheckDirty();

            EditorGUILayout.Space();
            // Remove AlphaChannel
            if (GUILayout.Button(GetHelpContent("Remove AlphaChannel")))
                NgAtlas.ConvertAlphaTexture(m_Sel.renderer.sharedMaterial, false, m_Sel.m_curveAlphaWeight, 1, 1, 1);
            // AlphaWeight
            if ((m_Sel.m_curveAlphaWeight == null || m_Sel.m_curveAlphaWeight.length <= 0) && FXMakerOption.inst != null)
                m_Sel.m_curveAlphaWeight = FXMakerOption.inst.m_AlphaWeightCurve;
            if (m_Sel.m_curveAlphaWeight != null)
            {
                bool bHighLight = m_Sel.m_bNeedRebuildAlphaChannel;
                if (bHighLight)
         				FXMakerLayout.GUIColorBackup(FXMakerLayout.m_ColorHelpBox);
                if (GUILayout.Button(GetHelpContent("Adjust the alpha channel with AlphaWeight")))
                {
                    m_Sel.m_bNeedRebuildAlphaChannel = false;
                    NgAtlas.ConvertAlphaTexture(m_Sel.renderer.sharedMaterial, true, m_Sel.m_curveAlphaWeight, 1, 1, 1);
        //					NgAtlas.ConvertAlphaTexture(m_Sel.renderer.sharedMaterial, m_Sel.m_curveAlphaWeight, m_Sel.m_fRedAlphaWeight, m_Sel.m_fGreenAlphaWeight, m_Sel.m_fBlueAlphaWeight);
                }
                if (bHighLight)
                    FXMakerLayout.GUIColorRestore();

                EditorGUI.BeginChangeCheck();
                m_Sel.m_curveAlphaWeight	= EditorGUILayout.CurveField(GetHelpContent("m_curveAlphaWeight"), m_Sel.m_curveAlphaWeight);
                if (EditorGUI.EndChangeCheck())
                    m_Sel.m_bNeedRebuildAlphaChannel = true;
        // 				m_Sel.m_fRedAlphaWeight		= EditorGUILayout.Slider("", m_Sel.m_fRedAlphaWeight	, 0, 1.0f);
        // 				m_Sel.m_fGreenAlphaWeight	= EditorGUILayout.Slider("", m_Sel.m_fGreenAlphaWeight	, 0, 1.0f);
        //	 			m_Sel.m_fBlueAlphaWeight	= EditorGUILayout.Slider("", m_Sel.m_fBlueAlphaWeight	, 0, 1.0f);
            }

            EditorGUILayout.Space();

        }
        // --------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
            GetFXMakerMain().CreateCurrentInstanceEffect(true);
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
            m_LastTooltip	= GUI.tooltip;
        HelpBox(m_LastTooltip);
    }
예제 #7
0
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);
        m_UndoManager.CheckUndo();

        Rect			rect;

        m_FxmPopupManager = GetFxmPopupManager();

        // --------------------------------------------------------------
        bool bClickButton = false;
        EditorGUI.BeginChangeCheck();
        {
        //			DrawDefaultInspector();
            m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

            m_Sel.m_AttachType				= (NcAttachPrefab.AttachType)EditorGUILayout.EnumPopup(GetHelpContent("m_AttachType")	, m_Sel.m_AttachType, GUILayout.MaxWidth(Screen.width));

            if (m_Sel.m_AttachType == NcAttachPrefab.AttachType.Active)
            {
                m_Sel.m_fDelayTime			= EditorGUILayout.FloatField	(GetHelpContent("m_fDelayTime")				, m_Sel.m_fDelayTime);
                m_Sel.m_fRepeatTime			= EditorGUILayout.FloatField	(GetHelpContent("m_fRepeatTime")			, m_Sel.m_fRepeatTime);
            }

            m_Sel.m_nRepeatCount			= EditorGUILayout.IntField		(GetHelpContent("m_nRepeatCount")			, m_Sel.m_nRepeatCount);
            m_Sel.m_AttachPrefab			= (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_AttachPrefab")	, m_Sel.m_AttachPrefab, typeof(GameObject), false, null);
            m_Sel.m_fPrefabSpeed			= EditorGUILayout.FloatField	(GetHelpContent("m_fPrefabSpeed")			, m_Sel.m_fPrefabSpeed);
            m_Sel.m_fPrefabLifeTime			= EditorGUILayout.FloatField	(GetHelpContent("m_fPrefabLifeTime")		, m_Sel.m_fPrefabLifeTime);

            if (m_Sel.m_AttachType == NcAttachPrefab.AttachType.Destroy)
            {
                SetMinValue(ref m_Sel.m_nRepeatCount, 1);

                FXMakerLayout.GUIEnableBackup(false);
                EditorGUILayout.Toggle		(GetHelpContent("m_bWorldSpace")			, true);
                FXMakerLayout.GUIEnableRestore();
            }

            if (m_Sel.m_AttachType == NcAttachPrefab.AttachType.Active)
                m_Sel.m_bWorldSpace			= EditorGUILayout.Toggle		(GetHelpContent("m_bWorldSpace")			, m_Sel.m_bWorldSpace);

            m_Sel.m_RandomRange				= EditorGUILayout.Vector3Field	("m_RandomRange"							, m_Sel.m_RandomRange, null);
            m_Sel.m_AddStartPos				= EditorGUILayout.Vector3Field	("m_AddStartPos"							, m_Sel.m_AddStartPos, null);
            m_Sel.m_AccumStartRot			= EditorGUILayout.Vector3Field	("m_AccumStartRot"							, m_Sel.m_AccumStartRot, null);

            // check
            SetMinValue(ref m_Sel.m_fDelayTime, 0);
            SetMinValue(ref m_Sel.m_fRepeatTime, 0);
            SetMinValue(ref m_Sel.m_nRepeatCount, 0);
            SetMinValue(ref m_Sel.m_fPrefabSpeed, 0.01f);
            SetMinValue(ref m_Sel.m_fPrefabLifeTime, 0);

            // --------------------------------------------------------------
            EditorGUILayout.Space();
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
            {
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 0, 1), GetHelpContent("Select Prefab"), (m_FxmPopupManager != null)))
                    m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, true, 0);
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 1, 1), GetHelpContent("Clear Prefab"), (m_Sel.m_AttachPrefab != null)))
                {
                    bClickButton = true;
                    m_Sel.m_AttachPrefab = null;
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 2, 1), GetHelpContent("Open Prefab"), (m_FxmPopupManager != null) && (m_Sel.m_AttachPrefab != null)))
                {
                    bClickButton = true;
                    GetFXMakerMain().OpenPrefab(m_Sel.m_AttachPrefab);
                    return;
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();
        }
        m_UndoManager.CheckDirty();
        // --------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
            OnEditComponent();
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
            m_LastTooltip	= GUI.tooltip;
        HelpBox(m_LastTooltip);
    }
예제 #8
0
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);
        m_UndoManager.CheckUndo();

        Rect	rect;

        m_FxmPopupManager = GetFxmPopupManager();

        // --------------------------------------------------------------
        bool bClickButton = false;
        EditorGUI.BeginChangeCheck();
        {
        //			DrawDefaultInspector();
            m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

            m_Sel.m_ParticlePrefab	= (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_ParticlePrefab"), m_Sel.m_ParticlePrefab, typeof(GameObject), false, null);
            // --------------------------------------------------------------
            EditorGUILayout.Space();
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
            {
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("Select ParticlePrefab"), (m_FxmPopupManager != null)))
                    m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, true, 0);
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("Clear ParticlePrefab"), (m_Sel.m_ParticlePrefab != null)))
                {
                    bClickButton = true;
                    m_Sel.m_ParticlePrefab = null;
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            // --------------------------------------------------------------

            m_Sel.m_fDelayTime				= EditorGUILayout.FloatField	(GetHelpContent("m_fDelayTime")				, m_Sel.m_fDelayTime);
            m_Sel.m_nNumberOfArms			= EditorGUILayout.IntField		(GetHelpContent("m_nNumberOfArms")			, m_Sel.m_nNumberOfArms);
            m_Sel.m_nParticlesPerArm		= EditorGUILayout.IntField		(GetHelpContent("m_nParticlesPerArm")		, m_Sel.m_nParticlesPerArm);
            m_Sel.m_fParticleSeparation		= EditorGUILayout.FloatField	(GetHelpContent("m_fParticleSeparation")	, m_Sel.m_fParticleSeparation);
            m_Sel.m_fTurnDistance			= EditorGUILayout.FloatField	(GetHelpContent("m_fTurnDistance")			, m_Sel.m_fTurnDistance);
            m_Sel.m_fVerticalTurnDistance	= EditorGUILayout.FloatField	(GetHelpContent("m_fVerticalTurnDistance")	, m_Sel.m_fVerticalTurnDistance);
            m_Sel.m_fOriginOffset			= EditorGUILayout.FloatField	(GetHelpContent("m_fOriginOffset")			, m_Sel.m_fOriginOffset);
            m_Sel.m_fTurnSpeed				= EditorGUILayout.FloatField	(GetHelpContent("m_fTurnSpeed")				, m_Sel.m_fTurnSpeed);
            m_Sel.m_fFadeValue				= EditorGUILayout.FloatField	(GetHelpContent("m_fFadeValue")				, m_Sel.m_fFadeValue);
            m_Sel.m_fSizeValue				= EditorGUILayout.FloatField	(GetHelpContent("m_fSizeValue")				, m_Sel.m_fSizeValue);
            m_Sel.m_nNumberOfSpawns			= EditorGUILayout.IntField		(GetHelpContent("m_nNumberOfSpawns")		, m_Sel.m_nNumberOfSpawns);
            m_Sel.m_fSpawnRate				= EditorGUILayout.FloatField	(GetHelpContent("m_fSpawnRate")				, m_Sel.m_fSpawnRate);

            Rect butRect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight*2));
            {
                if (FXMakerLayout.GUIButton(butRect, GetHelpContent("Randomize"), true))
                {
                    m_Sel.RandomizeEditor();
                    bClickButton = true;
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            SetMinValue(ref m_Sel.m_fDelayTime, 0);
            SetMinValue(ref m_Sel.m_nNumberOfArms, 1);
            SetMinValue(ref m_Sel.m_nParticlesPerArm, 1);
            SetMinValue(ref m_Sel.m_fFadeValue, -1);
            SetMaxValue(ref m_Sel.m_fFadeValue, 1);
            SetMinValue(ref m_Sel.m_nNumberOfSpawns, 1);
            SetMinValue(ref m_Sel.m_fSpawnRate, 0.1f);
        }
        m_UndoManager.CheckDirty();
        // --------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
            OnEditComponent();
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
            m_LastTooltip	= GUI.tooltip;
        HelpBox(m_LastTooltip);
    }
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);
        m_UndoManager.CheckUndo();

        Rect rect;

        m_FxmPopupManager = GetFxmPopupManager();

        // --------------------------------------------------------------
        bool bClickButton = false;

        EditorGUI.BeginChangeCheck();
        {
//			DrawDefaultInspector();
            m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

            m_Sel.m_NcSpriteFactoryPrefab = (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_NcSpriteFactoryPrefab"), m_Sel.m_NcSpriteFactoryPrefab, typeof(GameObject), false, null);
            // --------------------------------------------------------------
            EditorGUILayout.Space();
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
            {
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("Select SpriteFactory"), (m_FxmPopupManager != null)))
                {
                    m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, true, 0);
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("Clear SpriteFactory"), (m_Sel.m_NcSpriteFactoryPrefab != null)))
                {
                    bClickButton = true;
                    m_Sel.m_NcSpriteFactoryPrefab = null;
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            // --------------------------------------------------------------

            NcSpriteFactory ncSpriteFactory = (m_Sel.m_NcSpriteFactoryPrefab == null ? null : m_Sel.m_NcSpriteFactoryPrefab.GetComponent <NcSpriteFactory>());
            if (ncSpriteFactory != null)
            {
                int nSelIndex = EditorGUILayout.IntSlider(GetHelpContent("m_nSpriteFactoryIndex"), m_Sel.m_nSpriteFactoryIndex, 0, ncSpriteFactory.GetSpriteNodeCount() - 1);
                if (m_Sel.m_nSpriteFactoryIndex != nSelIndex)
                {
                    m_Sel.SetSpriteFactoryIndex(nSelIndex, m_Sel.m_nFrameIndex, false);
                }
            }

            // --------------------------------------------------------------
            if (m_Sel.m_NcSpriteFactoryPrefab != null && m_Sel.m_NcSpriteFactoryPrefab.renderer != null && m_Sel.renderer)
            {
                if (m_Sel.m_NcSpriteFactoryPrefab.renderer.sharedMaterial != m_Sel.renderer.sharedMaterial)
                {
                    m_Sel.UpdateSpriteMaterial();
                }
            }

            // --------------------------------------------------------------
            m_Sel.m_MeshType  = (NcSpriteFactory.MESH_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_MeshType"), m_Sel.m_MeshType);
            m_Sel.m_AlignType = (NcSpriteFactory.ALIGN_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_AlignType"), m_Sel.m_AlignType);

            // --------------------------------------------------------------
            if (ncSpriteFactory != null && ncSpriteFactory.IsValidFactory())
            {
                // Texture --------------------------------------------------------------
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(200));
                {
                    GUI.Box(rect, "");
                    GUILayout.Label("");

                    Rect subRect = rect;

                    // draw texture
                    if (0 < rect.width && m_Sel.renderer != null && m_Sel.renderer.sharedMaterial != null && m_Sel.renderer.sharedMaterial.mainTexture != null)
                    {
                        int nClickFactoryIndex;
                        int nClickFrameIndex;
                        bClickButton = DrawTrimTexture(subRect, true, m_Sel.renderer.sharedMaterial, ncSpriteFactory, m_Sel.m_nSpriteFactoryIndex, m_Sel.m_nFrameIndex, true, out nClickFactoryIndex, out nClickFrameIndex);
                        if (bClickButton)
                        {
                            m_Sel.SetSpriteFactoryIndex(nClickFactoryIndex, nClickFrameIndex, false);
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                m_Sel.m_nSpriteFactoryIndex = -1;
            }
        }
        m_UndoManager.CheckDirty();
        // --------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
        {
            GetFXMakerMain().CreateCurrentInstanceEffect(true);
        }
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
        {
            m_LastTooltip = GUI.tooltip;
        }
        HelpBox(m_LastTooltip);
    }
예제 #10
0
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);
        m_UndoManager.CheckUndo();

        Rect	rect;

        m_FxmPopupManager = GetFxmPopupManager();

        // --------------------------------------------------------------
        bool bClickButton = false;
        EditorGUI.BeginChangeCheck();
        {
        //			DrawDefaultInspector();
            m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

            m_Sel.m_NcSpriteFactoryPrefab	= (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_NcSpriteFactoryPrefab"), m_Sel.m_NcSpriteFactoryPrefab, typeof(GameObject), false, null);
            // --------------------------------------------------------------
            EditorGUILayout.Space();
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
            {
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("Select SpriteFactory"), (m_FxmPopupManager != null)))
                    m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, true, 0);
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("Clear SpriteFactory"), (m_Sel.m_NcSpriteFactoryPrefab != null)))
                {
                    bClickButton = true;
                    m_Sel.m_NcSpriteFactoryPrefab = null;
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            // --------------------------------------------------------------

            NcSpriteFactory ncSpriteFactory	= (m_Sel.m_NcSpriteFactoryPrefab == null ? null : m_Sel.m_NcSpriteFactoryPrefab.GetComponent<NcSpriteFactory>());
            if (ncSpriteFactory != null)
            {
                int nSelIndex	= EditorGUILayout.IntSlider(GetHelpContent("m_nSpriteFactoryIndex")	, m_Sel.m_nSpriteFactoryIndex, 0, ncSpriteFactory.GetSpriteNodeCount()-1);
                if (m_Sel.m_nSpriteFactoryIndex != nSelIndex)
                    m_Sel.SetSpriteFactoryIndex(nSelIndex, m_Sel.m_nFrameIndex, false);
            }

            // --------------------------------------------------------------
            if (m_Sel.m_NcSpriteFactoryPrefab != null && m_Sel.m_NcSpriteFactoryPrefab.renderer != null && m_Sel.renderer)
                if (m_Sel.m_NcSpriteFactoryPrefab.renderer.sharedMaterial != m_Sel.renderer.sharedMaterial)
                    m_Sel.UpdateSpriteMaterial();

            // --------------------------------------------------------------
            m_Sel.m_MeshType	= (NcSpriteFactory.MESH_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_MeshType"), m_Sel.m_MeshType);
            m_Sel.m_AlignType	= (NcSpriteFactory.ALIGN_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_AlignType"), m_Sel.m_AlignType);

            // --------------------------------------------------------------
            if (ncSpriteFactory != null && ncSpriteFactory.IsValidFactory())
            {
                // Texture --------------------------------------------------------------
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(200));
                {
                    GUI.Box(rect, "");
                    GUILayout.Label("");

                    Rect subRect = rect;

                    // draw texture
                    if (0 < rect.width && m_Sel.renderer != null && m_Sel.renderer.sharedMaterial != null && m_Sel.renderer.sharedMaterial.mainTexture != null)
                    {
                        int nClickFactoryIndex;
                        int nClickFrameIndex;
                        bClickButton = DrawTrimTexture(subRect, true, m_Sel.renderer.sharedMaterial, ncSpriteFactory, m_Sel.m_nSpriteFactoryIndex, m_Sel.m_nFrameIndex, true, out nClickFactoryIndex, out nClickFrameIndex);
                        if (bClickButton)
                            m_Sel.SetSpriteFactoryIndex(nClickFactoryIndex, nClickFrameIndex, false);
                    }
                }
                EditorGUILayout.EndHorizontal();
            } else {
                m_Sel.m_nSpriteFactoryIndex	= -1;
            }
        }
        m_UndoManager.CheckDirty();
        // --------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
            GetFXMakerMain().CreateCurrentInstanceEffect(true);
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
            m_LastTooltip	= GUI.tooltip;
        HelpBox(m_LastTooltip);
    }
	public override void OnInspectorGUI()
	{
		AddScriptNameField(m_Sel);
		m_UndoManager.CheckUndo();

		Rect	rect;

		m_FxmPopupManager = GetFxmPopupManager();

		// --------------------------------------------------------------
		bool bClickButton = false;
		EditorGUI.BeginChangeCheck();
		{
//			DrawDefaultInspector();
			m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

			m_Sel.m_NcSpriteFactoryPrefab	= (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_NcSpriteFactoryPrefab"), m_Sel.m_NcSpriteFactoryPrefab, typeof(GameObject), false, null);
			NcSpriteFactory ncSpriteFactory	= (m_Sel.m_NcSpriteFactoryPrefab == null ? null : m_Sel.m_NcSpriteFactoryPrefab.GetComponent<NcSpriteFactory>());
			if (ncSpriteFactory != null)
			{
				int nSelIndex	= EditorGUILayout.IntSlider(GetHelpContent("m_nSpriteFactoryIndex")	, m_Sel.m_nSpriteFactoryIndex, 0, ncSpriteFactory.GetSpriteNodeCount()-1);
				if (m_Sel.m_nSpriteFactoryIndex != nSelIndex)
				{
					m_Sel.m_nSpriteFactoryIndex	= nSelIndex;
					ncSpriteFactory.m_nCurrentIndex = nSelIndex;
				}
			}

			// --------------------------------------------------------------
			if (m_Sel.m_NcSpriteFactoryPrefab != null && m_Sel.m_NcSpriteFactoryPrefab.renderer != null && m_Sel.renderer)
				if (m_Sel.m_NcSpriteFactoryPrefab.renderer.sharedMaterial != m_Sel.renderer.sharedMaterial)
					m_Sel.UpdateSpriteMaterial();

			// --------------------------------------------------------------
			EditorGUILayout.Space();
			rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
			{
				if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("Select SpriteFactory"), (m_FxmPopupManager != null)))
					m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, true, 0);
				if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("Clear SpriteFactory"), (m_Sel.m_NcSpriteFactoryPrefab != null)))
				{
					bClickButton = true;
					m_Sel.m_NcSpriteFactoryPrefab = null;
				}
				GUILayout.Label("");
			}
			EditorGUILayout.EndHorizontal();
			// --------------------------------------------------------------

			if (ncSpriteFactory != null)
			{
				// Texture --------------------------------------------------------------
				rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(200));
				{
					GUI.Box(rect, "");
					GUILayout.Label("");

					Rect subRect = rect;
					FXMakerLayout.GetOffsetRect(rect, 0, 5, 0, -5);

					// draw texture
					if (m_Sel.renderer != null && m_Sel.renderer.sharedMaterial != null && m_Sel.renderer.sharedMaterial.mainTexture != null)
					{
						GUI.DrawTexture(subRect, m_Sel.renderer.sharedMaterial.mainTexture, ScaleMode.StretchToFill, true);

						Event	ev	= Event.current;

						for (int n = 0; n < ncSpriteFactory.GetSpriteNodeCount(); n++)
						{
							NcSpriteFactory.NcSpriteNode	ncSNode = ncSpriteFactory.GetSpriteNode(n);

							// draw indexRect
							Rect currRect = new Rect(rect.x+ncSNode.m_UvRect.xMin*rect.width, rect.y+(1-ncSNode.m_UvRect.yMin-ncSNode.m_UvRect.height)*rect.height, ncSNode.m_UvRect.width*rect.width, ncSNode.m_UvRect.height*rect.height);
							NgGUIDraw.DrawBox(FXMakerLayout.GetOffsetRect(currRect, 0), (m_Sel.m_nSpriteFactoryIndex == n ? Color.green : Color.red), 1, false);
							GUI.DrawTexture(subRect, m_Sel.renderer.sharedMaterial.mainTexture, ScaleMode.StretchToFill, true);

							// Change selIndex
							if ((ev.type == EventType.MouseDown) && currRect.Contains(ev.mousePosition))
							{
								m_Sel.m_nSpriteFactoryIndex = n;
								ncSpriteFactory.m_nCurrentIndex = n;
								// Rotate
								if (ev.button == 1)
									m_Sel.transform.Rotate(0, 180, 0);
								bClickButton = true;
							}
						}
					}
				}
				EditorGUILayout.EndHorizontal();
			} else {
				m_Sel.m_nSpriteFactoryIndex	= -1;
			}
		}
		m_UndoManager.CheckDirty();
		// --------------------------------------------------------------
		if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
			GetFXMakerMain().CreateCurrentInstanceEffect(true);
		// ---------------------------------------------------------------------
		if (GUI.tooltip != "")
			m_LastTooltip	= GUI.tooltip;
		HelpBox(m_LastTooltip);
	}
예제 #12
0
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);

        int  nClickIndex  = -1;
        int  nClickButton = 0;
        Rect rect;
        int  nLeftWidth    = 35;
        int  nAddHeight    = 30;
        int  nDelWidth     = 35;
        int  nLineHeight   = 18;
        int  nSpriteHeight = nLeftWidth;
        List <NcSpriteFactory.NcSpriteNode> spriteList = m_Sel.m_SpriteList;

        m_FxmPopupManager = GetFxmPopupManager();

        // --------------------------------------------------------------
        bool bClickButton = false;

        EditorGUI.BeginChangeCheck();
        {
            m_UndoManager.CheckUndo();
            // --------------------------------------------------------------
            m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

            EditorGUILayout.Space();
            m_Sel.m_SpriteType = (NcSpriteFactory.SPRITE_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_SpriteType"), m_Sel.m_SpriteType);

            // --------------------------------------------------------------
            if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && m_Sel.gameObject.GetComponent("NcSpriteAnimation") == null)
            {
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
                {
                    if (FXMakerLayout.GUIButton(rect, GetHelpContent("Add NcSpriteAnimation Component"), true))
                    {
                        m_Sel.gameObject.AddComponent("NcSpriteAnimation");
                    }
                    GUILayout.Label("");
                }
                EditorGUILayout.EndHorizontal();
            }
            // --------------------------------------------------------------
            if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteTexture && m_Sel.gameObject.GetComponent("NcSpriteTexture") == null)
            {
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
                {
                    if (FXMakerLayout.GUIButton(rect, GetHelpContent("Add NcSpriteTexture Component"), true))
                    {
                        m_Sel.gameObject.AddComponent("NcSpriteTexture");
                    }
                    GUILayout.Label("");
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.Space();

            // --------------------------------------------------------------
            int nSelIndex = EditorGUILayout.IntSlider(GetHelpContent("m_nCurrentIndex"), m_Sel.m_nCurrentIndex, 0, (spriteList == null ? 0 : spriteList.Count));
            if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteTexture)
            {
                m_Sel.m_fUvScale = EditorGUILayout.FloatField(GetHelpContent("m_fUvScale"), m_Sel.m_fUvScale);
            }
            m_Sel.m_nMaxAtlasTextureSize = EditorGUILayout.IntPopup("nMaxAtlasTextureSize", m_Sel.m_nMaxAtlasTextureSize, NgEnum.m_TextureSizeStrings, NgEnum.m_TextureSizeIntters);
//          m_Sel.m_AtlasMaterial		= (Material)EditorGUILayout.ObjectField(GetHelpContent("m_AtlasMaterial")	, m_Sel.m_AtlasMaterial, typeof(Material), false);

            if (m_Sel.m_nCurrentIndex != nSelIndex)
            {
                m_Sel.m_nCurrentIndex = nSelIndex;
                m_Sel.SetSprite(nSelIndex, false);
            }

            // check

            // Add Button ------------------------------------------------------
            EditorGUILayout.Space();
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nAddHeight * 2));
            {
                Rect lineRect = FXMakerLayout.GetInnerVerticalRect(rect, 2, 0, 1);
                if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 0, 1), GetHelpContent("Add Sprite")))
                {
                    bClickButton = true;
                    m_Sel.AddSpriteNode();
                }
                if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 1, 1), GetHelpContent("Build Sprite")))
                {
                    bClickButton = true;
                    BuildSpriteAtlas(m_Sel.renderer.sharedMaterial);
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 2, 1), GetHelpContent("Clear All"), (0 < m_Sel.GetSpriteNodeCount())))
                {
                    bClickButton = true;
                    if (m_FxmPopupManager != null)
                    {
                        m_FxmPopupManager.CloseNcPrefabPopup();
                    }
                    m_Sel.ClearAllSpriteNode();
                }
                lineRect = FXMakerLayout.GetInnerVerticalRect(rect, 2, 1, 1);
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 0, 1), GetHelpContent("Sequence"), (0 < m_Sel.GetSpriteNodeCount())))
                {
                    m_Sel.m_bSequenceMode = true;
                    bClickButton          = true;
                    m_Sel.SetSprite(0, false);
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 1, 1), GetHelpContent("NewMaterial"), true))
                {
                    Material newMat  = new Material(m_Sel.renderer.sharedMaterial);
                    string   matPath = AssetDatabase.GetAssetPath(m_Sel.renderer.sharedMaterial);
                    NgMaterial.SaveMaterial(newMat, NgFile.TrimFilenameExt(matPath), m_Sel.name);
                    m_Sel.renderer.sharedMaterial = newMat;
//                  m_Sel.renderer.sharedMaterial = (Material)AssetDatabase.LoadAssetAtPath(savePath, typeof(Material));
                }

                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();

            // Select ShotType -------------------------------------------------
//			showType		= (NcSpriteFactory.SHOW_TYPE)EditorGUILayout.EnumPopup		(GetHelpContent("m_ShowType")	, showType);
            // --------------------------------------------------------------
            EditorGUILayout.Space();
            NcSpriteFactory.SHOW_TYPE showType = (NcSpriteFactory.SHOW_TYPE)EditorPrefs.GetInt("NcSpriteFactory.SHOW_TYPE", 0);

            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
            {
                showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 0, 1), showType == NcSpriteFactory.SHOW_TYPE.NONE, GetHelpContent("NONE"), true) ? NcSpriteFactory.SHOW_TYPE.NONE        : showType;
                showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 1, 1), showType == NcSpriteFactory.SHOW_TYPE.ALL, GetHelpContent("ALL"), true) ? NcSpriteFactory.SHOW_TYPE.ALL         : showType;
                if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation)
                {
                    showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 2, 1), showType == NcSpriteFactory.SHOW_TYPE.SPRITE, GetHelpContent("SPRITE"), true) ? NcSpriteFactory.SHOW_TYPE.SPRITE              : showType;
                    showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 3, 1), showType == NcSpriteFactory.SHOW_TYPE.ANIMATION, GetHelpContent("ANIMATION"), true) ? NcSpriteFactory.SHOW_TYPE.ANIMATION   : showType;
                }
                showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 4, 1), showType == NcSpriteFactory.SHOW_TYPE.EFFECT, GetHelpContent("EFFECT"), true) ? NcSpriteFactory.SHOW_TYPE.EFFECT              : showType;
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();

            EditorPrefs.SetInt("NcSpriteFactory.SHOW_TYPE", ((int)showType));

            // Show Option -------------------------------------------------
            EditorGUILayout.Space();
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
            {
                m_Sel.m_bShowEffect = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 0, 1), m_Sel.m_bShowEffect, GetHelpContent("m_bShowEffect"), true);
                if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation)
                {
                    m_Sel.m_bTestMode     = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 1, 1), m_Sel.m_bTestMode, GetHelpContent("m_bTestMode"), true);
                    m_Sel.m_bSequenceMode = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 2, 1), m_Sel.m_bSequenceMode, GetHelpContent("m_bSequenceMode"), true);
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();

            // Node List ------------------------------------------------------
            for (int n = 0; n < (spriteList != null ? spriteList.Count : 0); n++)
            {
                EditorGUILayout.Space();

                EditorGUI.BeginChangeCheck();
                // Load Texture ---------------------------------------------------------
                Texture2D selTexture = null;
                if (spriteList[n].m_TextureGUID != "")
                {
                    selTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(spriteList[n].m_TextureGUID), typeof(Texture2D));
                }

                // Enabled --------------------------------------------------------------
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                {
                    Rect subRect;
                    // enable
                    spriteList[n].m_bIncludedAtlas = GUILayout.Toggle(spriteList[n].m_bIncludedAtlas, "Idx", GUILayout.Width(nLeftWidth));
                    // change index
                    subRect       = rect;
                    subRect.x    += nLeftWidth;
                    subRect.width = nLineHeight * 2;
                    int newPos = EditorGUI.IntPopup(subRect, n, NgConvert.GetIntStrings(0, spriteList.Count), NgConvert.GetIntegers(0, spriteList.Count));
                    if (newPos != n)
                    {
                        NcSpriteFactory.NcSpriteNode node = spriteList[n];
                        m_Sel.m_SpriteList.Remove(node);
                        m_Sel.m_SpriteList.Insert(newPos, node);
                        return;
                    }

                    // name
                    subRect        = rect;
                    subRect.x     += nLeftWidth + nLineHeight * 2;
                    subRect.width -= nLeftWidth + nLineHeight * 2;
                    spriteList[n].m_TextureName = selTexture == null ? "" : selTexture.name;
                    GUI.Label(subRect, (selTexture == null ? "" : "(" + spriteList[n].m_nFrameCount + ") " + selTexture.name));
                    GUI.Box(subRect, "");
                    GUI.Box(rect, "");

                    // delete
                    if (GUI.Button(new Rect(subRect.x + subRect.width - nDelWidth, subRect.y, nDelWidth, subRect.height), GetHelpContent("Del")))
                    {
                        bClickButton = true;
                        if (m_FxmPopupManager != null)
                        {
                            m_FxmPopupManager.CloseNcPrefabPopup();
                        }
                        m_Sel.DeleteSpriteNode(n);
                        return;
                    }
                }
                EditorGUILayout.EndHorizontal();

                // MaxAlpha -------------------------------------------------------------
                spriteList[n].m_fMaxTextureAlpha = EditorGUILayout.FloatField(GetHelpContent("m_fMaxTextureAlpha"), spriteList[n].m_fMaxTextureAlpha);

                // Texture --------------------------------------------------------------
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nSpriteHeight));
                {
                    GUILayout.Label("", GUILayout.Width(nLeftWidth));

                    Rect subRect = rect;
                    subRect.width = nLeftWidth;
                    FXMakerLayout.GetOffsetRect(rect, 0, 5, 0, -5);
                    EditorGUI.BeginChangeCheck();
                    selTexture = (Texture2D)EditorGUI.ObjectField(subRect, GetHelpContent(""), selTexture, typeof(Texture2D), false);
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (selTexture != null)
                        {
                            spriteList[n].m_TextureGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(selTexture));
                        }
                    }
                    if (selTexture != null)
                    {
                        if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation)
                        {
                            spriteList[n].m_nFrameCount = selTexture.width / selTexture.height;
                            spriteList[n].m_nFrameSize  = selTexture.height;
                            m_Sel.m_nFrameSize          = spriteList[n].m_nFrameSize;
                        }
                        else
                        {
                            spriteList[n].m_nFrameCount = 1;
                            spriteList[n].m_nFrameSize  = 1;
                            m_Sel.m_nFrameSize          = 1;
                        }
                    }

                    // draw texture
                    subRect = FXMakerLayout.GetOffsetRect(rect, nLeftWidth + 4, 0, 0, -4);
                    if (selTexture != null)
                    {
                        GUI.DrawTexture(FXMakerLayout.GetOffsetRect(subRect, 0, 0, -nDelWidth, 0), selTexture, ScaleMode.ScaleToFit, true, selTexture.width / selTexture.height);
                    }

                    // delete
                    if (GUI.Button(new Rect(subRect.x + subRect.width - nDelWidth, subRect.y, nDelWidth, subRect.height), GetHelpContent("Rmv")))
                    {
                        spriteList[n].m_TextureGUID = "";
                        spriteList[n].m_nFrameCount = 0;
                        spriteList[n].m_nFrameSize  = 0;
                    }
                    GUI.Box(rect, "");
                }
                EditorGUILayout.EndHorizontal();

                // Change selIndex
                Event e = Event.current;
                if (e.type == EventType.MouseDown)
                {
                    if (rect.Contains(e.mousePosition))
                    {
                        nClickIndex  = n;
                        nClickButton = e.button;
                    }
                }

                // SpriteNode ----------------------------------------------------------
                if (bClickButton == false)
                {
                    if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.SPRITE)
                    {
                        spriteList[n].m_bLoop = EditorGUILayout.Toggle(GetHelpContent("m_bLoop"), spriteList[n].m_bLoop);
                        spriteList[n].m_fTime = EditorGUILayout.Slider(GetHelpContent("m_fTime"), spriteList[n].m_nFrameCount / spriteList[n].m_fFps, 0, 5, null);
                        spriteList[n].m_fFps  = EditorGUILayout.Slider(GetHelpContent("m_fFps"), spriteList[n].m_nFrameCount / spriteList[n].m_fTime, 50, 1, null);
                    }

                    if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.ANIMATION)
                    {
                        spriteList[n].m_nNextSpriteIndex = EditorGUILayout.Popup("m_nNextSpriteIndex", spriteList[n].m_nNextSpriteIndex + 1, GetSpriteNodeNames()) - 1;
                        spriteList[n].m_nTestMode        = EditorGUILayout.Popup("m_nTestMode", spriteList[n].m_nTestMode, NgConvert.ContentsToStrings(FxmTestControls.GetHcEffectControls_Trans(FxmTestControls.AXIS.Z)), GUILayout.MaxWidth(Screen.width));
                        spriteList[n].m_fTestSpeed       = EditorGUILayout.FloatField("m_fTestSpeed", spriteList[n].m_fTestSpeed);

                        SetMinValue(ref spriteList[n].m_fTestSpeed, 0.01f);
                        SetMinValue(ref spriteList[n].m_fTestSpeed, 0.01f);
                    }

                    if (showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.EFFECT)
                    {
                        // char effect -------------------------------------------------------------
                        spriteList[n].m_EffectPrefab = (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_EffectPrefab"), spriteList[n].m_EffectPrefab, typeof(GameObject), false, null);

                        rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight * 0.7f));
                        {
                            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("SelEffect"), (m_FxmPopupManager != null)))
                            {
                                m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, n, 0, true);
                            }
                            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("ClearEffect"), (spriteList[n].m_EffectPrefab != null)))
                            {
                                bClickButton = true;
                                spriteList[n].m_EffectPrefab = null;
                            }
                            GUILayout.Label("");
                        }
                        EditorGUILayout.EndHorizontal();

                        if (spriteList[n].m_EffectPrefab != null)
                        {
                            if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation)
                            {
                                spriteList[n].m_nEffectFrame     = EditorGUILayout.IntSlider(GetHelpContent("m_nEffectFrame"), spriteList[n].m_nEffectFrame, 0, spriteList[n].m_nFrameCount, null);
                                spriteList[n].m_bEffectOnlyFirst = EditorGUILayout.Toggle(GetHelpContent("m_bEffectOnlyFirst"), spriteList[n].m_bEffectOnlyFirst);
                            }
                            spriteList[n].m_fEffectSpeed = EditorGUILayout.FloatField("m_fEffectSpeed", spriteList[n].m_fEffectSpeed);
                            spriteList[n].m_fEffectScale = EditorGUILayout.FloatField("m_fEffectScale", spriteList[n].m_fEffectScale);
                            spriteList[n].m_EffectPos    = EditorGUILayout.Vector3Field("m_EffectPos", spriteList[n].m_EffectPos, null);
                            spriteList[n].m_EffectRot    = EditorGUILayout.Vector3Field("m_EffectRot", spriteList[n].m_EffectRot, null);

                            SetMinValue(ref spriteList[n].m_fEffectScale, 0.001f);
                        }

                        EditorGUILayout.Space();

                        // char sound -------------------------------------------------------------
                        spriteList[n].m_AudioClip = (AudioClip)EditorGUILayout.ObjectField(GetHelpContent("m_AudioClip"), spriteList[n].m_AudioClip, typeof(AudioClip), false, null);

                        rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight * 0.7f));
                        {
//                          if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("SelAudio"), (m_FxmPopupManager != null)))
//								m_FxmPopupManager.ShowSelectAudioClipPopup(m_Sel);
                            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("ClearAudio"), (spriteList[n].m_AudioClip != null)))
                            {
                                bClickButton = true;
                                spriteList[n].m_AudioClip = null;
                            }
                            GUILayout.Label("");
                        }
                        EditorGUILayout.EndHorizontal();

                        if (spriteList[n].m_AudioClip != null)
                        {
                            if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation)
                            {
                                spriteList[n].m_nSoundFrame     = EditorGUILayout.IntSlider(GetHelpContent("m_nSoundFrame"), spriteList[n].m_nSoundFrame, 0, spriteList[n].m_nFrameCount, null);
                                spriteList[n].m_bSoundOnlyFirst = EditorGUILayout.Toggle(GetHelpContent("m_bSoundOnlyFirst"), spriteList[n].m_bSoundOnlyFirst);
                            }
                            spriteList[n].m_bSoundLoop   = EditorGUILayout.Toggle(GetHelpContent("m_bSoundLoop"), spriteList[n].m_bSoundLoop);
                            spriteList[n].m_fSoundVolume = EditorGUILayout.Slider(GetHelpContent("m_fSoundVolume"), spriteList[n].m_fSoundVolume, 0, 1.0f, null);
                            spriteList[n].m_fSoundPitch  = EditorGUILayout.Slider(GetHelpContent("m_fSoundPitch"), spriteList[n].m_fSoundPitch, -3, 3.0f, null);
                        }
                    }
                }

                if (EditorGUI.EndChangeCheck())
                {
                    nClickIndex = n;
                }

                selTexture = null;
            }

            // Select Node ----------------------------------------------------
            if (0 <= nClickIndex)
            {
                m_Sel.SetSprite(nClickIndex, false);
                if (m_Sel.m_bTestMode && 0 <= spriteList[nClickIndex].m_nTestMode && GetFXMakerMain())
                {
                    GetFXMakerMain().GetFXMakerControls().SetTransIndex(spriteList[nClickIndex].m_nTestMode, (4 <= spriteList[nClickIndex].m_nTestMode ? 1.8f : 1.0f), spriteList[nClickIndex].m_fTestSpeed);
                }
                // Rotate
                if (nClickButton == 1)
                {
                    m_Sel.transform.Rotate(0, 180, 0);
                }
                nClickIndex  = -1;
                bClickButton = true;
            }

            m_UndoManager.CheckDirty();
        }
        // --------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
        {
            GetFXMakerMain().CreateCurrentInstanceEffect(true);
        }
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
        {
            m_LastTooltip = GUI.tooltip;
        }
        HelpBox(m_LastTooltip);
    }
예제 #13
0
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);
        m_UndoManager.CheckUndo();

        Rect rect;

        m_FxmPopupManager = GetFxmPopupManager();

        // --------------------------------------------------------------
        bool bClickButton = false;

        EditorGUI.BeginChangeCheck();
        {
//			DrawDefaultInspector();
            m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

            m_Sel.m_AttachType = (NcAttachPrefab.AttachType)EditorGUILayout.EnumPopup(GetHelpContent("m_AttachType"), m_Sel.m_AttachType, GUILayout.MaxWidth(Screen.width));

            if (m_Sel.m_AttachType == NcAttachPrefab.AttachType.Active)
            {
                m_Sel.m_fDelayTime  = EditorGUILayout.FloatField(GetHelpContent("m_fDelayTime"), m_Sel.m_fDelayTime);
                m_Sel.m_fRepeatTime = EditorGUILayout.FloatField(GetHelpContent("m_fRepeatTime"), m_Sel.m_fRepeatTime);
            }

            m_Sel.m_nRepeatCount    = EditorGUILayout.IntField(GetHelpContent("m_nRepeatCount"), m_Sel.m_nRepeatCount);
            m_Sel.m_AttachPrefab    = (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_AttachPrefab"), m_Sel.m_AttachPrefab, typeof(GameObject), false, null);
            m_Sel.m_fPrefabSpeed    = EditorGUILayout.FloatField(GetHelpContent("m_fPrefabSpeed"), m_Sel.m_fPrefabSpeed);
            m_Sel.m_fPrefabLifeTime = EditorGUILayout.FloatField(GetHelpContent("m_fPrefabLifeTime"), m_Sel.m_fPrefabLifeTime);

            if (m_Sel.m_AttachType == NcAttachPrefab.AttachType.Destroy)
            {
                SetMinValue(ref m_Sel.m_nRepeatCount, 1);

                FXMakerLayout.GUIEnableBackup(false);
                EditorGUILayout.Toggle(GetHelpContent("m_bWorldSpace"), true);
                FXMakerLayout.GUIEnableRestore();
            }

            if (m_Sel.m_AttachType == NcAttachPrefab.AttachType.Active)
            {
                m_Sel.m_bWorldSpace = EditorGUILayout.Toggle(GetHelpContent("m_bWorldSpace"), m_Sel.m_bWorldSpace);
            }

            m_Sel.m_RandomRange   = EditorGUILayout.Vector3Field("m_RandomRange", m_Sel.m_RandomRange, null);
            m_Sel.m_AddStartPos   = EditorGUILayout.Vector3Field("m_AddStartPos", m_Sel.m_AddStartPos, null);
            m_Sel.m_AccumStartRot = EditorGUILayout.Vector3Field("m_AccumStartRot", m_Sel.m_AccumStartRot, null);

            // check
            SetMinValue(ref m_Sel.m_fDelayTime, 0);
            SetMinValue(ref m_Sel.m_fRepeatTime, 0);
            SetMinValue(ref m_Sel.m_nRepeatCount, 0);
            SetMinValue(ref m_Sel.m_fPrefabSpeed, 0.01f);
            SetMinValue(ref m_Sel.m_fPrefabLifeTime, 0);

            // --------------------------------------------------------------
            EditorGUILayout.Space();
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
            {
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 0, 1), GetHelpContent("Select Prefab"), (m_FxmPopupManager != null)))
                {
                    m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, true, 0);
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 1, 1), GetHelpContent("Clear Prefab"), (m_Sel.m_AttachPrefab != null)))
                {
                    bClickButton         = true;
                    m_Sel.m_AttachPrefab = null;
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 2, 1), GetHelpContent("Open Prefab"), (m_FxmPopupManager != null) && (m_Sel.m_AttachPrefab != null)))
                {
                    bClickButton = true;
                    GetFXMakerMain().OpenPrefab(m_Sel.m_AttachPrefab);
                    return;
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();

            // m_nSpriteFactoryIndex
            EditorGUILayout.Space();
            if (m_Sel.m_AttachPrefab)
            {
                NcSpriteFactory ncSpriteFactory = m_Sel.m_AttachPrefab.GetComponent <NcSpriteFactory>();
                if (ncSpriteFactory)
                {
                    m_Sel.m_nSpriteFactoryIndex = EditorGUILayout.IntSlider(GetHelpContent("m_nSpriteFactoryIndex"), m_Sel.m_nSpriteFactoryIndex, 0, ncSpriteFactory.GetSpriteNodeCount() - 1);

                    string[] spriteNames = new string[ncSpriteFactory.GetSpriteNodeCount()];
                    for (int n = 0; n < ncSpriteFactory.GetSpriteNodeCount(); n++)
                    {
                        spriteNames[n] = ncSpriteFactory.GetSpriteNode(n).m_SpriteName;
                    }
                    m_Sel.m_nSpriteFactoryIndex = EditorGUILayout.Popup("SpriteName", m_Sel.m_nSpriteFactoryIndex, spriteNames);
                }
                else
                {
                    m_Sel.m_nSpriteFactoryIndex = -1;
                }
            }
            else
            {
                m_Sel.m_nSpriteFactoryIndex = -1;
            }
        }
        m_UndoManager.CheckDirty();
        // --------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
        {
            OnEditComponent();
        }
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
        {
            m_LastTooltip = GUI.tooltip;
        }
        HelpBox(m_LastTooltip);
    }
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);
        m_UndoManager.CheckUndo();

        m_FxmPopupManager = GetFxmPopupManager();

        bool bClickButton = false;

        EditorGUI.BeginChangeCheck();
        {
            m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

            m_Sel.m_fStartDelayTime = EditorGUILayout.FloatField(GetHelpContent("m_fStartDelayTime"), m_Sel.m_fStartDelayTime);
            // --------------------------------------------------------------------------------------------------------------------------------------------
            if (IsParticleEmitterOneShot())
            {
                Rect butRect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
                {
                    if (FXMakerLayout.GUIButton(butRect, GetHelpContent("Convert: OneShot To FXMakerBurst"), true))
                    {
                        ConvertOneShotToFXMakerBurst();
                        return;
                    }
                    GUILayout.Label("");
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
            }
            // --------------------------------------------------------------------------------------------------------------------------------------------
            m_Sel.m_bBurst = EditorGUILayout.Toggle(GetHelpContent("m_bBurst"), m_Sel.m_bBurst);
            if (m_Sel.m_bBurst)
            {
                m_Sel.m_fBurstRepeatTime    = EditorGUILayout.FloatField(GetHelpContent("m_fBurstRepeatTime"), m_Sel.m_fBurstRepeatTime);
                m_Sel.m_nBurstRepeatCount   = EditorGUILayout.IntField(GetHelpContent("m_nBurstRepeatCount"), m_Sel.m_nBurstRepeatCount);
                m_Sel.m_fBurstEmissionCount = EditorGUILayout.IntField(GetHelpContent("m_fBurstEmissionCount"), m_Sel.m_fBurstEmissionCount);
                SetMinValue(ref m_Sel.m_fBurstRepeatTime, 0.01f);
            }
            else
            {
                m_Sel.m_fEmitTime  = EditorGUILayout.FloatField(GetHelpContent("m_fEmitTime"), m_Sel.m_fEmitTime);
                m_Sel.m_fSleepTime = EditorGUILayout.FloatField(GetHelpContent("m_fSleepTime"), m_Sel.m_fSleepTime);
            }

            m_Sel.m_bScaleWithTransform = EditorGUILayout.Toggle(GetHelpContent("m_bScaleWithTransform"), m_Sel.m_bScaleWithTransform);
            // --------------------------------------------------------------------------------------------------------------------------------------------
            if (m_Sel.GetComponent <ParticleEmitter>() != null && m_Sel.m_bScaleWithTransform && m_Sel.transform.lossyScale != Vector3.one)
            {
                Rect butRect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
                {
                    if (FXMakerLayout.GUIButton(butRect, GetHelpContent("Convert To Static Scale"), true))
                    {
                        ConvertToStaticScale(m_Sel.GetComponent <ParticleEmitter>(), m_Sel.GetComponent <ParticleAnimator>());
                        m_Sel.m_bScaleWithTransform = false;
                        return;
                    }
                    GUILayout.Label("");
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
            }

            // --------------------------------------------------------------------------------------------------------------------------------------------
            bool bWorldSpace = EditorGUILayout.Toggle(GetHelpContent("m_bWorldSpace"), m_Sel.m_bWorldSpace);
            // Set bWorldSpace
            if (m_Sel.m_bWorldSpace != bWorldSpace)
            {
                m_Sel.m_bWorldSpace = bWorldSpace;
                NgSerialized.SetSimulationSpaceWorld(m_Sel.transform, bWorldSpace);
            }
            // Update bWorldSpace
            if (m_Sel.m_bWorldSpace != NgSerialized.GetSimulationSpaceWorld(m_Sel.transform))
            {
                m_Sel.m_bWorldSpace = !m_Sel.m_bWorldSpace;
            }
            // --------------------------------------------------------------------------------------------------------------------------------------------

            m_Sel.m_fStartSizeRate     = EditorGUILayout.FloatField(GetHelpContent("m_fStartSizeRate"), m_Sel.m_fStartSizeRate);
            m_Sel.m_fStartLifeTimeRate = EditorGUILayout.FloatField(GetHelpContent("m_fStartLifeTimeRate"), m_Sel.m_fStartLifeTimeRate);
            m_Sel.m_fStartEmissionRate = EditorGUILayout.FloatField(GetHelpContent("m_fStartEmissionRate"), m_Sel.m_fStartEmissionRate);
            m_Sel.m_fStartSpeedRate    = EditorGUILayout.FloatField(GetHelpContent("m_fStartSpeedRate"), m_Sel.m_fStartSpeedRate);
            m_Sel.m_fRenderLengthRate  = EditorGUILayout.FloatField(GetHelpContent("m_fRenderLengthRate"), m_Sel.m_fRenderLengthRate);

            if (m_Sel.GetComponent <ParticleEmitter>() != null && NgSerialized.IsMeshParticleEmitter(m_Sel.GetComponent <ParticleEmitter>()))
            {
                m_Sel.m_fLegacyMinMeshNormalVelocity = EditorGUILayout.FloatField(GetHelpContent("m_fLegacyMinMeshNormalVelocity"), m_Sel.m_fLegacyMinMeshNormalVelocity);
                m_Sel.m_fLegacyMaxMeshNormalVelocity = EditorGUILayout.FloatField(GetHelpContent("m_fLegacyMaxMeshNormalVelocity"), m_Sel.m_fLegacyMaxMeshNormalVelocity);
            }

            if (m_Sel.GetComponent <ParticleSystem>() != null)
            {
                float fShurikenSpeedRate = EditorGUILayout.FloatField(GetHelpContent("m_fShurikenSpeedRate"), m_Sel.m_fShurikenSpeedRate);
                // Set particleSystem.speed
                if (m_Sel.m_fShurikenSpeedRate != fShurikenSpeedRate)
                {
                    m_Sel.m_fShurikenSpeedRate = fShurikenSpeedRate;
                    m_Sel.SaveShurikenSpeed();
                }
            }

            // m_ParticleDestruct
            m_Sel.m_ParticleDestruct = (NcParticleSystem.ParticleDestruct)EditorGUILayout.EnumPopup(GetHelpContent("m_ParticleDestruct"), m_Sel.m_ParticleDestruct, GUILayout.MaxWidth(Screen.width));
            if (m_Sel.m_ParticleDestruct != NcParticleSystem.ParticleDestruct.NONE)
            {
                if (m_Sel.m_ParticleDestruct == NcParticleSystem.ParticleDestruct.COLLISION)
                {
                    m_Sel.m_CollisionLayer   = LayerMaskField(GetHelpContent("m_CollisionLayer"), m_Sel.m_CollisionLayer);
                    m_Sel.m_fCollisionRadius = EditorGUILayout.FloatField(GetHelpContent("m_fCollisionRadius"), m_Sel.m_fCollisionRadius);
                }
                if (m_Sel.m_ParticleDestruct == NcParticleSystem.ParticleDestruct.WORLD_Y)
                {
                    m_Sel.m_fDestructPosY = EditorGUILayout.FloatField(GetHelpContent("m_fDestructPosY"), m_Sel.m_fDestructPosY);
                }
                m_Sel.m_AttachPrefab    = (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_AttachPrefab"), m_Sel.m_AttachPrefab, typeof(GameObject), false, null);
                m_Sel.m_fPrefabScale    = EditorGUILayout.FloatField(GetHelpContent("m_fPrefabScale"), m_Sel.m_fPrefabScale);
                m_Sel.m_fPrefabSpeed    = EditorGUILayout.FloatField(GetHelpContent("m_fPrefabSpeed"), m_Sel.m_fPrefabSpeed);
                m_Sel.m_fPrefabLifeTime = EditorGUILayout.FloatField(GetHelpContent("m_fPrefabLifeTime"), m_Sel.m_fPrefabLifeTime);

                SetMinValue(ref m_Sel.m_fCollisionRadius, 0.01f);
                SetMinValue(ref m_Sel.m_fPrefabScale, 0.01f);
                SetMinValue(ref m_Sel.m_fPrefabSpeed, 0.01f);
                SetMinValue(ref m_Sel.m_fPrefabLifeTime, 0);

                // --------------------------------------------------------------
                EditorGUILayout.Space();
                Rect attRect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
                {
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(attRect, 3, 0, 1), GetHelpContent("Select Prefab"), (m_FxmPopupManager != null)))
                    {
                        m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, true, 0);
                    }
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(attRect, 3, 1, 1), GetHelpContent("Clear Prefab"), (m_Sel.m_AttachPrefab != null)))
                    {
                        bClickButton         = true;
                        m_Sel.m_AttachPrefab = null;
                    }
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(attRect, 3, 2, 1), GetHelpContent("Open Prefab"), (m_FxmPopupManager != null) && (m_Sel.m_AttachPrefab != null)))
                    {
                        bClickButton = true;
                        GetFXMakerMain().OpenPrefab(m_Sel.m_AttachPrefab);
                        return;
                    }
                    GUILayout.Label("");
                }
                EditorGUILayout.EndHorizontal();
            }


            // ---------------------------------------------------------------------
            // current ParticleSystem
            EditorGUILayout.Space();
            Component currentParticle = null;
            Rect      rect            = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight * 3));
            {
                if ((currentParticle = m_Sel.gameObject.GetComponent <ParticleSystem>()) != null)
                {
                    ParticleSystemRenderer psr = m_Sel.gameObject.GetComponent <ParticleSystemRenderer>();
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 0, 2), GetHelpContent("Delete Shuriken Components"), true))
                    {
                        bClickButton = true;
                        Object.DestroyImmediate(currentParticle);
                        if (psr != null)
                        {
                            Object.DestroyImmediate(psr);
                        }
                    }
                    if (psr == null)
                    {
                        FXMakerLayout.GUIColorBackup(FXMakerLayout.m_ColorHelpBox);
                        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 2, 1), GetHelpContent("Add ParticleSystemRenderer"), true))
                        {
                            bClickButton = true;
                            m_Sel.gameObject.AddComponent <ParticleSystemRenderer>();
                        }
                        FXMakerLayout.GUIColorRestore();
                    }
                    else
                    {
                        FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 2, 1), "ParticleSystemRenderer", false);
                    }
                }
                else
                {
                    if ((currentParticle = m_Sel.gameObject.GetComponent <ParticleEmitter>()) != null)
                    {
                        ParticleAnimator pa = m_Sel.gameObject.GetComponent <ParticleAnimator>();
                        ParticleRenderer pr = m_Sel.gameObject.GetComponent <ParticleRenderer>();

                        if (currentParticle.ToString().Contains("EllipsoidParticleEmitter"))
                        {
                            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 0, 1), GetHelpContent("Delete Legacy(Ellipsoid) Components"), true))
                            {
                                bClickButton = true;
                                Object.DestroyImmediate(currentParticle);
                                if (pa != null)
                                {
                                    Object.DestroyImmediate(pa);
                                }
                                if (pr != null)
                                {
                                    Object.DestroyImmediate(pr);
                                }
                            }
                        }
                        else
                        {
                            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 0, 1), GetHelpContent("Delete Legacy(Mesh) Components"), true))
                            {
                                bClickButton = true;
                                Object.DestroyImmediate(currentParticle);
                                if (pa != null)
                                {
                                    Object.DestroyImmediate(pa);
                                }
                                if (pr != null)
                                {
                                    Object.DestroyImmediate(pr);
                                }
                            }
                        }

                        if (pa == null)
                        {
                            FXMakerLayout.GUIColorBackup(FXMakerLayout.m_ColorHelpBox);
                            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 1, 1), GetHelpContent("Add ParticleAnimator"), true))
                            {
                                bClickButton = true;
                                m_Sel.gameObject.AddComponent <ParticleAnimator>();
                            }
                            FXMakerLayout.GUIColorRestore();
                        }
                        else
                        {
                            FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 1, 1), "ParticleAnimator", false);
                        }
                        if (pr == null)
                        {
                            FXMakerLayout.GUIColorBackup(FXMakerLayout.m_ColorHelpBox);
                            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 2, 1), GetHelpContent("Add ParticleRenderer"), true))
                            {
                                bClickButton = true;
                                m_Sel.gameObject.AddComponent <ParticleRenderer>();
                            }
                            FXMakerLayout.GUIColorRestore();
                        }
                        else
                        {
                            FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 2, 1), "ParticleRenderer", false);
                        }
                    }
                }

                // ---------------------------------------------------------------------
                // Create ParticleSystem
                if (currentParticle == null)
                {
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 0, 1), GetHelpContent("Add Shuriken Components"), true))
                    {
                        bClickButton = true;
                        m_Sel.gameObject.AddComponent <ParticleSystem>();
                        if (m_Sel.gameObject.GetComponent <ParticleSystemRenderer>() == null)
                        {
                            m_Sel.gameObject.AddComponent <ParticleSystemRenderer>();
                        }
                    }
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 1, 1), GetHelpContent("Add Legacy(Ellipsoid) Components"), true))
                    {
                        bClickButton = true;
                        m_Sel.gameObject.AddComponent <EllipsoidParticleEmitter>();
                        if (m_Sel.gameObject.GetComponent <ParticleAnimator>() == null)
                        {
                            m_Sel.gameObject.AddComponent <ParticleAnimator>();
                        }
                        if (m_Sel.gameObject.GetComponent <ParticleRenderer>() == null)
                        {
                            m_Sel.gameObject.AddComponent <ParticleRenderer>();
                        }
                    }
                    if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 2, 1), GetHelpContent("Add Legacy(Mesh) Components"), true))
                    {
                        bClickButton = true;
                        m_Sel.gameObject.AddComponent <MeshParticleEmitter>();
                        if (m_Sel.gameObject.GetComponent <ParticleAnimator>() == null)
                        {
                            m_Sel.gameObject.AddComponent <ParticleAnimator>();
                        }
                        if (m_Sel.gameObject.GetComponent <ParticleRenderer>() == null)
                        {
                            m_Sel.gameObject.AddComponent <ParticleRenderer>();
                        }
                    }
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();
        }
        m_UndoManager.CheckDirty();
        // ---------------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
        {
            OnEditComponent();
        }
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
        {
            m_LastTooltip = GUI.tooltip;
        }
        HelpBox(m_LastTooltip);
    }
예제 #15
0
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);

        int				nClickIndex		= -1;
        int				nClickButton	= 0;
        Rect			rect;
        int				nLeftWidth		= 34;
        int				nAddHeight		= 30;
        int				nDelWidth		= 35;
        int				nLineHeight		= 18;
        int				nSpriteHeight	= nLeftWidth;
        List<NcSpriteFactory.NcSpriteNode>	spriteList = m_Sel.m_SpriteList;

        m_FxmPopupManager = GetFxmPopupManager();

        // --------------------------------------------------------------
        bool bClickButton = false;
        EditorGUI.BeginChangeCheck();
        {
            m_UndoManager.CheckUndo();
            // --------------------------------------------------------------
            m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

            EditorGUILayout.Space();
            m_Sel.m_SpriteType			= (NcSpriteFactory.SPRITE_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_SpriteType"), m_Sel.m_SpriteType);

            // --------------------------------------------------------------
            if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && m_Sel.gameObject.GetComponent("NcSpriteAnimation") == null)
            {
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
                {
                    if (FXMakerLayout.GUIButton(rect, GetHelpContent("Add NcSpriteAnimation Component"), true))
                        m_Sel.gameObject.AddComponent<NcSpriteAnimation>();
                    GUILayout.Label("");
                }
                EditorGUILayout.EndHorizontal();
            }
            // --------------------------------------------------------------
            if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteTexture && m_Sel.gameObject.GetComponent("NcSpriteTexture") == null)
            {
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
                {
                    if (FXMakerLayout.GUIButton(rect, GetHelpContent("Add NcSpriteTexture Component"), true))
                        m_Sel.gameObject.AddComponent<NcSpriteTexture>();
                    GUILayout.Label("");
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.Space();

            // --------------------------------------------------------------
            int		nSelIndex			= EditorGUILayout.IntSlider(GetHelpContent("m_nCurrentIndex")	, m_Sel.m_nCurrentIndex, 0, (spriteList==null ? 0 : spriteList.Count-1));
            float	fUvScale			= EditorGUILayout.FloatField(GetHelpContent("m_fUvScale")		, m_Sel.m_fUvScale);
            if (m_Sel.m_nCurrentIndex != nSelIndex || fUvScale != m_Sel.m_fUvScale)
            {
                m_Sel.m_nCurrentIndex	= nSelIndex;
                m_Sel.m_fUvScale		= fUvScale;
                m_Sel.SetSprite(nSelIndex, false);
            }

            // Rebuild Check
            EditorGUI.BeginChangeCheck();
            m_Sel.m_bTrimBlack			= EditorGUILayout.Toggle(GetHelpContent("m_bTrimBlack")			, m_Sel.m_bTrimBlack);
            m_Sel.m_bTrimAlpha			= EditorGUILayout.Toggle(GetHelpContent("m_bTrimAlpha")			, m_Sel.m_bTrimAlpha);
            m_Sel.m_nMaxAtlasTextureSize= EditorGUILayout.IntPopup("nMaxAtlasTextureSize", m_Sel.m_nMaxAtlasTextureSize, NgEnum.m_TextureSizeStrings, NgEnum.m_TextureSizeIntters);
        // 			m_Sel.m_AtlasMaterial		= (Material)EditorGUILayout.ObjectField(GetHelpContent("m_AtlasMaterial")	, m_Sel.m_AtlasMaterial, typeof(Material), false);
            if (EditorGUI.EndChangeCheck())
                m_Sel.m_bNeedRebuild = true;

            if (spriteList.Count <= m_Sel.m_nBuildStartIndex)
                m_Sel.m_nBuildStartIndex = 0;
            int nBuildStartIndex		= EditorGUILayout.IntSlider("m_nBuildStartIndex", m_Sel.m_nBuildStartIndex, 0, (spriteList==null ? 0 : spriteList.Count-1));
            if (spriteList != null && m_Sel.m_nBuildStartIndex < spriteList.Count && nBuildStartIndex != m_Sel.m_nBuildStartIndex)
            {
                for (int n = Mathf.Min(m_Sel.m_nBuildStartIndex, nBuildStartIndex); n < Mathf.Max(m_Sel.m_nBuildStartIndex, nBuildStartIndex); n++)
                    if (spriteList[n].IsUnused() == false && spriteList[n].IsEmptyTexture() == false)
                        m_Sel.m_bNeedRebuild = true;
                m_Sel.m_nBuildStartIndex	= nBuildStartIndex;
            }

            // SpriteResizeRate
            m_Sel.m_fSpriteResizeRate = EditorGUILayout.Slider("fSpriteResizeRate", m_Sel.m_fSpriteResizeRate, 0.1f, 1.0f);

            // nImageHeight
            nSpriteHeight	= PlayerPrefs.GetInt("FXMakerEditor.nFactorySpriteHeight", nSpriteHeight);
            nSpriteHeight	= EditorGUILayout.IntSlider("nSpriteHeight", nSpriteHeight, 0, 400);
            PlayerPrefs.SetInt("FXMakerEditor.nFactorySpriteHeight", nSpriteHeight);

            // Add Button ------------------------------------------------------
            EditorGUILayout.Space();
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nAddHeight*2));
            {
                Rect lineRect = FXMakerLayout.GetInnerVerticalRect(rect, 2, 0, 1);
                if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 0, 1), GetHelpContent("Add Sprite")))
                {
                    bClickButton	= true;
                    m_Sel.AddSpriteNode();
                }

                bool bHighLight = m_Sel.m_bNeedRebuild;
                if (bHighLight)
         			FXMakerLayout.GUIColorBackup(FXMakerLayout.m_ColorHelpBox);
                if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 1, 1), GetHelpContent("Build Sprite")))
                {
        #if UNITY_WEBPLAYER
        Debug.LogError("In WEB_PLAYER mode, you cannot run the FXMaker.");
        Debug.Break();
        #else
                    bClickButton	= true;
                    CreateSpriteAtlas(m_Sel.GetComponent<Renderer>().sharedMaterial);
                    m_Sel.m_bNeedRebuild = false;
        #endif
                }
                if (bHighLight)
                    FXMakerLayout.GUIColorRestore();
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 2, 1), GetHelpContent("Clear All"), (0 < m_Sel.GetSpriteNodeCount())))
                {
                    bClickButton	= true;
                    if (m_FxmPopupManager != null)
                        m_FxmPopupManager.CloseNcPrefabPopup();
                    m_Sel.ClearAllSpriteNode();
                }
                lineRect = FXMakerLayout.GetInnerVerticalRect(rect, 2, 1, 1);
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 0, 1), GetHelpContent("Sequence"), (0 < m_Sel.GetSpriteNodeCount())))
                {
                    m_Sel.m_bSequenceMode	= true;
                    bClickButton			= true;
                    m_Sel.SetSprite(0, false);
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 1, 1), GetHelpContent("NewMaterial"), true))
                {
                    Material	newMat		= new Material(m_Sel.GetComponent<Renderer>().sharedMaterial);
                    string		matPath		= AssetDatabase.GetAssetPath(m_Sel.GetComponent<Renderer>().sharedMaterial);
                    NgMaterial.SaveMaterial(newMat, NgFile.TrimFilenameExt(matPath), m_Sel.name);
                    m_Sel.GetComponent<Renderer>().sharedMaterial = newMat;
        // 					m_Sel.renderer.sharedMaterial = (Material)AssetDatabase.LoadAssetAtPath(savePath, typeof(Material));
                }

         				GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();

            // Select ShotType -------------------------------------------------
        //			showType		= (NcSpriteFactory.SHOW_TYPE)EditorGUILayout.EnumPopup		(GetHelpContent("m_ShowType")	, showType);
            // --------------------------------------------------------------
            EditorGUILayout.Space();
            NcSpriteFactory.SHOW_TYPE showType = (NcSpriteFactory.SHOW_TYPE)EditorPrefs.GetInt("NcSpriteFactory.SHOW_TYPE", 0);

            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
            {
                showType	= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 0, 1), showType==NcSpriteFactory.SHOW_TYPE.NONE		, GetHelpContent("NONE")		, true) ? NcSpriteFactory.SHOW_TYPE.NONE	: showType;
                showType	= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 1, 1), showType==NcSpriteFactory.SHOW_TYPE.ALL		, GetHelpContent("ALL")			, true) ? NcSpriteFactory.SHOW_TYPE.ALL		: showType;
                if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation || m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.Auto)
                {
                    showType= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 2, 1), showType==NcSpriteFactory.SHOW_TYPE.SPRITE	, GetHelpContent("SPRITE")		, true) ? NcSpriteFactory.SHOW_TYPE.SPRITE		: showType;
                    showType= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 3, 1), showType==NcSpriteFactory.SHOW_TYPE.ANIMATION, GetHelpContent("ANIMATION")	, true) ? NcSpriteFactory.SHOW_TYPE.ANIMATION	: showType;
                }
                showType	= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 4, 1), showType==NcSpriteFactory.SHOW_TYPE.EFFECT	, GetHelpContent("EFFECT")		, true) ? NcSpriteFactory.SHOW_TYPE.EFFECT		: showType;
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();

            EditorPrefs.SetInt("NcSpriteFactory.SHOW_TYPE", ((int)showType));

            // Show Option -------------------------------------------------
            EditorGUILayout.Space();
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
            {
                m_Sel.m_bShowEffect			= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 0, 1), m_Sel.m_bShowEffect	, GetHelpContent("m_bShowEffect")	, true);
                if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation || m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.Auto)
                {
                    m_Sel.m_bTestMode		= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 1, 1), m_Sel.m_bTestMode		, GetHelpContent("m_bTestMode")		, true);
                    m_Sel.m_bSequenceMode	= FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 2, 1), m_Sel.m_bSequenceMode	, GetHelpContent("m_bSequenceMode")	, true);
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();

            // Node List ------------------------------------------------------
            for (int n = 0; n < (spriteList != null ? spriteList.Count : 0); n++)
            {
                if (n < m_Sel.m_nBuildStartIndex)
                    continue;

                EditorGUILayout.Space();

                EditorGUI.BeginChangeCheck();
                // Load Texture ---------------------------------------------------------
                Texture2D	selTexture = null;
                if (spriteList[n].m_TextureGUID != "")
                    selTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(spriteList[n].m_TextureGUID), typeof(Texture2D));

                // Enabled --------------------------------------------------------------
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                {
                    Rect subRect;
                    EditorGUI.BeginChangeCheck();
                    // enable
                    spriteList[n].m_bIncludedAtlas = GUILayout.Toggle(spriteList[n].m_bIncludedAtlas, "Idx", GUILayout.Width(nLeftWidth));
                    // change index
                    subRect = rect;
                    subRect.x += nLeftWidth;
                    subRect.width = nLineHeight*2;
                    int newPos = EditorGUI.IntPopup(subRect, n, NgConvert.GetIntStrings(0, spriteList.Count), NgConvert.GetIntegers(0, spriteList.Count));
                    if (newPos != n)
                    {
                        NcSpriteFactory.NcSpriteNode node = spriteList[n];
                        m_Sel.m_SpriteList.Remove(node);
                        m_Sel.m_SpriteList.Insert(newPos, node);
                        return;
                    }
                    if (EditorGUI.EndChangeCheck())
                        m_Sel.m_bNeedRebuild = true;

                    // name
                    subRect = rect;
                    subRect.x += nLeftWidth+nLineHeight*2;
                    subRect.width -= nLeftWidth+nLineHeight*2;
         					spriteList[n].m_TextureName = selTexture==null ? "" : selTexture.name;
         					GUI.Label(subRect, (selTexture==null ? "" : "(" + spriteList[n].m_nFrameCount + ") " + selTexture.name));
                    GUI.Box(subRect, "");
                    GUI.Box(rect, "");

                    // delete
                    if (GUI.Button(new Rect(subRect.x+subRect.width-nDelWidth, subRect.y, nDelWidth, subRect.height), GetHelpContent("Del")))
                    {
                        m_Sel.m_bNeedRebuild = true;
                        bClickButton	= true;
                        if (m_FxmPopupManager != null)
                            m_FxmPopupManager.CloseNcPrefabPopup();
                        m_Sel.DeleteSpriteNode(n);
                        return;
                    }
                }
                EditorGUILayout.EndHorizontal();

                // SpriteName MaxAlpha -----------------------------------------------------------
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                {
                    GUILayout.Label("", GUILayout.Width(nLineHeight));
                    GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 7, 0, 2), "Name,fMaxAlpha");
                    spriteList[n].m_SpriteName			= EditorGUI.TextField(FXMakerLayout.GetInnerHorizontalRect(rect, 7, 2, 4), spriteList[n].m_SpriteName);
                    spriteList[n].m_fMaxTextureAlpha	= EditorGUI.FloatField(FXMakerLayout.GetInnerHorizontalRect(rect, 7, 6, 1), spriteList[n].m_fMaxTextureAlpha);
                }
                EditorGUILayout.EndHorizontal();

                // Texture --------------------------------------------------------------
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nSpriteHeight / (selTexture == null ? 2 : 1)));
                {
                    GUILayout.Label("", GUILayout.Width(nLeftWidth));

                    Rect subRect = rect;
                    subRect.width = nLeftWidth;
                    FXMakerLayout.GetOffsetRect(rect, 0, 5, 0, -5);
                    EditorGUI.BeginChangeCheck();
                    selTexture	= (Texture2D)EditorGUI.ObjectField(subRect, GetHelpContent(""), selTexture, typeof(Texture2D), false);
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (selTexture != null)
                            spriteList[n].m_TextureGUID	= AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(selTexture));
                        m_Sel.m_bNeedRebuild = true;
                    }

                    // draw texture
                    subRect = FXMakerLayout.GetOffsetRect(rect, nLeftWidth+4, 0, 0, -4);
                    Rect drawRect = FXMakerLayout.GetOffsetRect(subRect, 0, 0, -nDelWidth, 0);

                    if (selTexture != null)
                    {
                        // draw texture
                        GUI.DrawTexture(drawRect, selTexture, ScaleMode.ScaleToFit, true, selTexture.width/selTexture.height);

                        // draw tile
                        float	fDrawRatio	= drawRect.width / drawRect.height;
                        float	fImageRatio	= selTexture.width / selTexture.height;
                        if (fDrawRatio < fImageRatio)
                        {
                            drawRect = FXMakerLayout.GetVOffsetRect(drawRect, drawRect.height * -(1 - (fDrawRatio / fImageRatio)) / 2);
                        } else {
                            drawRect = FXMakerLayout.GetHOffsetRect(drawRect, drawRect.width * -(1 - (fImageRatio / fDrawRatio)) / 2);
                        }
                        float	tileWidth	= (drawRect.width  / spriteList[n].m_nTilingX);
                        float	tileHeight	= (drawRect.height / spriteList[n].m_nTilingY);
                        int		nCount		= 0;

                        for (int tn = spriteList[n].m_nStartFrame; tn < spriteList[n].m_nTilingX * spriteList[n].m_nTilingY; tn += spriteList[n].m_nSkipFrame+1, nCount++)
                        {
                            if (spriteList[n].m_nStartFrame + spriteList[n].m_nFrameCount <= nCount)
                                break;

                            int posx = tn % spriteList[n].m_nTilingX;
                            int posy = tn / spriteList[n].m_nTilingX;
                            Rect tileRect = new Rect(drawRect.x+posx*tileWidth, drawRect.y+posy*tileHeight, tileWidth, tileHeight);
                            NgGUIDraw.DrawBox(FXMakerLayout.GetOffsetRect(tileRect, -1), Color.green, 1, false);
                        }
                    }

                    // delete
                    if (GUI.Button(new Rect(subRect.x+subRect.width-nDelWidth, subRect.y, nDelWidth, subRect.height), GetHelpContent("Rmv")))
                        spriteList[n].SetEmpty();
                    GUI.Box(rect, "");
                }
                EditorGUILayout.EndHorizontal();

                // Change selIndex
                Event e = Event.current;
                if (e.type == EventType.MouseDown && rect.Contains(e.mousePosition))
                {
                    nClickIndex = n;
                    nClickButton = e.button;
                }

                // -----------------------------------------------------------------------------------------------------------------------------------------------
                if (spriteList[n].IsEmptyTexture() == false)
                {
                    // m_nSkipFrame
                    rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                    {
                        GUILayout.Label("", GUILayout.Width(nLineHeight));
                        GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 0, 4), "m_nSkipFrame");

                        EditorGUI.BeginChangeCheck();
                        spriteList[n].m_nSkipFrame		= EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 4, 1), spriteList[n].m_nSkipFrame);
                        SetMinValue(ref spriteList[n].m_nSkipFrame	, 0);
                        if (EditorGUI.EndChangeCheck())
                            m_Sel.m_bNeedRebuild = true;
                    }
                    EditorGUILayout.EndHorizontal();

                    // Frame tile
                    rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                    {
                        GUILayout.Label("", GUILayout.Width(nLineHeight));
                        GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 0, 4), "nTileXY,Start,Count");

                        // m_nTilingX, m_nTilingY
                        EditorGUI.BeginChangeCheck();
                        spriteList[n].m_nTilingX		= EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 4, 1), spriteList[n].m_nTilingX);
                        spriteList[n].m_nTilingY		= EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 5, 1), spriteList[n].m_nTilingY);
                        SetMinValue(ref spriteList[n].m_nTilingX	, 1);
                        SetMinValue(ref spriteList[n].m_nTilingY	, 1);
                        if (EditorGUI.EndChangeCheck())
                        {
                            spriteList[n].m_nFrameCount	= (spriteList[n].m_nTilingX*spriteList[n].m_nTilingY-spriteList[n].m_nStartFrame) / spriteList[n].m_nSkipFrame;
                            m_Sel.m_bNeedRebuild = true;
                        }

                        // m_nStartFrame, m_nFrameCount
                        EditorGUI.BeginChangeCheck();
                        spriteList[n].m_nStartFrame		= EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 6, 1), spriteList[n].m_nStartFrame);
                        spriteList[n].m_nFrameCount		= EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 7, 1), spriteList[n].m_nFrameCount);
                        SetMaxValue(ref spriteList[n].m_nStartFrame	, spriteList[n].m_nTilingX*spriteList[n].m_nTilingY-1);
                        SetMinValue(ref spriteList[n].m_nStartFrame	, 0);
                        SetMaxValue(ref spriteList[n].m_nFrameCount	, (spriteList[n].m_nTilingX*spriteList[n].m_nTilingY-spriteList[n].m_nStartFrame) / (spriteList[n].m_nSkipFrame+1));
                        SetMinValue(ref spriteList[n].m_nFrameCount	, 1);
                        if (EditorGUI.EndChangeCheck())
                            m_Sel.m_bNeedRebuild = true;
                    }
                    EditorGUILayout.EndHorizontal();

                    // SpriteNode ----------------------------------------------------------
                    if (bClickButton == false)
                    {
                        if ((m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation || m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.Auto) && (showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.SPRITE))
                        {
                            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                            {
                                GUILayout.Label("", GUILayout.Width(nLineHeight));
                                GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 0, 4), "Loop,Start,FCnt,LCnt");

                                bool bOldLoop = spriteList[n].m_bLoop;
                                spriteList[n].m_bLoop				= EditorGUI.Toggle	(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 4, 1), spriteList[n].m_bLoop);
                                if (!bOldLoop && spriteList[n].m_bLoop)
                                {
                                    spriteList[n].m_nLoopStartFrame	= 0;
                                    spriteList[n].m_nLoopFrameCount	= spriteList[n].m_nFrameCount;
                                    spriteList[n].m_nLoopingCount	= 0;
                                }
                                if (spriteList[n].m_bLoop)
                                {
                                    spriteList[n].m_nLoopStartFrame	= EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 5, 1), spriteList[n].m_nLoopStartFrame);
                                    spriteList[n].m_nLoopFrameCount	= EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 6, 1), spriteList[n].m_nLoopFrameCount);
                                    spriteList[n].m_nLoopingCount	= EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 7, 1), spriteList[n].m_nLoopingCount);
                                }
                                // check
                                SetMaxValue(ref spriteList[n].m_nLoopStartFrame, spriteList[n].m_nFrameCount-1);
                                SetMinValue(ref spriteList[n].m_nLoopStartFrame, 0);
                                SetMaxValue(ref spriteList[n].m_nLoopFrameCount, spriteList[n].m_nFrameCount-spriteList[n].m_nLoopStartFrame);
                                SetMinValue(ref spriteList[n].m_nLoopingCount, 0);
                            }
                            EditorGUILayout.EndHorizontal();

                            spriteList[n].m_fFps				= EditorGUILayout.Slider	(GetHelpContent("m_fFps")	, spriteList[n].m_nFrameCount/spriteList[n].m_fTime, 50, 1, null);
                            spriteList[n].m_fTime				= EditorGUILayout.Slider	(GetHelpContent("m_fTime")	, spriteList[n].m_nFrameCount/spriteList[n].m_fFps, 0, 5, null);
                        }

                        if ((m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation || m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.Auto) && (showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.ANIMATION))
                        {
                            spriteList[n].m_nNextSpriteIndex= EditorGUILayout.Popup			("m_nNextSpriteIndex"		, spriteList[n].m_nNextSpriteIndex+1, GetSpriteNodeNames()) - 1;
                            if (0 <= spriteList[n].m_nNextSpriteIndex)
                            {
                                spriteList[n].m_nTestMode		= EditorGUILayout.Popup		("m_nTestMode"				, spriteList[n].m_nTestMode, NgConvert.ContentsToStrings(FxmTestControls.GetHcEffectControls_Trans(FxmTestControls.AXIS.Z)), GUILayout.MaxWidth(Screen.width));
                                spriteList[n].m_fTestSpeed		= EditorGUILayout.FloatField("m_fTestSpeed"				, spriteList[n].m_fTestSpeed);

                                SetMinValue(ref spriteList[n].m_fTestSpeed, 0.01f);
                            }
                        }

                        if (showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.EFFECT)
                        {
                            EditorGUILayout.Separator();
                            // char effect -------------------------------------------------------------
                            spriteList[n].m_EffectPrefab	= (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_EffectPrefab")	, spriteList[n].m_EffectPrefab, typeof(GameObject), false, null);

                            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight*0.7f));
                            {
                                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 0, 1), GetHelpContent("SelEffect"), (m_FxmPopupManager != null)))
                                    m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, n, 0, true);
                                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 1, 1), GetHelpContent("ClearEffect"), (spriteList[n].m_EffectPrefab != null)))
                                {
                                    bClickButton = true;
                                    spriteList[n].m_EffectPrefab = null;
                                }
                                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 2, 1), GetHelpContent("OpenEffect"), (m_FxmPopupManager != null) && (spriteList[n].m_EffectPrefab != null)))
                                {
                                    bClickButton = true;
                                    GetFXMakerMain().OpenPrefab(spriteList[n].m_EffectPrefab);
                                    return;
                                }
                                GUILayout.Label("");
                            }
                            EditorGUILayout.EndHorizontal();

                            if (spriteList[n].m_EffectPrefab != null)
                            {
                                // m_nSpriteFactoryIndex
                                EditorGUILayout.Space();
                                if (spriteList[n].m_EffectPrefab)
                                {
                                    NcSpriteFactory ncSpriteFactory = spriteList[n].m_EffectPrefab.GetComponent<NcSpriteFactory>();
                                    if (ncSpriteFactory)
                                    {
                                        spriteList[n].m_nSpriteFactoryIndex = EditorGUILayout.IntSlider(GetHelpContent("m_nSpriteFactoryIndex"), spriteList[n].m_nSpriteFactoryIndex, -1, ncSpriteFactory.GetSpriteNodeCount()-1);

                                        string[]	spriteNames = new string[ncSpriteFactory.GetSpriteNodeCount()+1];
                                        spriteNames[0] = "Default";
                                        for (int ni = 0; ni < ncSpriteFactory.GetSpriteNodeCount(); ni++)
                                            spriteNames[ni+1] = ncSpriteFactory.GetSpriteNode(ni).m_SpriteName;
                                        spriteList[n].m_nSpriteFactoryIndex = EditorGUILayout.Popup("SpriteName", spriteList[n].m_nSpriteFactoryIndex+1, spriteNames)-1;
                                    } else spriteList[n].m_nSpriteFactoryIndex = -1;
                                } else spriteList[n].m_nSpriteFactoryIndex = -1;

                                spriteList[n].m_bEffectInstantiate	= EditorGUILayout.Toggle	(GetHelpContent("m_bEffectInstantiate"), spriteList[n].m_bEffectInstantiate);

                                if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation || m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.Auto)
                                {
                                    spriteList[n].m_nEffectFrame	= EditorGUILayout.IntSlider		(GetHelpContent("m_nEffectFrame")		, spriteList[n].m_nEffectFrame, 0, spriteList[n].m_nFrameCount, null);

                                    rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                                    {
                                        GUILayout.Label("", GUILayout.Width(nLineHeight));
                                        GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 0, 2), "bOnlyFirst,bEffDetach");
                                        spriteList[n].m_bEffectOnlyFirst= EditorGUI.Toggle	(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 2, 1), spriteList[n].m_bEffectOnlyFirst);
                                        spriteList[n].m_bEffectDetach	= EditorGUI.Toggle	(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 3, 1), spriteList[n].m_bEffectDetach);
                                    }
                                    EditorGUILayout.EndHorizontal();
                                }
                                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                                {
                                    GUILayout.Label("", GUILayout.Width(nLineHeight));
                                    GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 0, 2), "fSpeed, fScale");
                                    spriteList[n].m_fEffectSpeed	= EditorGUI.FloatField	(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 2, 1), spriteList[n].m_fEffectSpeed);
                                    spriteList[n].m_fEffectScale	= EditorGUI.FloatField	(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 3, 1), spriteList[n].m_fEffectScale);
                                }
                                EditorGUILayout.EndHorizontal();

                                spriteList[n].m_EffectPos			= EditorGUILayout.Vector3Field	("m_EffectPos"			, spriteList[n].m_EffectPos, null);
                                spriteList[n].m_EffectRot			= EditorGUILayout.Vector3Field	("m_EffectRot"			, spriteList[n].m_EffectRot, null);

                                SetMinValue(ref spriteList[n].m_fEffectScale, 0.001f);
                            }

                            EditorGUILayout.Space();

                            // char sound -------------------------------------------------------------
                            spriteList[n].m_AudioClip		= (AudioClip)EditorGUILayout.ObjectField(GetHelpContent("m_AudioClip")		, spriteList[n].m_AudioClip, typeof(AudioClip), false, null);

                            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight*0.7f));
                            {
        // 							if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("SelAudio"), (m_FxmPopupManager != null)))
        //								m_FxmPopupManager.ShowSelectAudioClipPopup(m_Sel);
                                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("ClearAudio"), (spriteList[n].m_AudioClip != null)))
                                {
                                    bClickButton = true;
                                    spriteList[n].m_AudioClip = null;
                                }
                                GUILayout.Label("");
                            }
                            EditorGUILayout.EndHorizontal();

                            if (spriteList[n].m_AudioClip != null)
                            {
                                if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation || m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.Auto)
                                {
                                    spriteList[n].m_nSoundFrame		= EditorGUILayout.IntSlider	(GetHelpContent("m_nSoundFrame")		, spriteList[n].m_nSoundFrame, 0, spriteList[n].m_nFrameCount, null);
                                    spriteList[n].m_bSoundOnlyFirst	= EditorGUILayout.Toggle	(GetHelpContent("m_bSoundOnlyFirst")	, spriteList[n].m_bSoundOnlyFirst);
                                }
                                spriteList[n].m_bSoundLoop			= EditorGUILayout.Toggle	(GetHelpContent("m_bSoundLoop")			, spriteList[n].m_bSoundLoop);
                                spriteList[n].m_fSoundVolume		= EditorGUILayout.Slider	(GetHelpContent("m_fSoundVolume")		, spriteList[n].m_fSoundVolume, 0, 1.0f, null);
                                spriteList[n].m_fSoundPitch			= EditorGUILayout.Slider	(GetHelpContent("m_fSoundPitch")		, spriteList[n].m_fSoundPitch, -3, 3.0f, null);
                            }
                        }
                    }
                }

                if (EditorGUI.EndChangeCheck())
                    nClickIndex = n;

                selTexture = null;
            }

            // Select Node ----------------------------------------------------
            if (0 <= nClickIndex)
            {
                m_Sel.SetSprite(nClickIndex, false);
                if (m_Sel.m_bTestMode && 0 <= spriteList[nClickIndex].m_nTestMode && GetFXMakerMain())
                    GetFXMakerMain().GetFXMakerControls().SetTransIndex(spriteList[nClickIndex].m_nTestMode, (4 <= spriteList[nClickIndex].m_nTestMode ? 1.8f : 1.0f), spriteList[nClickIndex].m_fTestSpeed);
                // Rotate
                if (nClickButton == 1)
                    m_Sel.transform.Rotate(0, 180, 0);
                nClickIndex		= -1;
                bClickButton	= true;
            }

            m_UndoManager.CheckDirty();
        }
        // --------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
            OnEditComponent();
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
            m_LastTooltip	= GUI.tooltip;
        HelpBox(m_LastTooltip);
    }
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);
        m_UndoManager.CheckUndo();

        Rect rect;

        m_FxmPopupManager = GetFxmPopupManager();

        // --------------------------------------------------------------
        bool bClickButton = false;

        EditorGUI.BeginChangeCheck();
        {
//			DrawDefaultInspector();
            m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

            m_Sel.m_ParticlePrefab = (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_ParticlePrefab"), m_Sel.m_ParticlePrefab, typeof(GameObject), false, null);
            // --------------------------------------------------------------
            EditorGUILayout.Space();
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
            {
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 0, 2), GetHelpContent("SelectParticlePrefab"), (m_FxmPopupManager != null)))
                {
                    m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, true, 0);
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 2, 1), GetHelpContent("ClearPrefab"), (m_Sel.m_ParticlePrefab != null)))
                {
                    bClickButton           = true;
                    m_Sel.m_ParticlePrefab = null;
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 3, 1), GetHelpContent("OpenPrefab"), (m_FxmPopupManager != null) && (m_Sel.m_ParticlePrefab != null)))
                {
                    bClickButton = true;
                    GetFXMakerMain().OpenPrefab(m_Sel.m_ParticlePrefab);
                    return;
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            // --------------------------------------------------------------

            m_Sel.m_fDelayTime            = EditorGUILayout.FloatField(GetHelpContent("m_fDelayTime"), m_Sel.m_fDelayTime);
            m_Sel.m_nNumberOfArms         = EditorGUILayout.IntField(GetHelpContent("m_nNumberOfArms"), m_Sel.m_nNumberOfArms);
            m_Sel.m_nParticlesPerArm      = EditorGUILayout.IntField(GetHelpContent("m_nParticlesPerArm"), m_Sel.m_nParticlesPerArm);
            m_Sel.m_fParticleSeparation   = EditorGUILayout.FloatField(GetHelpContent("m_fParticleSeparation"), m_Sel.m_fParticleSeparation);
            m_Sel.m_fTurnDistance         = EditorGUILayout.FloatField(GetHelpContent("m_fTurnDistance"), m_Sel.m_fTurnDistance);
            m_Sel.m_fVerticalTurnDistance = EditorGUILayout.FloatField(GetHelpContent("m_fVerticalTurnDistance"), m_Sel.m_fVerticalTurnDistance);
            m_Sel.m_fOriginOffset         = EditorGUILayout.FloatField(GetHelpContent("m_fOriginOffset"), m_Sel.m_fOriginOffset);
            m_Sel.m_fTurnSpeed            = EditorGUILayout.FloatField(GetHelpContent("m_fTurnSpeed"), m_Sel.m_fTurnSpeed);
            m_Sel.m_fFadeValue            = EditorGUILayout.FloatField(GetHelpContent("m_fFadeValue"), m_Sel.m_fFadeValue);
            m_Sel.m_fSizeValue            = EditorGUILayout.FloatField(GetHelpContent("m_fSizeValue"), m_Sel.m_fSizeValue);
            m_Sel.m_nNumberOfSpawns       = EditorGUILayout.IntField(GetHelpContent("m_nNumberOfSpawns"), m_Sel.m_nNumberOfSpawns);
            m_Sel.m_fSpawnRate            = EditorGUILayout.FloatField(GetHelpContent("m_fSpawnRate"), m_Sel.m_fSpawnRate);

            Rect butRect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight * 2));
            {
                if (FXMakerLayout.GUIButton(butRect, GetHelpContent("Randomize"), true))
                {
                    m_Sel.RandomizeEditor();
                    bClickButton = true;
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            SetMinValue(ref m_Sel.m_fDelayTime, 0);
            SetMinValue(ref m_Sel.m_nNumberOfArms, 1);
            SetMinValue(ref m_Sel.m_nParticlesPerArm, 1);
            SetMinValue(ref m_Sel.m_fFadeValue, -1);
            SetMaxValue(ref m_Sel.m_fFadeValue, 1);
            SetMinValue(ref m_Sel.m_nNumberOfSpawns, 1);
            SetMinValue(ref m_Sel.m_fSpawnRate, 0.1f);
        }
        m_UndoManager.CheckDirty();
        // --------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
        {
            OnEditComponent();
        }
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
        {
            m_LastTooltip = GUI.tooltip;
        }
        HelpBox(m_LastTooltip);
    }
예제 #17
0
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);
        m_UndoManager.CheckUndo();

        Rect rect;

        m_FxmPopupManager = GetFxmPopupManager();

        // --------------------------------------------------------------
        bool bClickButton = false;

        EditorGUI.BeginChangeCheck();
        {
//			DrawDefaultInspector();
            m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag);

            m_Sel.m_NcSpriteFactoryPrefab = (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_NcSpriteFactoryPrefab"), m_Sel.m_NcSpriteFactoryPrefab, typeof(GameObject), false, null);
            NcSpriteFactory ncSpriteFactory = (m_Sel.m_NcSpriteFactoryPrefab == null ? null : m_Sel.m_NcSpriteFactoryPrefab.GetComponent <NcSpriteFactory>());
            if (ncSpriteFactory != null)
            {
                int nSelIndex = EditorGUILayout.IntSlider(GetHelpContent("m_nSpriteFactoryIndex"), m_Sel.m_nSpriteFactoryIndex, 0, ncSpriteFactory.GetSpriteNodeCount() - 1);
                if (m_Sel.m_nSpriteFactoryIndex != nSelIndex)
                {
                    m_Sel.m_nSpriteFactoryIndex     = nSelIndex;
                    ncSpriteFactory.m_nCurrentIndex = nSelIndex;
                }
            }

            // --------------------------------------------------------------
            if (m_Sel.m_NcSpriteFactoryPrefab != null && m_Sel.m_NcSpriteFactoryPrefab.renderer != null && m_Sel.renderer)
            {
                if (m_Sel.m_NcSpriteFactoryPrefab.renderer.sharedMaterial != m_Sel.renderer.sharedMaterial)
                {
                    m_Sel.UpdateSpriteMaterial();
                }
            }

            // --------------------------------------------------------------
            EditorGUILayout.Space();
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight));
            {
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("Select SpriteFactory"), (m_FxmPopupManager != null)))
                {
                    m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, true, 0);
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("Clear SpriteFactory"), (m_Sel.m_NcSpriteFactoryPrefab != null)))
                {
                    bClickButton = true;
                    m_Sel.m_NcSpriteFactoryPrefab = null;
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();
            // --------------------------------------------------------------

            if (ncSpriteFactory != null)
            {
                // Texture --------------------------------------------------------------
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(200));
                {
                    GUI.Box(rect, "");
                    GUILayout.Label("");

                    Rect subRect = rect;
                    FXMakerLayout.GetOffsetRect(rect, 0, 5, 0, -5);

                    // draw texture
                    if (m_Sel.renderer != null && m_Sel.renderer.sharedMaterial != null && m_Sel.renderer.sharedMaterial.mainTexture != null)
                    {
                        GUI.DrawTexture(subRect, m_Sel.renderer.sharedMaterial.mainTexture, ScaleMode.StretchToFill, true);

                        Event ev = Event.current;

                        for (int n = 0; n < ncSpriteFactory.GetSpriteNodeCount(); n++)
                        {
                            NcSpriteFactory.NcSpriteNode ncSNode = ncSpriteFactory.GetSpriteNode(n);

                            // draw indexRect
                            Rect currRect = new Rect(rect.x + ncSNode.m_UvRect.xMin * rect.width, rect.y + (1 - ncSNode.m_UvRect.yMin - ncSNode.m_UvRect.height) * rect.height, ncSNode.m_UvRect.width * rect.width, ncSNode.m_UvRect.height * rect.height);
                            NgGUIDraw.DrawBox(FXMakerLayout.GetOffsetRect(currRect, 0), (m_Sel.m_nSpriteFactoryIndex == n ? Color.green : Color.red), 1, false);
                            GUI.DrawTexture(subRect, m_Sel.renderer.sharedMaterial.mainTexture, ScaleMode.StretchToFill, true);

                            // Change selIndex
                            if ((ev.type == EventType.MouseDown) && currRect.Contains(ev.mousePosition))
                            {
                                m_Sel.m_nSpriteFactoryIndex     = n;
                                ncSpriteFactory.m_nCurrentIndex = n;
                                // Rotate
                                if (ev.button == 1)
                                {
                                    m_Sel.transform.Rotate(0, 180, 0);
                                }
                                bClickButton = true;
                            }
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                m_Sel.m_nSpriteFactoryIndex = -1;
            }
        }
        m_UndoManager.CheckDirty();
        // --------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
        {
            GetFXMakerMain().CreateCurrentInstanceEffect(true);
        }
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
        {
            m_LastTooltip = GUI.tooltip;
        }
        HelpBox(m_LastTooltip);
    }