Esempio n. 1
0
    public NcEffectBehaviour SetSprite(int nNodeIndex, bool bRunImmediate)
    {
        if (m_SpriteList == null || nNodeIndex < 0 || m_SpriteList.Count <= nNodeIndex)
        {
            return(null);
        }

        if (bRunImmediate)
        {
            OnChangingSprite(m_nCurrentIndex, nNodeIndex);
        }
        m_nCurrentIndex = nNodeIndex;

        //      if (m_SpriteType == SPRITE_TYPE.NcSpriteAnimation)
        NcSpriteAnimation spriteCom = GetComponent <NcSpriteAnimation>();

        if (spriteCom != null)
        {
            spriteCom.SetSpriteFactoryIndex(nNodeIndex, false);

            if (bRunImmediate)
            {
                spriteCom.ResetAnimation();
            }
        }

        //      if (m_SpriteType == SPRITE_TYPE.NcSpriteTexture)
        NcSpriteTexture uvCom = GetComponent <NcSpriteTexture>();

        if (uvCom != null)
        {
            uvCom.SetSpriteFactoryIndex(nNodeIndex, -1, false);
            if (bRunImmediate)
            {
                //				UpdateUvScale(nNodeIndex, transform);
                CreateEffectObject();
            }
        }

        if (spriteCom != null)
        {
            return(spriteCom);
        }
        if (spriteCom != null)
        {
            return(uvCom);
        }

        return(null);
    }
Esempio n. 2
0
    public NcEffectBehaviour SetSprite(int nNodeIndex, bool bRunImmediate)
    {
        if (this.m_SpriteList == null || nNodeIndex < 0 || this.m_SpriteList.Count <= nNodeIndex)
        {
            return(null);
        }
        if (bRunImmediate)
        {
            this.OnChangingSprite(this.m_nCurrentIndex, nNodeIndex);
        }
        this.m_nCurrentIndex = nNodeIndex;
        NcSpriteAnimation component = base.GetComponent <NcSpriteAnimation>();

        if (component != null)
        {
            component.SetSpriteFactoryIndex(nNodeIndex, false);
            if (bRunImmediate)
            {
                component.ResetAnimation();
            }
        }
        NcSpriteTexture component2 = base.GetComponent <NcSpriteTexture>();

        if (component2 != null)
        {
            component2.SetSpriteFactoryIndex(nNodeIndex, -1, false);
            if (bRunImmediate)
            {
                this.CreateEffectObject();
            }
        }
        if (component != null)
        {
            return(component);
        }
        if (component != null)
        {
            return(component2);
        }
        return(null);
    }
    public override void OnInspectorGUI()
    {
        AddScriptNameField(m_Sel);
        m_UndoManager.CheckUndo();

        Rect rect;

        m_FxmPopupManager = GetFxmPopupManager();

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

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

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

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

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

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

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

                    Rect subRect = rect;

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