Exemple #1
0
    // ---------------------------------------------------------------------
    public string EndCapture(Texture2D[] SpriteTextures)
    {
#if UNITY_WEBPLAYER
        Debug.LogError("In WEB_PLAYER mode, you cannot run the FXMaker.");
        Debug.Break();
        return(null);
#else
        int       nTexSize      = m_nResultTextureSize;
        int       nCapSize      = m_nResultCaptureSize;
        int       nMaxCount     = (nTexSize / nCapSize) * (nTexSize / nCapSize);
        int       nTexHeight    = (m_nSaveFrameCount <= nMaxCount / 2 ? nTexSize / 2 : nTexSize);
        Texture2D spriteTexture = new Texture2D(nTexSize, nTexHeight, TextureFormat.ARGB32, false);
        int       nSaveCount    = 0;

        for (int x = 0; x < spriteTexture.width; x++)
        {
            for (int y = 0; y < spriteTexture.height; y++)
            {
                spriteTexture.SetPixel(x, y, Color.black);
            }
        }

        for (int n = m_nSkipFrameCount; n < m_nTotalFrameCount; n++, nSaveCount++)
        {
            Color[] srcColors = SpriteTextures[n].GetPixels(0);

            if (m_ShaderType == SHADER_TYPE.ALPHA_BLENDED || m_ShaderType == SHADER_TYPE.ALPHA_BLENDED_MOBILE)
            {
                srcColors = NgAtlas.ConvertAlphaTexture(srcColors, true, FXMakerOption.inst.m_AlphaWeightCurve, 1, 1, 1);
            }
            spriteTexture.SetPixels(((nSaveCount) % (nTexSize / nCapSize)) * nCapSize, nTexHeight - (((nSaveCount) / (nTexSize / nCapSize) + 1) * nCapSize), nCapSize, nCapSize, srcColors);
            Object.DestroyImmediate(SpriteTextures[n]);
        }

        byte[] bytes = spriteTexture.EncodeToPNG();
        string texBasePath;
        if (FXMakerLayout.m_bDevelopState)
        {
            texBasePath = FXMakerMain.inst.GetResourceDir(FXMakerMain.TOOLDIR_TYPE.SPRITE_TOOL);
        }
        else
        {
            texBasePath = FXMakerMain.inst.GetResourceDir(FXMakerMain.TOOLDIR_TYPE.SPRITE_USER);
        }
        string pathTexture = NgTexture.UniqueTexturePath(texBasePath, m_SelectedPrefabName);

        // save texture
        File.WriteAllBytes(pathTexture, bytes);
        AssetDatabase.Refresh();
        NgTexture.ReimportTexture(pathTexture, m_bGUITexture, m_wrapMode, m_filterMode, m_anisoLevel, m_nSpriteTextureSizes[(int)m_fSpriteTextureIndex], m_SpriteTextureFormat[(int)m_fSpriteTextureFormatIdx]);
        Object.DestroyImmediate(spriteTexture);

        // Create Prefab
        if (m_bCreatePrefab)
        {
            string     pathMaterial = CreateMaterial(pathTexture);
            Material   newMat       = (Material)AssetDatabase.LoadAssetAtPath(pathMaterial, typeof(Material));
            GameObject newPrefab    = (GameObject)Instantiate(FXMakerMain.inst.m_FXMakerSpritePrefab);

            newPrefab.transform.rotation = Quaternion.identity;
            newPrefab.GetComponent <Renderer>().material = newMat;
            NcSpriteAnimation spriteCom = newPrefab.GetComponent <NcSpriteAnimation>();
            spriteCom.m_bBuildSpriteObj = true;
            spriteCom.m_nFrameCount     = m_nSaveFrameCount;
            spriteCom.m_fFps            = m_nResultFps;
            spriteCom.m_nTilingX        = m_nResultTextureSize / m_nResultCaptureSize;
            spriteCom.m_nTilingY        = (m_nSaveFrameCount <= spriteCom.m_nTilingX * spriteCom.m_nTilingX / 2 ? spriteCom.m_nTilingX / 2 : spriteCom.m_nTilingX);
            spriteCom.m_PlayMode        = m_PlayMode;
            spriteCom.m_bLoop           = m_bLoop;
            spriteCom.m_nLoopStartFrame = 0;
            spriteCom.m_nLoopFrameCount = spriteCom.m_nFrameCount;
            spriteCom.m_nLoopingCount   = 0;

            spriteCom.m_bAutoDestruct = !m_bLoop;

            NcCurveAnimation curveCom = newPrefab.GetComponent <NcCurveAnimation>();
            if (curveCom.GetCurveInfoCount() != 3)
            {
                Debug.LogError("FXMakerMain.inst.m_FxmSpritePrefab : curveCom Count Error!!!");
            }

            curveCom.GetCurveInfo(0).m_bEnabled = false;                        // both
            curveCom.GetCurveInfo(1).m_bEnabled = false;                        // fadein
            curveCom.GetCurveInfo(2).m_bEnabled = false;                        // fadeout
            curveCom.m_bAutoDestruct            = false;
            curveCom.m_fDurationTime            = spriteCom.GetDurationTime();

            if (m_bFadeIn && m_bFadeOut)
            {
                curveCom.GetCurveInfo(0).m_bEnabled = true;
            }
            else
            {
                if (m_bFadeIn)
                {
                    curveCom.GetCurveInfo(1).m_bEnabled = true;
                }
                if (m_bFadeOut)
                {
                    curveCom.GetCurveInfo(2).m_bEnabled = true;
                }
            }

            string     basePath     = AssetDatabase.GetAssetPath(FXMakerMain.inst.GetOriginalEffectPrefab());
            string     prefabPath   = UniquePrefabPath(NgFile.TrimFilenameExt(basePath));
            GameObject createPrefab = PrefabUtility.CreatePrefab(prefabPath, newPrefab);
            Destroy(newPrefab);

            // Create Thumb
            CreateSpriteThumb(createPrefab, pathTexture);

            AssetDatabase.SaveAssets();

            return(prefabPath);
        }
        else
        {
            return(pathTexture);
        }
#endif
    }
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);

        Rect rect;
        int  nLeftWidth   = 115;
        int  nAddHeight   = 22;
        int  nDelHeight   = 17;
        int  nLineHeight  = 19;
        int  nCurveHeight = 50;
        List <NcCurveAnimation.NcInfoCurve> curveInfoList = m_Sel.m_CurveInfoList;

        m_FxmPopupManager = GetFxmPopupManager();

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

        // --------------------------------------------------------------
        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_fDelayTime    = EditorGUILayout.FloatField(GetHelpContent("m_fDelayTime"), m_Sel.m_fDelayTime);
            m_Sel.m_fDurationTime = EditorGUILayout.FloatField(GetHelpContent("m_fDurationTime"), m_Sel.m_fDurationTime);
            m_Sel.m_bAutoDestruct = EditorGUILayout.Toggle(GetHelpContent("m_bAutoDestruct"), m_Sel.m_bAutoDestruct);

            // check
            SetMinValue(ref m_Sel.m_fDelayTime, 0);
            SetMinValue(ref m_Sel.m_fDurationTime, 0.01f);

            // --------------------------------------------------------------
            EditorGUILayout.Space();
            rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nAddHeight * 3));
            {
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 0, 1), GetHelpContent("Clear All"), (0 < m_Sel.GetCurveInfoCount())))
                {
                    bClickButton = true;
                    m_Sel.ClearAllCurveInfo();
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(FXMakerLayout.GetInnerVerticalRect(rect, 3, 1, 1), 2, 0, 1), GetHelpContent("Load Curves"), (m_FxmPopupManager != null)))
                {
                    m_FxmPopupManager.ShowNcCurveAnimationPopup(m_Sel, false);
                }
                if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(FXMakerLayout.GetInnerVerticalRect(rect, 3, 1, 1), 2, 1, 1), GetHelpContent("Save Curves"), (m_FxmPopupManager != null && 0 < m_Sel.GetCurveInfoCount())))
                {
                    m_FxmPopupManager.ShowNcCurveAnimationPopup(m_Sel, true);
                }
                if (GUI.Button(FXMakerLayout.GetInnerVerticalRect(rect, 3, 2, 1), GetHelpContent("Add EmptyCurve")))
                {
                    bClickButton = true;
                    m_Sel.AddCurveInfo();
                }
                GUILayout.Label("");
            }
            EditorGUILayout.EndHorizontal();
            m_UndoManager.CheckDirty();

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

                // Enabled --------------------------------------------------------------
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nDelHeight));
                {
                    GUI.Box(rect, "");
                    curveInfoList[n].m_bEnabled = GUILayout.Toggle(curveInfoList[n].m_bEnabled, "CurveInfo " + n.ToString(), GUILayout.Width(nLeftWidth));
//					GUILayout.Label("CurveInfo Index " + n.ToString(), GUILayout.Width(nLeftWidth));
                }
                EditorGUILayout.EndHorizontal();

                // CurveName -----------------------------------------------------------
                curveInfoList[n].m_CurveName = EditorGUILayout.TextField(GetHelpContent("m_CurveName"), curveInfoList[n].m_CurveName);

                // ApplyType --------------------------------------------------------------
                EditorGUI.BeginChangeCheck();
                {
                    rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                    {
                        GUI.Box(rect, "");
                        GUILayout.Label("", GUILayout.Width(nLeftWidth));
                        NcCurveAnimation.NcInfoCurve.APPLY_TYPE nApplyType = (NcCurveAnimation.NcInfoCurve.APPLY_TYPE)EditorGUI.Popup(new Rect(rect.x, rect.y, nLeftWidth, rect.height), (int)curveInfoList[n].m_ApplyType, NcCurveAnimation.NcInfoCurve.m_TypeName);
                        if (curveInfoList[n].m_ApplyType != nApplyType)
                        {
                            curveInfoList[n].m_ApplyType = nApplyType;
                            curveInfoList[n].SetDefaultValueScale();
                        }

                        // Add Component
                        bool bShowOption = true;
                        if (curveInfoList[n].m_ApplyType == NcCurveAnimation.NcInfoCurve.APPLY_TYPE.TEXTUREUV)
                        {
                            if (m_Sel.gameObject.GetComponent <NcUvAnimation>() == null)
                            {
                                bShowOption = false;
                                FXMakerLayout.GUIColorBackup(FXMakerLayout.m_ColorHelpBox);
                                if (GUI.Button(new Rect(rect.x + nLeftWidth, rect.y, rect.width - nLeftWidth, rect.height), GetHelpContent("Add NcUvAnimation Script")))
                                {
                                    m_Sel.gameObject.AddComponent <NcUvAnimation>();
                                }
                                FXMakerLayout.GUIColorRestore();
                            }
                        }
                        if (bShowOption)
                        {
                            for (int nValueIndex = 0; nValueIndex < curveInfoList[n].GetValueCount(); nValueIndex++)
                            {
                                curveInfoList[n].m_bApplyOption[nValueIndex] = GUILayout.Toggle(curveInfoList[n].m_bApplyOption[nValueIndex], curveInfoList[n].GetValueName(nValueIndex));
                            }
                        }
                        if (curveInfoList[n].m_ApplyType == NcCurveAnimation.NcInfoCurve.APPLY_TYPE.SCALE)
                        {
                            GUILayout.Label("LocalSpace");
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                if (EditorGUI.EndChangeCheck())
                {
                    m_Sel.CheckInvalidOption(n);
                }

                if (curveInfoList[n].m_ApplyType == NcCurveAnimation.NcInfoCurve.APPLY_TYPE.MATERIAL_COLOR)
                {
                    // ValueScale --------------------------------------------------------------
                    rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight * 2));
                    {
                        GUI.Box(rect, "");
                        GUILayout.Label("", GUILayout.Width(nLeftWidth));
                        bool bEnableColor = (m_Sel.GetComponent <Renderer>() != null && m_Sel.GetComponent <Renderer>().sharedMaterial != null & NgMaterial.IsMaterialColor(m_Sel.GetComponent <Renderer>().sharedMaterial));
                        Rect colorRect    = FXMakerLayout.GetInnerVerticalRect(rect, 2, 0, 1);
                        colorRect.width = nLeftWidth;
                        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(colorRect, 2, 0, 1), GetHelpContent("White"), bEnableColor))
                        {
                            curveInfoList[n].m_ToColor = Color.white;
                        }
                        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(colorRect, 2, 1, 1), GetHelpContent("Current"), bEnableColor))
                        {
                            curveInfoList[n].m_ToColor = NgMaterial.GetMaterialColor(m_Sel.GetComponent <Renderer>().sharedMaterial);
                        }
                        colorRect.x += colorRect.width;
                        GUI.Label(colorRect, GetHelpContent("ToColor"));
                        colorRect.x               += 60;
                        colorRect.width            = rect.width - colorRect.x;
                        curveInfoList[n].m_ToColor = EditorGUI.ColorField(colorRect, curveInfoList[n].m_ToColor);

                        // m_bRecursively
                        Rect recRect = FXMakerLayout.GetInnerVerticalRect(rect, 2, 1, 1);
                        curveInfoList[n].m_bRecursively = GUI.Toggle(FXMakerLayout.GetRightRect(recRect, rect.width - nLeftWidth), curveInfoList[n].m_bRecursively, GetHelpContent("Recursively"));
                    }
                    EditorGUILayout.EndHorizontal();
                }
                else
                if (curveInfoList[n].m_ApplyType == NcCurveAnimation.NcInfoCurve.APPLY_TYPE.MESH_COLOR)
                {
                    // ValueScale --------------------------------------------------------------
                    rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight * 3));
                    {
                        GUI.Box(rect, "");
                        GUILayout.Label("", GUILayout.Width(nLeftWidth));
//						bool bEnableColor	= (m_Sel.renderer != null && m_Sel.renderer.sharedMaterial != null & NgMaterial.IsMaterialColor(m_Sel.renderer.sharedMaterial));
                        // From Color
                        Rect colorRect = FXMakerLayout.GetInnerVerticalRect(rect, 3, 0, 1);
                        colorRect.width = nLeftWidth;
                        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(colorRect, 2, 0, 1), GetHelpContent("White"), true))
                        {
                            curveInfoList[n].m_FromColor = Color.white;
                        }
                        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(colorRect, 2, 1, 1), GetHelpContent("Black"), true))
                        {
                            curveInfoList[n].m_FromColor = Color.black;
                        }
                        colorRect.x += colorRect.width;
                        GUI.Label(colorRect, GetHelpContent("FromColor"));
                        colorRect.x    += 60;
                        colorRect.width = rect.width - colorRect.x;
                        curveInfoList[n].m_FromColor = EditorGUI.ColorField(colorRect, curveInfoList[n].m_FromColor);

                        // To Color
                        colorRect       = FXMakerLayout.GetInnerVerticalRect(rect, 3, 1, 1);
                        colorRect.width = nLeftWidth;
                        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(colorRect, 2, 0, 1), GetHelpContent("White"), true))
                        {
                            curveInfoList[n].m_ToColor = Color.white;
                        }
                        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(colorRect, 2, 1, 1), GetHelpContent("Black"), true))
                        {
                            curveInfoList[n].m_ToColor = Color.black;
                        }
                        colorRect.x += colorRect.width;
                        GUI.Label(colorRect, GetHelpContent("ToColor"));
                        colorRect.x               += 60;
                        colorRect.width            = rect.width - colorRect.x;
                        curveInfoList[n].m_ToColor = EditorGUI.ColorField(colorRect, curveInfoList[n].m_ToColor);

                        // m_bRecursively
                        Rect recRect = FXMakerLayout.GetInnerVerticalRect(rect, 3, 2, 1);
                        curveInfoList[n].m_bRecursively = GUI.Toggle(FXMakerLayout.GetRightRect(recRect, rect.width - nLeftWidth), curveInfoList[n].m_bRecursively, GetHelpContent("Recursively"));
                    }
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    // ValueScale --------------------------------------------------------------
                    rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight));
                    {
                        GUI.Box(rect, "");
                        GUILayout.Label("", GUILayout.Width(nLeftWidth));
                        if (curveInfoList[n].m_ApplyType == NcCurveAnimation.NcInfoCurve.APPLY_TYPE.SCALE)
                        {
                            curveInfoList[n].m_fValueScale = EditorGUI.FloatField(rect, GetHelpContent("Value Scale"), curveInfoList[n].m_fValueScale + 1) - 1;
                        }
                        else
                        {
                            curveInfoList[n].m_fValueScale = EditorGUI.FloatField(rect, GetHelpContent("Value Scale"), curveInfoList[n].m_fValueScale);
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }

                // Curve --------------------------------------------------------------
                rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nCurveHeight));
                {
                    GUI.Box(rect, "");
                    GUILayout.Label("", GUILayout.Width(nLeftWidth));
                    EditorGUI.BeginChangeCheck();
                    {
                        curveInfoList[n].m_AniCurve = EditorGUI.CurveField(FXMakerLayout.GetOffsetRect(rect, nLeftWidth + 4, 0, 0, -4), curveInfoList[n].m_AniCurve, Color.green, curveInfoList[n].GetEditRange());
//						curveInfoList[n].m_AniCurve	= EditorGUILayout.CurveField(" ", curveInfoList[n].m_AniCurve, Color.green, curveInfoList[n].GetEditRange(), GUILayout.Height(nCurveHeight-4));
//						curveInfoList[n].m_AniCurve	= EditorGUILayout.CurveField(" ", curveInfoList[n].m_AniCurve, GUILayout.Height(nCurveHeight-4));
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        curveInfoList[n].NormalizeCurveTime();
                    }

                    Rect buttonRect = rect;
                    buttonRect.width = nLeftWidth;
                    FXMakerLayout.GetOffsetRect(rect, 0, 5, 0, -5);
                    if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(FXMakerLayout.GetInnerVerticalRect(buttonRect, 2, 1, 1), 2, 0, 2), GetHelpContent("Delete")))
                    {
                        bClickButton = true;
                        m_Sel.DeleteCurveInfo(n);
                    }

                    //               if (m_FxmPopupManager != null)
                    //{
                    //	Rect buttonRect = rect;
                    //	buttonRect.width = nLeftWidth;
                    //	FXMakerLayout.GetOffsetRect(rect, 0, 5, 0, -5);
                    //	if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(FXMakerLayout.GetInnerVerticalRect(buttonRect, 2, 0, 1), 2, 0, 1), GetHelpContent("Change")))
                    //		m_FxmPopupManager.ShowNcInfoCurvePopup(m_Sel, n, false);
                    //	if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(FXMakerLayout.GetInnerVerticalRect(buttonRect, 2, 0, 1), 2, 1, 1), GetHelpContent("Save")))
                    //		m_FxmPopupManager.ShowNcInfoCurvePopup(m_Sel, n, true);
                    //	if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(FXMakerLayout.GetInnerVerticalRect(buttonRect, 2, 1, 1), 2, 0, 2), GetHelpContent("Delete")))
                    //	{
                    //		bClickButton	= true;
                    //		m_Sel.DeleteCurveInfo(n);
                    //	}
                    //}
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
            }
        }
        // --------------------------------------------------------------
        if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain())
        {
            OnEditComponent();
        }
        // ---------------------------------------------------------------------
        if (GUI.tooltip != "")
        {
            m_LastTooltip = GUI.tooltip;
        }
        HelpBox(m_LastTooltip);
    }
    // ==========================================================================================================
    void winPopup(int id)
    {
        Rect baseRect = GetPopupRect();
        Rect buttonRect;
        Rect lineRect;

        if (UnfocusClose(baseRect, -10, 0, 0, 0))
        {
            return;
        }

        baseRect = FXMakerLayout.GetChildVerticalRect(baseRect, 0, 1, 0, 1);

        Transform transOriginalRoot = FXMakerMain.inst.GetOriginalEffectObject().transform;
        int       nButtonCount      = m_nButtonCount * 2;
        int       nDrawCount        = 0;
        bool      bEnable           = false;

        // Copy
        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Copy"), true))
        {
            FXMakerClipboard.inst.SetClipboardObject(m_SelectedObject);
            ClosePopup(true);
            return;
        }
        nDrawCount += 2;

        // Cut
        switch (m_SelObjectType)
        {
        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT:    bEnable = (m_SelectedTransform != transOriginalRoot);  break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_TRANSFORM:             bEnable = false;        break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_EASYEFFECT:    bEnable = true;         break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_UNITYENGINE:   bEnable = true;         break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_OTHER:                 bEnable = true;         break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_MATERIAL:              bEnable = false;        break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_ANICLIP:               bEnable = false;        break;

        default: Debug.LogWarning("not declare");      break;
        }
        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Cut"), bEnable))
        {
            FXMakerClipboard.inst.SetClipboardObject(m_SelectedObject);
            FXMakerHierarchy.inst.DeleteHierarchyObject(m_SelectedTransform, m_SelectedObject, m_nSelectedIndex);
            ClosePopup(true);
            return;
        }
        nDrawCount += 2;

        // Paste
        switch (m_SelObjectType)
        {
        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT:
        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_TRANSFORM:
        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_EASYEFFECT:
        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_UNITYENGINE:
        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_OTHER:                 bEnable = FXMakerClipboard.inst.IsObject();     break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_MATERIAL:              bEnable = false;        break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_ANICLIP:               bEnable = false;        break;

        default: Debug.LogWarning("not declare");      break;
        }
        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Paste", FXMakerClipboard.inst.GetName()), bEnable))
        {
            Object tarObj = FXMakerClipboard.inst.PasteClipboardObject(m_SelectedTransform.gameObject, m_SelectedObject, m_nSelectedIndex);
            if (tarObj is GameObject)
            {
                SetAddObject((tarObj as GameObject), tarObj);
            }
            else
            {
                SetAddObject(null, tarObj);
            }
            ClosePopup(true);
            return;
        }
        nDrawCount += 2;

        // Overwrite
        switch (m_SelObjectType)
        {
        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT:            bEnable = false;        break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_TRANSFORM:             bEnable = FXMakerClipboard.inst.IsTransform() && FXMakerClipboard.inst.GetObject().GetType() == m_SelectedObject.GetType();             break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_EASYEFFECT:
        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_UNITYENGINE:
        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_OTHER:                 bEnable = FXMakerClipboard.inst.IsComponent() && FXMakerClipboard.inst.GetObject().GetType() == m_SelectedObject.GetType();             break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_MATERIAL:              bEnable = FXMakerClipboard.inst.IsMaterial() && FXMakerClipboard.inst.GetObject().GetType() == m_SelectedObject.GetType();              break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_ANICLIP:               bEnable = FXMakerClipboard.inst.IsAnimationClip() && FXMakerClipboard.inst.GetObject().GetType() == m_SelectedObject.GetType(); break;

        default: Debug.LogWarning("not declare"); break;
        }
        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Overwrite", FXMakerClipboard.inst.GetName()), bEnable))
        {
            FXMakerClipboard.inst.OverwriteClipboardObject(m_SelectedTransform.gameObject, m_SelectedObject, m_nSelectedIndex);
            ClosePopup(true);
            return;
        }
        nDrawCount += 2;

        // Draw line
        lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 1);
        NgGUIDraw.DrawHorizontalLine(new Vector2(lineRect.x, lineRect.y + lineRect.height / 2), (int)lineRect.width, Color.gray, 2, false);
        nDrawCount += 1;

        // Duplicate
        switch (m_SelObjectType)
        {
        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT:    bEnable = (m_SelectedTransform != transOriginalRoot);   break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_TRANSFORM:             bEnable = false;        break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_EASYEFFECT:    bEnable = true;         break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_UNITYENGINE:   bEnable = true;         break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_OTHER:                 bEnable = true;         break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_MATERIAL:              bEnable = false;        break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_ANICLIP:               bEnable = false;        break;

        default: Debug.LogWarning("not declare"); break;
        }
        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Duplicate"), bEnable))
        {
            switch (m_SelObjectType)
            {
            case FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT:    SetAddObject(FXMakerHierarchy.inst.AddGameObject(m_SelectedTransform.transform.parent.gameObject, m_SelectedTransform.gameObject), null);               break;

            case FXMakerHierarchy.OBJECT_TYPE.OBJECT_TRANSFORM:             break;

            case FXMakerHierarchy.OBJECT_TYPE.OBJECT_EASYEFFECT:
            case FXMakerHierarchy.OBJECT_TYPE.OBJECT_UNITYENGINE:
            case FXMakerHierarchy.OBJECT_TYPE.OBJECT_OTHER:                 m_AddComObject = NgSerialized.CloneComponent(m_SelectedObject as Component, (m_SelectedObject as Component).gameObject, false); break;

            case FXMakerHierarchy.OBJECT_TYPE.OBJECT_MATERIAL:              break;

            case FXMakerHierarchy.OBJECT_TYPE.OBJECT_ANICLIP:               break;

            default: Debug.LogWarning("not declare"); break;
            }
            ClosePopup(true);
            return;
        }
        nDrawCount += 2;

        // Disable
        if (m_SelObjectType == FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT)
        {
            bool bObjEnable = (m_SelectedTransform.gameObject.GetComponent <NcDontActive>() == null);
            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), (bObjEnable ? GetHelpContent("Disable") : GetHelpContent("Enable")), (m_SelectedTransform != transOriginalRoot)))
            {
                FXMakerHierarchy.inst.SetEnableGameObject(m_SelectedTransform.gameObject, !bObjEnable);
                ClosePopup(true);
                return;
            }
        }
        else
        {
            buttonRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2);
            if (m_SelectedObject is Component)
            {
                int nObjEnable = EditorUtility.GetObjectEnabled(m_SelectedObject);
                if (0 <= nObjEnable)
                {
                    if (0 < nObjEnable)
                    {
                        if (GUI.Button(buttonRect, GetHelpContent("Disable")))
                        {
                            EditorUtility.SetObjectEnabled(m_SelectedObject, false);
                            ClosePopup(true);
                            return;
                        }
                    }
                    else
                    {
                        if (GUI.Button(buttonRect, GetHelpContent("Enable")))
                        {
                            EditorUtility.SetObjectEnabled(m_SelectedObject, true);
                            ClosePopup(true);
                            return;
                        }
                    }
                }
                else
                {
                    FXMakerLayout.GUIButton(buttonRect, GetHelpContent("Disable"), false);
                }
            }
            else
            {
                FXMakerLayout.GUIButton(buttonRect, GetHelpContent("Disable"), false);
            }
        }
        nDrawCount += 2;


        // Delete
        switch (m_SelObjectType)
        {
        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT:    bEnable = (m_SelectedTransform != transOriginalRoot);  break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_TRANSFORM:             bEnable = false;        break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_EASYEFFECT:    bEnable = true;         break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_UNITYENGINE:   bEnable = true;         break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_OTHER:                 bEnable = true;         break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_MATERIAL:              bEnable = true;         break;

        case FXMakerHierarchy.OBJECT_TYPE.OBJECT_ANICLIP:               bEnable = true;         break;

        default: Debug.LogWarning("not declare"); break;
        }
        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Delete"), bEnable))
        {
            FXMakerHierarchy.inst.DeleteHierarchyObject(m_SelectedTransform, m_SelectedObject, m_nSelectedIndex);
            ClosePopup(true);
            return;
        }
        nDrawCount += 2;

        // Draw line
        lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 1);
        NgGUIDraw.DrawHorizontalLine(new Vector2(lineRect.x, lineRect.y + lineRect.height / 2), (int)lineRect.width, Color.gray, 2, false);
        nDrawCount += 1;

        // -------------------------------------------------------------------------------------
        if (m_SelectedObject is NcCurveAnimation)
        {
            // NcCurveAnimation
            NcCurveAnimation curveCom = m_SelectedObject as NcCurveAnimation;
            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("SaveCurves"), 0 < curveCom.GetCurveInfoCount()))
            {
                ClosePopup(true);
                FxmPopupManager.inst.ShowNcCurveAnimationPopup(curveCom, true);
                return;
            }
            nDrawCount += 2;
            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("LoadCurves"), true))
            {
                ClosePopup(true);
                FxmPopupManager.inst.ShowNcCurveAnimationPopup(curveCom, false);
                return;
            }
            nDrawCount += 2;
        }
        // -------------------------------------------------------------------------------------
        if (m_SelObjectType == FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT)
        {
            // Add Child
            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Add Child"), true))
            {
//              GameObject	newChild	= new GameObject("GameObject");
//              newChild.transform.parent = m_SelectedTransform;
//              FXMakerHierarchy.inst.OnAddGameObject(newChild);
//              SetAddObject(newChild, null);
//              ClosePopup(true);

                FXMakerHierarchy.inst.ShowAddObjectRightPopup();
                ClosePopup(false);

                return;
            }
            nDrawCount += 2;

            // Add Parent
            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Add Parent"), true))
            {
                GameObject newParent = new GameObject("GameObject");
                newParent.transform.parent = m_SelectedTransform.parent;
                m_SelectedTransform.parent = newParent.transform;
                m_SelectedTransform.name   = m_SelectedTransform.name.Replace("(Original)", "");
                if (m_SelectedTransform == transOriginalRoot)
                {
                    FXMakerMain.inst.ChangeRoot_OriginalEffectObject(newParent);
                }
                FXMakerHierarchy.inst.OnAddGameObject(newParent);
                SetAddObject(newParent, null);
                ClosePopup(true);
                return;
            }
            nDrawCount += 2;

            // MoveToParent
            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("MoveToParent"), (m_SelectedTransform != transOriginalRoot && (m_SelectedTransform.parent != transOriginalRoot) || (m_SelectedTransform.parent == transOriginalRoot && transOriginalRoot.childCount == 1))))
            {
                if (m_SelectedTransform.parent == transOriginalRoot && transOriginalRoot.childCount == 1)
                {
                    FXMakerMain.inst.SaveTool("");
                    m_SelectedTransform = FXMakerMain.inst.GetOriginalEffectObject().transform;
                    // root swap
                    Transform toolRoot  = m_SelectedTransform.parent;
                    Transform newParent = m_SelectedTransform.GetChild(0);
                    Transform newChild  = m_SelectedTransform;
                    newChild.parent     = null;
                    newParent.parent    = null;
                    newChild.parent     = newParent;
                    newParent.parent    = toolRoot;
                    m_SelectedTransform = newParent;
                    FXMakerMain.inst.ChangeRoot_OriginalEffectObject(m_SelectedTransform.gameObject);
                    SetAddObject(null, null);
                }
                else
                {
                    m_SelectedTransform.parent = m_SelectedTransform.parent.parent;
                }
                ClosePopup(true);
                return;
            }
            nDrawCount += 2;

            // Add Component
            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Add Component"), true))
            {
                ClosePopup(true);
                FxmPopupManager.inst.ShowHierarchyObjectPopup("FxmPopup_GameObject", m_SelectedTransform.gameObject);
                return;
            }
            nDrawCount += 2;

            // Add Prefab
            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Add Prefab"), true))
            {
                FxmPopupManager.inst.ShowAddPrefabPopup(m_SelectedTransform);
                ClosePopup(true);
                return;
            }
            nDrawCount += 2;

            // Save Prefab
            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Save Prefab"), true))
            {
                ClosePopup(true);
                FxmPopupManager.inst.ShowSavePrefabPopup(m_SelectedTransform);
                return;
            }
            nDrawCount += 2;
        }
        // -------------------------------------------------------------------------------------
        if (m_SelObjectType == FXMakerHierarchy.OBJECT_TYPE.OBJECT_MATERIAL)
        {
            bEnable = NgMaterial.IsMaterialColor(m_SelectedObject as Material);

            // Copy Color
            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Copy Color"), bEnable))
            {
                FXMakerClipboard.inst.SetClipboardColor(NgMaterial.GetMaterialColor(m_SelectedObject as Material));
                ClosePopup(true);
                return;
            }
            if (bEnable)
            {
                Rect colorRect = FXMakerLayout.GetOffsetRect(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), -5);
                colorRect.width = colorRect.height;
                EditorGUIUtility.DrawColorSwatch(colorRect, NgMaterial.GetMaterialColor(m_SelectedObject as Material));
            }
            nDrawCount += 2;

            // Paste Color
            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Paste Color"), bEnable))
            {
                FXMakerClipboard.inst.PasteClipboardColor(m_SelectedTransform, m_nSelectedIndex, m_SelectedObject as Material);
                ClosePopup(true);
                return;
            }
            {
                Rect colorRect = FXMakerLayout.GetOffsetRect(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), -5);
                colorRect.width = colorRect.height;
                EditorGUIUtility.DrawColorSwatch(colorRect, FXMakerClipboard.inst.m_CopyColor);
            }
            nDrawCount += 2;
        }

        m_nButtonCount = nDrawCount / 2;
        FXMakerMain.inst.SaveTooltip();
    }