Example #1
0
        internal sealed override void AddTo(UnityEngine.UI.VertexHelper helper)
        {
            if (Verts != null)
            {
                var count = helper.currentVertCount;

                foreach (var vert in Verts)
                {
                    helper.AddVert(Map(vert));
                }

                helper.AddTriangle(count, count + 1, count + 2);
                helper.AddTriangle(count + 2, count + 3, count);
            }
        }
        static int _m_AddTriangle(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                UnityEngine.UI.VertexHelper gen_to_be_invoked = (UnityEngine.UI.VertexHelper)translator.FastGetCSObj(L, 1);



                {
                    int _idx0 = LuaAPI.xlua_tointeger(L, 2);
                    int _idx1 = LuaAPI.xlua_tointeger(L, 3);
                    int _idx2 = LuaAPI.xlua_tointeger(L, 4);

                    gen_to_be_invoked.AddTriangle(_idx0, _idx1, _idx2);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
        static StackObject *AddTriangle_10(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 4);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Int32 @idx2 = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Int32 @idx1 = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.Int32 @idx0 = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            UnityEngine.UI.VertexHelper instance_of_this_method = (UnityEngine.UI.VertexHelper) typeof(UnityEngine.UI.VertexHelper).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.AddTriangle(@idx0, @idx1, @idx2);

            return(__ret);
        }
        protected override void OnPopulateMesh(UnityEngine.UI.VertexHelper toFill)
        {
            if (null == points_)
            {
                resetPoints();
            }

            if (points_.Length < 3)
            {
                return;
            }
            int           numPoints = points_.Length;
            RectTransform rectTrans = GetComponent <RectTransform>();
            UIVertex      vertex    = new UIVertex();

            Vector2 localOffset;

            localOffset.x = rectTrans.pivot.x * rectTrans.rect.width;
            localOffset.y = rectTrans.pivot.y * rectTrans.rect.height;

            Vector2 isize;
            Vector2 local;

            toFill.Clear();

            if (null == sprite)
            {
                isize.x = (1.0e-4f < rectTrans.rect.width) ? 1.0f / rectTrans.rect.width : 1.0f;
                isize.y = (1.0e-4f < rectTrans.rect.height) ? 1.0f / rectTrans.rect.height : 1.0f;

                for (int i = 0; i < numPoints; ++i)
                {
                    vertex.position = points_[i];
                    vertex.color    = this.color;

                    local = points_[i] + localOffset;

                    vertex.uv0.x = (local.x) * isize.x;
                    vertex.uv0.y = (local.y) * isize.y;

                    toFill.AddVert(vertex);
                }

                for (int i = 2; i < numPoints; ++i)
                {
                    toFill.AddTriangle(0, i - 1, i);
                }
                return;
            }

            //Debug.Log("OnPopulateMesh:" + gameObject.name + " " + sprite.packed);

            isize.x = (1 < sprite.texture.width) ? 1.0f / sprite.texture.width : 1.0f;
            isize.y = (1 < sprite.texture.height) ? 1.0f / sprite.texture.height : 1.0f;

            Vector2 localToSprite;

            localToSprite.x = sprite.rect.width / rectTrans.rect.width;
            localToSprite.y = sprite.rect.height / rectTrans.rect.height;

            //Debug.Log("sprite.packed " + sprite.packed);
            //Debug.Log("sprite.textureRectOffset " + sprite.textureRectOffset);
            //Debug.Log("sprite.textureRect " + sprite.textureRect);
            //Debug.Log("sprite.rect " + sprite.rect);
            //Debug.Log("sprite.pivot " + sprite.pivot);

            //Debug.Log("RectTransform.rect " + rectTrans.rect);
            //Debug.Log("RectTransform.pivot " + rectTrans.pivot);

            if (sprite.packed)
            {
                localOffset.x += sprite.textureRect.xMin;
                localOffset.y += sprite.textureRect.yMin;
                for (int i = 0; i < numPoints; ++i)
                {
                    vertex.position = points_[i];
                    vertex.color    = this.color;

                    local    = points_[i] + localOffset;
                    local.x *= localToSprite.x;
                    local.y *= localToSprite.y;

                    vertex.uv0.x = (local.x) * isize.x;
                    vertex.uv0.y = (local.y) * isize.y;

                    toFill.AddVert(vertex);
                }
            }
            else
            {
                for (int i = 0; i < numPoints; ++i)
                {
                    vertex.position = points_[i];
                    vertex.color    = this.color;

                    local    = points_[i] + localOffset;
                    local.x *= localToSprite.x;
                    local.y *= localToSprite.y;

                    vertex.uv0.x = (local.x) * isize.x;
                    vertex.uv0.y = (local.y) * isize.y;

                    toFill.AddVert(vertex);
                }
            }

            for (int i = 2; i < numPoints; ++i)
            {
                toFill.AddTriangle(0, i - 1, i);
            }
        }
Example #5
0
 internal sealed override void AddTo(UnityEngine.UI.VertexHelper helper)
 {
     helper.AddTriangle(Indices.x, Indices.y, Indices.z);
 }