private SEARCHSPRITE_ERROR_TYPE CheckUtilityForNGUIError(UTILITYFORNGUI_ERROR_TYPE utilityForNGUIErrorType) { SEARCHSPRITE_ERROR_TYPE errorType = SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_NONE_ERROR; switch (utilityForNGUIErrorType) { case UTILITYFORNGUI_ERROR_TYPE.UTILITYFORNGUI_ERROR_NONE: errorType = SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_NONE_ERROR; break; case UTILITYFORNGUI_ERROR_TYPE.UTILITYFORNGUI_ERROR_UNKNOWN: errorType = SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_UNKNOWN; break; case UTILITYFORNGUI_ERROR_TYPE.UTILITYFORNGUI_ERROR_ISNOT_UISPRITE: errorType = SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_SET_IS_NOT_UISPRITE; break; case UTILITYFORNGUI_ERROR_TYPE.UTILITYFORNGUI_ERROR_ISNOT_ATLAS: errorType = SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_SET_IS_NOT_ATLAS; break; default: errorType = SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_NONE_ERROR; break; } return(errorType); }
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(); }
public SEARCHSPRITE_ERROR_TYPE SetUISprite(GameObject go, string spriteName, string atlasPath) { SEARCHSPRITE_ERROR_TYPE errorType = SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_NONE_ERROR; errorType = CheckUtilityForNGUIError(UtilityForNGUI.SetUISprite(go, spriteName, atlasPath)); return(errorType); }
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; } }
public SEARCHSPRITE_ERROR_TYPE VagueSearchSprite(string spriteName, out List <AtlasInfoForSearchSprite> atlasInfoTbl) { atlasInfoTbl = null; SEARCHSPRITE_ERROR_TYPE errorType = SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_NONE_ERROR; if (string.IsNullOrEmpty(spriteName)) { errorType = SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_SEARCH_WITH_EMPTY_NAME; } AtlasAnalyziser analyziser = new AtlasAnalyziser(); atlasInfoTbl = analyziser.VagueSearchAtlasWithSpecifySprite(spriteName); return(errorType); }