コード例 #1
0
	//
	static bool isApprorateTexture(List< UIAtlas.Sprite> sprites,Texture obj){
		List<Texture> tempTxts = new List<Texture>();
		tempTxts.Add(obj);
		List<UIAtlasMaker.SpriteEntry>  entrys = UIAtlasMaker.CreateSpritesEX(tempTxts);
		UIAtlasMaker.SpriteEntry tempEntry = entrys[0];
		
		UIAtlas.Sprite searched = null;
		foreach(UIAtlas.Sprite tempSprite in sprites){
			if(tempSprite.name == tempEntry.name){
				
				if(Mathf.Abs(tempSprite.inner.width - tempEntry.tex.width) <= (
					tempSprite.inner.width > 200 ? tempSprite.inner.width*0.1f:20)
				&& Mathf.Abs(tempSprite.inner.height - tempEntry.tex.height) <= (
					tempSprite.inner.height > 200 ? tempSprite.inner.height*0.1f:20))
				{
					searched = tempSprite;
					break;
				}else if(Mathf.Abs(tempSprite.outer.width - tempEntry.tex.width) <= (
					tempSprite.outer.width > 200 ? tempSprite.outer.width*0.1f:20)
				&& Mathf.Abs(tempSprite.outer.height - tempEntry.tex.height) <= (
					tempSprite.outer.height > 200 ? tempSprite.outer.height*0.1f:20)){
					searched = tempSprite;
					break;	
				}else{
					Debug.LogWarning("Name:"+tempSprite.name
									+" Sprite:"+tempSprite.inner
									+" Sprite:"+tempSprite.outer
									+" Entry:"+tempEntry.tex.width + " "+ tempEntry.tex.height);
				}
			}

		}
		
		return searched!= null;
	}