コード例 #1
0
    void OnSetBtn(EditorControl c)
    {
        if (null == Selection.activeGameObject)
        {
            EditorUtility.DisplayDialog("操作失败", "\n未指定任何UISprite", "确认");
            return;
        }

        if (
            (m_SearchResultInfo == null) ||
            (m_SearchResultInfo.SearchSpriteInfo == null)
            )
        {
            EditorUtility.DisplayDialog("操作失败", "\n未指定有效Sprite", "确认");
            return;
        }

        ListViewCtrl searchList = _GetControl <ListViewCtrl>(m_SearchResultListName);

        if (null == searchList)
        {
            return;
        }


        int index = searchList.LastSelectItem;

        if (
            (index < 0) ||
            (index > m_SearchResultInfo.SearchSpriteInfo.Count)
            )
        {
            EditorUtility.DisplayDialog("操作失败", "\n未指定有效Sprite", "确认");
            return;
        }

        SEARCHSPRITE_ERROR_TYPE errorType = SearchSpriteEidtorModel.GetInstance().SetUISprite(Selection.activeGameObject, m_SearchResultInfo.SearchSpriteInfo[index].SpriteName, m_SearchResultInfo.SearchSpriteInfo[index].AtlasPath);

        switch (errorType)
        {
        //设定成功
        case SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_NONE_ERROR:
            string atlasName = Path.GetFileNameWithoutExtension(m_SearchResultInfo.SearchSpriteInfo[index].AtlasPath);
            EditorUtility.DisplayDialog("设置完成", "\n已设置" + atlasName + "的" + m_SearchResultInfo.SearchSpriteInfo[index].SpriteName, "确认");

            break;

        //设定对象不是UISpirte
        case SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_SET_IS_NOT_UISPRITE:
            string goName = Selection.activeGameObject.name;
            EditorUtility.DisplayDialog("设置失败", "\n" + goName + "不是UISprite", "确认");

            break;

        default:
            break;
        }

        RequestRepaint();
    }
コード例 #2
0
 public static SearchSpriteEidtorModel GetInstance()
 {
     if (m_Instance == null)
     {
         m_Instance = new SearchSpriteEidtorModel();
     }
     return(m_Instance);
 }
コード例 #3
0
 public static void DestoryInstance()
 {
     if (m_Instance != null)
     {
         m_Instance = null;
         SearchSpriteEidtorModel.DestoryInstance();
     }
 }
コード例 #4
0
    void OnSearchBtn(EditorControl c)
    {
        TextBoxCtrl searchText = _GetControl <TextBoxCtrl>(m_SearchTextBoxName);

        if (null == searchText)
        {
            return;
        }

        string spriteName = searchText.Text;
        List <AtlasInfoForSearchSprite> atlasInfoTbl = null;

        SEARCHSPRITE_ERROR_TYPE errorType = SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_NONE_ERROR;

        if (c.Name == m_VagueSearchBtnName)
        {
            errorType = SearchSpriteEidtorModel.GetInstance().VagueSearchSprite(spriteName, out atlasInfoTbl);
        }
        else
        {
            errorType = SearchSpriteEidtorModel.GetInstance().SearchSprite(spriteName, out atlasInfoTbl);
        }

        switch (errorType)
        {
        //搜索成功
        case SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_NONE_ERROR:
            FixSearchResultAndList(spriteName, atlasInfoTbl);
            ClearPreview();

            if (
                (null == m_SearchResultInfo) ||
                (null == m_SearchResultInfo.SearchSpriteInfo) ||
                (0 == m_SearchResultInfo.SearchSpriteInfo.Count)
                )
            {    //搜索结果为空
                EditorUtility.DisplayDialog("查找完毕", "\n" + spriteName + "不存在", "确认");
            }
            else
            {    //不为空
                EditorUtility.DisplayDialog("查找完毕", "\n有" + m_SearchResultInfo.SearchSpriteInfo.Count + "个Atlas包含" + spriteName, "确认");
            }

            break;

        //未指定Sprite名称
        case SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_SEARCH_WITH_EMPTY_NAME:
            EditorUtility.DisplayDialog("操作失败", "\n未指定Sprite名称", "确认");
            if (m_SearchResultInfo != null)
            {
                searchText.Text = m_SearchResultInfo.SearchName;
            }
            break;

        default:
            break;
        }
    }