Hi guys, dont know if I can get much help on this, but I am a little stuck and I cant figure this out.
I got code quite similar to this a while back from these forums and it is used to create a new atlas for use on ngui buttons.
Prior to updating, the code below worked fine, but since updating I am getting errors.
I have pasted the code and the error areas are commented.
private void CreateAtlas()
{
atlasTexture
= new Texture2D
(1,
1); spriteCoordInfo = atlasTexture.PackTextures(textureArray, 0);
atlasMat
= new Material
(Shader
.Find("Unlit/Transparent Colored")); atlasMat.SetTexture("_MainTex", atlasTexture);
myAtlas.GetComponent<UIAtlas>();
myAtlas.spriteMaterial = atlasMat;
myAtlas.coordinates = UIAtlas.Coordinates.TexCoords; <--- Error 1
myAtlas.spriteList.Clear();
for(int i = 0; i < spriteCoordInfo.Length; i++)
{
Rect coordinate = spriteCoordInfo[i];
UIAtlas
.Sprite sprite
= new UIAtlas
.Sprite(); **** sprite.name = names[i];
sprite.inner = coordinate; <---- error 2
sprite.outer = coordinate; <---- error 3
sprite.paddingBottom = 0;
sprite.paddingTop = 0;
sprite.paddingLeft = 0;
sprite.paddingRight = 0;
myAtlas.spriteList.Add(sprite);
}
}
I can remove the lines listed, and then change this line
UIAtlas
.Sprite sprite
= new UIAtlas
.Sprite(); ****
and replace it with
UISpriteData sprite
= new UISpriteData
();
but when I then assign the new sprites to my buttons I am getting new errors which are:
aabb.IsValid()
!IsFinite(outDistanceForSort)
UnityEditor.DockArea:OnGUI()
!IsFinite(outDistanceAlongView)
UnityEditor.DockArea:OnGUI()
!IsFinite(outDistanceForSort)
!IsFinite(outDistanceAlongView)
These errors just repeat themselves over and over.
I am fairly new to Unity and NGUI, so I apologise if this wastes anyones time, I will continue to try and fix this myself too!
Thanks in advance for any time and advice given.
Sigh
edit: I should note, that I believe the errors to be caused by the fact that the sprites are being added without their inner/outer coordinates? as a result, when rendering the sprite, the coordinates are (id imagine) 0, 0, 0, 0 ?
I did find a SetRect within spritedata, but that takes 4 int values? is this the replacement? if so, does this mean I need to get pixel coordinates from my packtextures line? rather than texcoords? Thanks again