public void addSprite2SO(SOSpriteList soSprite) { string assetsImagePath = ExportUtil.convFullPath2AssetsPath(m_fullPath); Sprite[] allSpritesArr = AtlasPrefabUtil.loadAllSprite(assetsImagePath); soSprite.addSprite(m_subPathNoExt, allSpritesArr[0]); }
// inPath 类似这样 Assets/Res/Image/UI/Common/denglu_srk.png , outPath = Assets/Prefabs/Resources/Atlas/aaa.asset public void packSprite(string inPath, string outPath) { m_soSprite = ScriptableObject.CreateInstance <SOSpriteList>(); Sprite[] spriteArr = AtlasPrefabUtil.loadAllSprite(inPath); m_soSprite.addSprite("aaa", spriteArr[0]); AssetDatabase.CreateAsset(m_soSprite, outPath); }
public void createSpriteAsset() { SOSpriteList soSprite = m_dirData.createScriptSprite(); string assetsPrefabPath = ExportUtil.getRelDataPath(m_outPath); // 创建预制,并且添加到编辑器中,以便进行检查 AssetDatabase.CreateAsset(soSprite, assetsPrefabPath); //刷新编辑器 AssetDatabase.Refresh(); }
public SOSpriteList createScriptSprite() { SOSpriteList retSOSprite = ScriptableObject.CreateInstance <SOSpriteList>(); foreach (FileData file in m_filesList) { file.addSprite2SO(retSOSprite); } return(retSOSprite); }
protected void testScriptSprite() { GameObject srcBtnGo = UtilApi.TransFindChildByPObjAndPath(m_GUIWin.m_uiRoot, "BtnTest1"); Image srcImage = UtilApi.getComByP <Image>(srcBtnGo); SOSpriteList spriteList = Resources.Load <SOSpriteList>("Atlas/TuJian"); //srcImage.sprite = sprite.m_path2SpriteDic["aaa"].m_sprite; srcImage.sprite = spriteList.m_objList[0].m_sprite; UtilApi.setImageType(srcImage, Image.Type.Simple); UtilApi.SetNativeSize(srcImage); }