Exemplo n.º 1
0
 void OnDisable()
 {
     if (m_curObj != null)
     {
         Object.DestroyImmediate(m_curObj);
         m_curObj = null;
     }
     m_curSelectSprite = null;
 }
Exemplo n.º 2
0
 // 功能:选择一个精灵对象
 public void OnSelectSprite(string szNewSelectSpriteName)
 {
     if (m_curSelectSprite == null)
     {
         if (m_curObj == null)
         {
             GameObject obj = new GameObject();
             m_curObj = obj;
             m_curObj.SetActive(false);
         }
         m_curSelectSprite = m_curObj.AddComponent <MyUISpritePreView>();
     }
     if (m_curSelectSprite.spritename != szNewSelectSpriteName)
     {
         m_szSelectSpriteName         = szNewSelectSpriteName;
         m_pSelectSprite              = null;
         m_curSelectSprite.spritename = szNewSelectSpriteName;
     }
     Selection.activeObject = m_curSelectSprite;
 }
Exemplo n.º 3
0
    /// <summary>
    /// Refresh the window on selection.
    /// </summary>

    // 当有选中对象改变时发生的操作
    void OnSelectionChange()
    {
        RefreshSelectObject();
        Repaint();
        Object [] objs = Selection.objects;
        if (objs != null && objs.Length == 1)
        {
            GameObject gObj = objs[0] as GameObject;
            if (gObj != null)
            {
                MyUISpritePreView spView = gObj.GetComponent <MyUISpritePreView>();
                if (spView != null)
                {
                    OnSelectSprite(spView.name);
                    m_bSortUpSelect = false;
                    SortBySelect();
                }
            }
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// Draw the atlas and sprite selection fields.
    /// </summary>

    protected virtual bool DrawProperties()
    {
        mSprite = target as MyUISpritePreView;
        // 属性绘制
        string spriteName = mSprite != null ? mSprite.name : "";

        if (m_sprite == null || m_sprite.name != spriteName)
        {
            UISpriteInfo sprite = AtlasMng_Editor.instance.GetSprite(spriteName);
            if (m_bDirty)
            {
                if (m_sprite != null)
                {
                    UISpriteInfo oldSprite = AtlasMng_Editor.instance.GetSprite(m_sprite.name);
                    if (oldSprite != null)
                    {
                        oldSprite.Copy(m_sprite);                          // 自动取消修改
                        MarkSpriteAsDirty();
                    }
                }
                m_bDirty = false;
            }
            if (sprite != null)
            {
                m_sprite = sprite.Clone();
            }
        }
        // Sprite selection drop-down list
        GUILayout.BeginHorizontal();
        {
            if (string.IsNullOrEmpty(spriteName))
            {
                spriteName = "";
            }
            GUILayout.Label(spriteName, GUILayout.Width(180f));
        }
        GUILayout.EndHorizontal();

        return(true);
    }