static public int OverrideGeometry(IntPtr l) { try { UnityEngine.Sprite self = (UnityEngine.Sprite)checkSelf(l); UnityEngine.Vector2[] a1; checkType(l, 2, out a1); System.UInt16[] a2; checkType(l, 3, out a2); self.OverrideGeometry(a1, a2); return(0); } catch (Exception e) { return(error(l, e)); } }
static int OverrideGeometry(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); UnityEngine.Sprite obj = (UnityEngine.Sprite)ToLua.CheckObject(L, 1, typeof(UnityEngine.Sprite)); UnityEngine.Vector2[] arg0 = ToLua.CheckObjectArray <UnityEngine.Vector2>(L, 2); ushort[] arg1 = ToLua.CheckNumberArray <ushort>(L, 3); obj.OverrideGeometry(arg0, arg1); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static void DoSpriteOverride(SpriteMesh spriteMesh, Sprite sprite) { SpriteMeshData spriteMeshData = SpriteMeshUtils.LoadSpriteMeshData(spriteMesh); if(spriteMeshData) { Rect rect = SpriteMeshUtils.CalculateSpriteRect(spriteMesh,5); Rect spriteRect = sprite.rect; Vector2 factor = new Vector2(spriteRect.width/rect.width,spriteRect.height/rect.height); Vector2[] newVertices = new List<Vector2>(spriteMeshData.vertices).ConvertAll( v => MathUtils.ClampPositionInRect(Vector2.Scale(v,factor),spriteRect) - spriteRect.position ).ToArray(); ushort[] newIndices = new List<int>(spriteMeshData.indices).ConvertAll<ushort>( i => (ushort)i ).ToArray(); sprite.OverrideGeometry(newVertices, newIndices); } }