Example #1
0
    // -------------------------------------------------------------------------------------------
    public string[] GetPlayContents()
    {
        int nRepeatIndex = 3;

        GUIContent[] cons = FxmTestControls.GetHcEffectControls_Play(0, 0, m_fPlayToolbarTimes[1], m_fPlayToolbarTimes[nRepeatIndex], m_fPlayToolbarTimes[nRepeatIndex + 1], m_fPlayToolbarTimes[nRepeatIndex + 2], m_fPlayToolbarTimes[nRepeatIndex + 3], m_fPlayToolbarTimes[nRepeatIndex + 4]);
        return(NgConvert.ContentsToStrings(cons));
    }
    public string[] GetPlayContents()
    {
        int num = 3;

        GUIContent[] hcEffectControls_Play = FxmTestControls.GetHcEffectControls_Play(0f, 0f, this.m_fPlayToolbarTimes[1], this.m_fPlayToolbarTimes[num], this.m_fPlayToolbarTimes[num + 1], this.m_fPlayToolbarTimes[num + 2], this.m_fPlayToolbarTimes[num + 3], this.m_fPlayToolbarTimes[num + 4]);
        return(NgConvert.ContentsToStrings(hcEffectControls_Play));
    }
Example #3
0
 public FxmTestControls GetFXMakerControls()
 {
     if (m_FXMakerControls == null)
     {
         m_FXMakerControls = GetComponent <FxmTestControls>();
     }
     return(m_FXMakerControls);
 }
Example #4
0
 public FxmTestControls GetFXMakerControls()
 {
     if (this.m_FXMakerControls == null)
     {
         this.m_FXMakerControls = base.GetComponent <FxmTestControls>();
     }
     return(this.m_FXMakerControls);
 }
Example #5
0
	public void SimulateMove(FxmTestControls.AXIS nTransAxis, float fHalfDist, float fSpeed, bool bRotFront)
	{
		Vector3	pos	= transform.position;
		m_nAxis		= nTransAxis;
		m_StartPos	= pos;
		m_EndPos	= pos;
		m_StartPos[(int)m_nAxis] -= fHalfDist;
		m_EndPos[(int)m_nAxis] += fHalfDist;
		m_fDist		= Vector3.Distance(m_StartPos, m_EndPos);
		m_Mode		= MODE_TYPE.MOVE;
		SimulateStart(m_StartPos, fSpeed, bRotFront);
	}
    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 FxmTestControls GetFXMakerControls()
 {
     if (m_FXMakerControls == null)
         m_FXMakerControls = GetComponent<FxmTestControls>();
     return m_FXMakerControls;
 }
Example #8
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);
    }
Example #9
0
    private void winActionToolbar(int id)
    {
        Rect   actionToolbarRect = this.GetActionToolbarRect();
        string text  = string.Empty;
        string str   = string.Empty;
        int    num   = 10;
        int    count = 5;

        this.m_bMinimize = GUI.Toggle(new Rect(3f, 1f, FXMakerLayout.m_fMinimizeClickWidth, FXMakerLayout.m_fMinimizeClickHeight), this.m_bMinimize, "Mini");
        if (GUI.changed)
        {
            PlayerPrefs.SetInt("FxmTestControls.m_bMinimize", (!this.m_bMinimize) ? 0 : 1);
        }
        GUI.changed = false;
        Rect childVerticalRect;
        Rect innerHorizontalRect;

        if (FXMakerLayout.m_bMinimizeAll || this.m_bMinimize)
        {
            count             = 1;
            childVerticalRect = FXMakerLayout.GetChildVerticalRect(actionToolbarRect, 0, count, 0, 1);
            if (FxmTestMain.inst.IsCurrentEffectObject())
            {
                text = string.Format("P={0} M={1} T={2}", this.m_nParticleCount, this.m_nMeshCount, this.m_nTriangles);
                str  = string.Format("ParticleCount = {0} MeshCount = {1}\n Mesh: Triangles = {2} Vertices = {3}", new object[]
                {
                    this.m_nParticleCount,
                    this.m_nMeshCount,
                    this.m_nTriangles,
                    this.m_nVertices
                });
            }
            GUI.Box(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 0, 2), text);
            if (FxmTestMain.inst.IsCurrentEffectObject())
            {
                float rightValue = (3 > this.m_nPlayIndex) ? 10f : this.m_fPlayToolbarTimes[this.m_nPlayIndex];
                childVerticalRect = FXMakerLayout.GetChildVerticalRect(actionToolbarRect, 0, count, 0, 1);
                GUI.Box(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 2, 2), "ElapsedTime " + (Time.time - this.m_fPlayStartTime).ToString("0.000"));
                innerHorizontalRect    = FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 4, 4);
                innerHorizontalRect.y += 5f;
                GUI.HorizontalSlider(innerHorizontalRect, Time.time - this.m_fPlayStartTime, 0f, rightValue);
                childVerticalRect = FXMakerLayout.GetChildVerticalRect(actionToolbarRect, 0, count, 0, 1);
                if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 8, 2), "Restart"))
                {
                    this.CreateInstanceEffect();
                }
            }
            return;
        }
        childVerticalRect = FXMakerLayout.GetChildVerticalRect(actionToolbarRect, 0, count, 0, 2);
        if (NcEffectBehaviour.GetRootInstanceEffect())
        {
            text = string.Format("P = {0}\nM = {1}\nT = {2}", this.m_nParticleCount, this.m_nMeshCount, this.m_nTriangles);
            str  = string.Format("ParticleCount = {0} MeshCount = {1}\n Mesh: Triangles = {2} Vertices = {3}", new object[]
            {
                this.m_nParticleCount,
                this.m_nMeshCount,
                this.m_nTriangles,
                this.m_nVertices
            });
        }
        GUI.Box(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 0, 1), new GUIContent(text, this.NgTooltipTooltip(str)));
        if (FxmTestMain.inst.IsCurrentEffectObject())
        {
            bool         flag = false;
            GUIContent[] hcEffectControls_Play = FxmTestControls.GetHcEffectControls_Play(0f, this.m_fTimeScale, this.m_fPlayToolbarTimes[1], this.m_fPlayToolbarTimes[3], this.m_fPlayToolbarTimes[4], this.m_fPlayToolbarTimes[5], this.m_fPlayToolbarTimes[6], this.m_fPlayToolbarTimes[7]);
            childVerticalRect = FXMakerLayout.GetChildVerticalRect(actionToolbarRect, 0, count, 0, 1);
            GUI.Box(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 1, 1), new GUIContent("Play", string.Empty));
            int nPlayIndex = GUI.SelectionGrid(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 2, 8), this.m_nPlayIndex, hcEffectControls_Play, hcEffectControls_Play.Length);
            if (GUI.changed)
            {
                flag = true;
            }
            GUIContent[] hcEffectControls_Trans = FxmTestControls.GetHcEffectControls_Trans(this.m_nTransAxis);
            childVerticalRect = FXMakerLayout.GetChildVerticalRect(actionToolbarRect, 0, count, 1, 1);
            GUI.Box(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 1, 1), new GUIContent("Trans", string.Empty));
            int num2 = GUI.SelectionGrid(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 2, 8), this.m_nTransIndex, hcEffectControls_Trans, hcEffectControls_Trans.Length);
            if (GUI.changed)
            {
                flag = true;
                if ((num2 == 1 || num2 == 2) && Input.GetMouseButtonUp(1))
                {
                    if (this.m_nTransAxis == FxmTestControls.AXIS.Z)
                    {
                        this.m_nTransAxis = FxmTestControls.AXIS.X;
                    }
                    else
                    {
                        this.m_nTransAxis++;
                    }
                    PlayerPrefs.SetInt("FxmTestControls.m_nTransAxis", (int)this.m_nTransAxis);
                }
            }
            if (flag)
            {
                FxmTestMain.inst.CreateCurrentInstanceEffect(false);
                this.RunActionControl(nPlayIndex, num2);
                PlayerPrefs.SetInt("FxmTestControls.m_nPlayIndex", this.m_nPlayIndex);
                PlayerPrefs.SetInt("FxmTestControls.m_nTransIndex", this.m_nTransIndex);
            }
        }
        float num3 = this.m_fDistPerTime;

        childVerticalRect = FXMakerLayout.GetChildVerticalRect(actionToolbarRect, 0, count, 2, 1);
        GUIContent gUIContent = new GUIContent("DistPerTime", string.Empty);
        GUIContent expr_471   = gUIContent;

        expr_471.text = expr_471.text + " " + this.m_fDistPerTime.ToString("00.00");
        GUI.Box(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 0, 2), gUIContent);
        innerHorizontalRect    = FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 2, 5);
        innerHorizontalRect.y += 5f;
        num3 = GUI.HorizontalSlider(innerHorizontalRect, num3, 0.1f, 40f);
        if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num * 2, 14, 1), new GUIContent("<", string.Empty)))
        {
            num3 = (float)((int)(num3 - 1f));
        }
        if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num * 2, 15, 1), new GUIContent(">", string.Empty)))
        {
            num3 = (float)((int)(num3 + 1f));
        }
        if (num3 != this.m_fDistPerTime)
        {
            this.m_fDistPerTime = ((num3 != 0f) ? num3 : 0.1f);
            PlayerPrefs.SetFloat("FxmTestControls.m_fDistPerTime", this.m_fDistPerTime);
            if (0 < this.m_nTransIndex)
            {
                this.CreateInstanceEffect();
            }
        }
        if (NgLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 9, 1), new GUIContent("Multi", this.m_nMultiShotCount.ToString()), true))
        {
            if (Input.GetMouseButtonUp(0))
            {
                this.m_nMultiShotCount++;
                if (4 < this.m_nMultiShotCount)
                {
                    this.m_nMultiShotCount = 1;
                }
            }
            else
            {
                this.m_nMultiShotCount = 1;
            }
            this.CreateInstanceEffect();
        }
        GUIContent[] hcEffectControls_Rotate = FxmTestControls.GetHcEffectControls_Rotate();
        childVerticalRect = FXMakerLayout.GetChildVerticalRect(actionToolbarRect, 0, count, 2, 1);
        int num4 = GUI.SelectionGrid(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 8, 1), this.m_nRotateIndex, hcEffectControls_Rotate, hcEffectControls_Rotate.Length);

        if (num4 != this.m_nRotateIndex)
        {
            this.m_nRotateIndex = num4;
            PlayerPrefs.SetInt("FxmTestControls.m_nRotateIndex", this.m_nRotateIndex);
            if (0 < this.m_nTransIndex)
            {
                this.CreateInstanceEffect();
            }
        }
        float num5 = this.m_fTimeScale;

        childVerticalRect = FXMakerLayout.GetChildVerticalRect(actionToolbarRect, 0, count, 3, 1);
        gUIContent        = new GUIContent("TimeScale", string.Empty);
        GUIContent expr_681 = gUIContent;

        expr_681.text = expr_681.text + " " + this.m_fTimeScale.ToString("0.00");
        GUI.Box(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 0, 2), gUIContent);
        innerHorizontalRect    = FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 2, 5);
        innerHorizontalRect.y += 5f;
        num5 = GUI.HorizontalSlider(innerHorizontalRect, num5, 0f, 3f);
        if (num5 == 0f)
        {
            if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 7, 1), new GUIContent("Resume", string.Empty)))
            {
                num5 = this.m_fOldTimeScale;
            }
        }
        else if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 7, 1), new GUIContent("Pause", string.Empty)))
        {
            num5 = 0f;
        }
        if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 8, 1), new GUIContent("Reset", string.Empty)))
        {
            num5 = 1f;
        }
        this.SetTimeScale(num5);
        if (FxmTestMain.inst.IsCurrentEffectObject())
        {
            float rightValue2 = (3 > this.m_nPlayIndex) ? 10f : this.m_fPlayToolbarTimes[this.m_nPlayIndex];
            childVerticalRect = FXMakerLayout.GetChildVerticalRect(actionToolbarRect, 0, count, 4, 1);
            gUIContent        = new GUIContent("ElapsedTime", string.Empty);
            GUIContent expr_7D4 = gUIContent;
            expr_7D4.text = expr_7D4.text + " " + (Time.time - this.m_fPlayStartTime).ToString("0.000");
            GUI.Box(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 0, 2), gUIContent);
            innerHorizontalRect    = FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 2, 5);
            innerHorizontalRect.y += 5f;
            GUI.HorizontalSlider(innerHorizontalRect, Time.time - this.m_fPlayStartTime, 0f, rightValue2);
            if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num * 2, 14, 1), new GUIContent("+.5", string.Empty)))
            {
                this.SetTimeScale(1f);
                base.Invoke("invokeStopTimer", 0.5f);
            }
            if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num * 2, 15, 1), new GUIContent("+.1", string.Empty)))
            {
                this.SetTimeScale(0.4f);
                base.Invoke("invokeStopTimer", 0.1f);
            }
            if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num * 2, 16, 1), new GUIContent("+.05", string.Empty)))
            {
                this.SetTimeScale(0.2f);
                base.Invoke("invokeStopTimer", 0.05f);
            }
            if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num * 2, 17, 1), new GUIContent("+.01", string.Empty)))
            {
                this.SetTimeScale(0.04f);
                base.Invoke("invokeStopTimer", 0.01f);
            }
            childVerticalRect = FXMakerLayout.GetChildVerticalRect(actionToolbarRect, 0, count, 3, 2);
            if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(childVerticalRect, num, 9, 1), new GUIContent("Restart", string.Empty)))
            {
                this.CreateInstanceEffect();
            }
        }
    }
Example #10
0
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);
        m_UndoManager.CheckUndo();
        // --------------------------------------------------------------
        EditorGUI.BeginChangeCheck();
        {
//			DrawDefaultInspector();
            m_Sel.m_nPlayIndex      = EditorGUILayout.Popup("PlayType", m_Sel.m_nPlayIndex, m_Sel.GetPlayContents(), GUILayout.MaxWidth(Screen.width));
            m_Sel.m_nTransIndex     = EditorGUILayout.Popup("PlayType", m_Sel.m_nTransIndex, NgConvert.ContentsToStrings(FxmTestControls.GetHcEffectControls_Trans(m_Sel.m_nTransAxis)), GUILayout.MaxWidth(Screen.width));
            m_Sel.m_nTransAxis      = (FxmTestControls.AXIS)EditorGUILayout.EnumPopup("TransAxis", m_Sel.m_nTransAxis, GUILayout.MaxWidth(Screen.width));
            m_Sel.m_fTransRate      = EditorGUILayout.FloatField("MaxDistance", m_Sel.m_fTransRate);
            m_Sel.m_fStartPosition  = EditorGUILayout.FloatField("StartPosition", m_Sel.m_fStartPosition);
            m_Sel.m_fDistPerTime    = EditorGUILayout.FloatField("DistPerTime", m_Sel.m_fDistPerTime);
            m_Sel.m_nRotateIndex    = EditorGUILayout.Popup("RotateIndex", m_Sel.m_nRotateIndex, new string[] { "Rot", "Fix" }, GUILayout.MaxWidth(Screen.width));
            m_Sel.m_nMultiShotCount = EditorGUILayout.IntField("MultiShotCount", m_Sel.m_nMultiShotCount);
        }

        m_UndoManager.CheckDirty();
    }