Example #1
0
 static int QPYX_Resize_YXQP(IntPtr L_YXQP)
 {
     try
     {
         int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP);
         if (QPYX_count_YXQP == 3)
         {
             UnityEngine.Texture2D QPYX_obj_YXQP = (UnityEngine.Texture2D)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Texture2D));
             int  QPYX_arg0_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 2);
             int  QPYX_arg1_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 3);
             bool QPYX_o_YXQP    = QPYX_obj_YXQP.Resize(QPYX_arg0_YXQP, QPYX_arg1_YXQP);
             LuaDLL.lua_pushboolean(L_YXQP, QPYX_o_YXQP);
             return(1);
         }
         else if (QPYX_count_YXQP == 5)
         {
             UnityEngine.Texture2D QPYX_obj_YXQP = (UnityEngine.Texture2D)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Texture2D));
             int QPYX_arg0_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 2);
             int QPYX_arg1_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 3);
             UnityEngine.TextureFormat QPYX_arg2_YXQP = (UnityEngine.TextureFormat)ToLua.CheckObject(L_YXQP, 4, typeof(UnityEngine.TextureFormat));
             bool QPYX_arg3_YXQP = LuaDLL.luaL_checkboolean(L_YXQP, 5);
             bool QPYX_o_YXQP    = QPYX_obj_YXQP.Resize(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP, QPYX_arg3_YXQP);
             LuaDLL.lua_pushboolean(L_YXQP, QPYX_o_YXQP);
             return(1);
         }
         else
         {
             return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.Texture2D.Resize"));
         }
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
Example #2
0
        static object PerformMemberwiseClone(ref object o)
        {
            var ins = new UnityEngine.TextureFormat();

            ins = (UnityEngine.TextureFormat)o;
            return(ins);
        }
    static int CreateExternalTexture(IntPtr L)
    {
        ToLua.CheckArgsCount(L, 6);
        int arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
        int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);

        UnityEngine.TextureFormat arg2 = (UnityEngine.TextureFormat)ToLua.CheckObject(L, 3, typeof(UnityEngine.TextureFormat));
        bool arg3 = LuaDLL.luaL_checkboolean(L, 4);
        bool arg4 = LuaDLL.luaL_checkboolean(L, 5);

        System.IntPtr         arg5 = (System.IntPtr)LuaDLL.lua_touserdata(L, 6);
        UnityEngine.Texture2D o    = null;

        try
        {
            o = UnityEngine.Texture2D.CreateExternalTexture(arg0, arg1, arg2, arg3, arg4, arg5);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }

        ToLua.Push(L, o);
        return(1);
    }
Example #4
0
 public TextureInformation(byte[] imageData, UnityEngine.Vector2 scaleDifference, UnityEngine.Vector3 textureSize, UnityEngine.TextureFormat textureFormat)
 {
     this.imageData       = imageData;
     this.scaleDifference = scaleDifference;
     this.textureSize     = textureSize;
     this.textureFormat   = textureFormat;
 }
        private static UTexture2D LoadDXT(byte[] ddsBytes, TextureFormat textureFormat, bool mipmap)
        {
            if (textureFormat != TextureFormat.DXT1 && textureFormat != TextureFormat.DXT5)
            {
                throw new Error("Invalid TextureFormat. Only DXT1 and DXT5 formats are supported by this method.");
            }

            byte ddsSizeCheck = ddsBytes[4];

            if (ddsSizeCheck != 124)
            {
                throw new Error("Invalid DDS DXTn texture. Unable to read");                  //this header byte should be 124 for DDS image files
            }
            int height = ddsBytes[13] * 256 + ddsBytes[12];
            int width  = ddsBytes[17] * 256 + ddsBytes[16];

            int DDS_HEADER_SIZE = 128;

            byte[] dxtBytes = new byte[ddsBytes.Length - DDS_HEADER_SIZE];
            Buffer.BlockCopy(ddsBytes, DDS_HEADER_SIZE, dxtBytes, 0, ddsBytes.Length - DDS_HEADER_SIZE);

            UTexture2D texture = new UTexture2D(width, height, textureFormat, mipmap);

            texture.LoadRawTextureData(dxtBytes);
            texture.Apply();

            return(texture);
        }
Example #6
0
        static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 5);

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

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            UnityEngine.TextureFormat @format = (UnityEngine.TextureFormat) typeof(UnityEngine.TextureFormat).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

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

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

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


            var result_of_this_method = new UnityEngine.Texture3D(@width, @height, @depth, @format, @mipmap);

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
        private static void LoadDXT(out UTexture2D tex, string effectivePath, bool mipmap, string fileNamePath)
        {
            byte[] bytes = SIO.File.ReadAllBytes(effectivePath);

            SIO.BinaryReader binaryReader = new SIO.BinaryReader(new SIO.MemoryStream(bytes));
            uint             num          = binaryReader.ReadUInt32();

            if (num != DDSValues.uintMagic)
            {
                throw new Error("DDS: File {0} is not a DDS format file!", fileNamePath);
            }

            DDSHeader ddSHeader = new DDSHeader(binaryReader);

            TextureFormat tf = TextureFormat.Alpha8;

            if (ddSHeader.ddspf.dwFourCC == DDSValues.uintDXT1)
            {
                tf = TextureFormat.DXT1;
            }
            if (ddSHeader.ddspf.dwFourCC == DDSValues.uintDXT5)
            {
                tf = TextureFormat.DXT5;
            }
            if (tf == TextureFormat.Alpha8)
            {
                throw new Error("DDS: TextureFormat {0} File {1} is not supported!", tf, fileNamePath);
            }

            tex = LoadDXT(bytes, tf, mipmap);
        }
    private void SaveRenderTextureToPNG(
        UnityEngine.RenderTexture renderTexture,
        UnityEngine.TextureFormat textureFormat,
        RenderCheck renderCheck)
    {
        string fileName = string.Empty;

        if (renderCheck.Match != null)
        {
            fileName = UnityEditor.AssetDatabase.GetAssetPath(renderCheck.Match);
        }
        else
        {
            fileName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(UnityEditor.AssetDatabase.GetAssetPath(renderCheck));
        }

        fileName = System.IO.Path.GetDirectoryName(fileName) + "/" + System.IO.Path.GetFileNameWithoutExtension(fileName) + ".png";

        if (renderCheck.Match != null && (renderCheck.Match.width != renderTexture.width || renderCheck.Match.height != renderTexture.height))
        {
            UnityEngine.GameObject.Destroy(renderCheck.Match);
        }

        if (renderCheck.Match == null)
        {
            renderCheck.Match = new UnityEngine.Texture2D(renderTexture.width, renderTexture.height, textureFormat, false, true);
        }

        UnityEngine.RenderTexture previousRT = UnityEngine.RenderTexture.active;
        UnityEngine.RenderTexture.active = renderTexture;
        UnityEngine.Texture2D linearTexture = new UnityEngine.Texture2D(renderTexture.width, renderTexture.height, UnityEngine.TextureFormat.RGBAFloat, false);
        linearTexture.ReadPixels(new UnityEngine.Rect(0.0f, 0.0f, (float)renderTexture.width, (float)renderTexture.height), 0, 0, false);
        //linearTexture.Apply();

        renderCheck.Match.SetPixels32(linearTexture.GetPixels32());
        UnityEngine.GameObject.DestroyImmediate(linearTexture);
        linearTexture = null;
        UnityEngine.RenderTexture.active = previousRT;

        renderCheck.Match.Apply(false, false);

        byte[] pngFile = UnityEngine.ImageConversion.EncodeToPNG(renderCheck.Match);

        try
        {
            using (System.IO.Stream fileStream = new System.IO.FileStream(fileName, System.IO.FileMode.Create))
            {
                System.IO.BinaryWriter streamWriter = new System.IO.BinaryWriter(fileStream);
                streamWriter.Write(pngFile);
                this.needRefresh = true;
                this.needReload.Add(new System.Collections.Generic.KeyValuePair <RenderCheck, string>(renderCheck, fileName));
            }
        }
        catch (System.Exception exception)
        {
            UnityEngine.Debug.LogError(string.Format("Saving texture at path {0} failed with exception {1}", fileName, exception.Message));
        }
    }
        public void Serialize(OverloadLevelConvertSerializer serializer)
        {
            serializer.StartCmd(CommandId);

            int    width         = 0;
            int    height        = 0;
            string formatStr     = UnityEngine.TextureFormat.RGB24.ToString();
            string filterModeStr = UnityEngine.FilterMode.Bilinear.ToString();
            string name          = string.Empty;
            bool   mipmap        = false;

            if (serializer.IsWriting)
            {
                width         = texture.width;
                height        = texture.height;
                formatStr     = texture.format.ToString();
                filterModeStr = texture.filterMode.ToString();
                name          = texture.name;
#if OVERLOAD_LEVEL_EDITOR
                mipmap = texture.mipmap;
#endif
            }

            serializer.SerializeX(this, x => x.texture2DGuid);
            serializer.Serialize(ref width);
            serializer.Serialize(ref height);
            serializer.Serialize(ref formatStr);
            serializer.Serialize(ref mipmap);
            serializer.Serialize(ref filterModeStr);
            serializer.Serialize(ref name);

            UnityEngine.Color32[] pixelData = null;
            if (serializer.IsWriting)
            {
                serializer.SerializeOut_array(typeof(UnityEngine.Color32), texture.GetPixels32());
            }
            else
            {
                pixelData = (UnityEngine.Color32[])serializer.SerializeIn_array(typeof(UnityEngine.Color32));
            }

            if (!serializer.IsWriting)
            {
                UnityEngine.TextureFormat format = (UnityEngine.TextureFormat)Enum.Parse(typeof(UnityEngine.TextureFormat), formatStr);
                this.texture = new UnityEngine.Texture2D(width, height, format, mipmap);

                UnityEngine.FilterMode filterMode = (UnityEngine.FilterMode)Enum.Parse(typeof(UnityEngine.FilterMode), filterModeStr);
                this.texture.filterMode = filterMode;

                this.texture.name = name;

                this.texture.SetPixels32(pixelData);
                this.texture.Apply();
            }

            serializer.FinishCmd(CommandId);
        }
Example #10
0
        public DDSImage(byte[] rawdata)
        {
            using (MemoryStream ms = new MemoryStream(rawdata)) {
                using (BinaryReader r = new BinaryReader(ms)) {
                    dwMagic = r.ReadInt32();
                    if (dwMagic != 0x20534444)
                    {
                        throw new Exception("This is not a DDS!");
                    }

                    Read_DDS_HEADER(header, r);

                    if (((header.ddspf.dwFlags & DDPF_FOURCC) != 0) && (header.ddspf.dwFourCC == FOURCC_DX10 /*DX10*/))
                    {
                        throw new Exception("DX10 not supported yet!");
                    }

                    _mipMapCount = 1;
                    if ((header.dwFlags & DDSD_MIPMAPCOUNT) != 0)
                    {
                        _mipMapCount = header.dwMipMapCount;
                    }
                    images = new Bitmap[_mipMapCount];

                    //Version .4 <Denys.Bul*>
                    int sliceSize = header.dwPitchOrLinearSize > 0 ? header.dwPitchOrLinearSize : header.dwWidth * header.dwHeight * 4;
                    bdata = r.ReadBytes(sliceSize);

                    for (int i = 0; i < mipMapCount; ++i)
                    {
                        // Version .2 changes <AmaroK86>
                        int w = (int)(header.dwWidth / Math.Pow(2, i));
                        int h = (int)(header.dwHeight / Math.Pow(2, i));

                        if ((header.ddspf.dwFlags & DDPF_RGB) != 0)
                        {
                            format    = UnityEngine.TextureFormat.ARGB32;
                            images[i] = readLinearImage(bdata, w, h);
                        }
                        else if ((header.ddspf.dwFlags & DDPF_FOURCC) != 0)
                        {
                            images[i] = readBlockImage(bdata, w, h);
                        }
                        else if ((header.ddspf.dwFlags & DDPF_FOURCC) == 0 &&
                                 header.ddspf.dwRGBBitCount == 0x10 &&
                                 header.ddspf.dwRBitMask == 0xFF &&
                                 header.ddspf.dwGBitMask == 0xFF00 &&
                                 header.ddspf.dwBBitMask == 0x00 &&
                                 header.ddspf.dwABitMask == 0x00)
                        {
                            images[i] = UncompressV8U8(bdata, w, h);                            // V8U8 normalmap format
                        }
                    }
                }
            }
        }
Example #11
0
 public Cubemap(System.Int32 size, UnityEngine.TextureFormat format, System.Boolean mipmap)
 {
     //Mock Data:
     m_functionCallCounts = new Dictionary <string, int>();
     if (!m_functionCallCounts.ContainsKey("Void .ctor(Int32, TextureFormat, Boolean)"))
     {
         m_functionCallCounts.Add("Void .ctor(Int32, TextureFormat, Boolean)", 0);
     }
     m_functionCallCounts["Void .ctor(Int32, TextureFormat, Boolean)"]++;
 }
    static int _CreateUnityEngine_Texture2D(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.Texture2D obj = new UnityEngine.Texture2D(arg0, arg1);
                ToLua.PushSealed(L, obj);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes <UnityEngine.Experimental.Rendering.GraphicsFormat, UnityEngine.Experimental.Rendering.TextureCreationFlags>(L, 3))
            {
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.Experimental.Rendering.GraphicsFormat       arg2 = (UnityEngine.Experimental.Rendering.GraphicsFormat)ToLua.ToObject(L, 3);
                UnityEngine.Experimental.Rendering.TextureCreationFlags arg3 = (UnityEngine.Experimental.Rendering.TextureCreationFlags)ToLua.ToObject(L, 4);
                UnityEngine.Texture2D obj = new UnityEngine.Texture2D(arg0, arg1, arg2, arg3);
                ToLua.PushSealed(L, obj);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes <UnityEngine.TextureFormat, bool>(L, 3))
            {
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.TextureFormat arg2 = (UnityEngine.TextureFormat)ToLua.ToObject(L, 3);
                bool arg3 = LuaDLL.lua_toboolean(L, 4);
                UnityEngine.Texture2D obj = new UnityEngine.Texture2D(arg0, arg1, arg2, arg3);
                ToLua.PushSealed(L, obj);
                return(1);
            }
            else if (count == 5)
            {
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.TextureFormat arg2 = (UnityEngine.TextureFormat)ToLua.CheckObject(L, 3, typeof(UnityEngine.TextureFormat));
                bool arg3 = LuaDLL.luaL_checkboolean(L, 4);
                bool arg4 = LuaDLL.luaL_checkboolean(L, 5);
                UnityEngine.Texture2D obj = new UnityEngine.Texture2D(arg0, arg1, arg2, arg3, arg4);
                ToLua.PushSealed(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.Texture2D.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Example #13
0
 internal static bool HasAlpha(UnityEngine.TextureFormat format)
 {
     return(format == UnityEngine.TextureFormat.Alpha8 ||
            format == UnityEngine.TextureFormat.ARGB4444 ||
            format == UnityEngine.TextureFormat.ARGB32 ||
            format == UnityEngine.TextureFormat.RGBA32 ||
            format == UnityEngine.TextureFormat.DXT5 ||
            format == UnityEngine.TextureFormat.PVRTC_RGBA2 ||
            format == UnityEngine.TextureFormat.PVRTC_RGBA4 ||
            format == UnityEngine.TextureFormat.ETC2_RGBA8);
 }
    static int Resize(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 3 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.Texture2D), typeof(int), typeof(int)))
        {
            UnityEngine.Texture2D obj = (UnityEngine.Texture2D)ToLua.ToObject(L, 1);
            int  arg0 = (int)LuaDLL.lua_tonumber(L, 2);
            int  arg1 = (int)LuaDLL.lua_tonumber(L, 3);
            bool o;

            try
            {
                o = obj.Resize(arg0, arg1);
            }
            catch (Exception e)
            {
                return(LuaDLL.toluaL_exception(L, e));
            }

            LuaDLL.lua_pushboolean(L, o);
            return(1);
        }
        else if (count == 5 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.Texture2D), typeof(int), typeof(int), typeof(UnityEngine.TextureFormat), typeof(bool)))
        {
            UnityEngine.Texture2D obj = (UnityEngine.Texture2D)ToLua.ToObject(L, 1);
            int arg0 = (int)LuaDLL.lua_tonumber(L, 2);
            int arg1 = (int)LuaDLL.lua_tonumber(L, 3);
            UnityEngine.TextureFormat arg2 = (UnityEngine.TextureFormat)ToLua.ToObject(L, 4);
            bool arg3 = LuaDLL.lua_toboolean(L, 5);
            bool o;

            try
            {
                o = obj.Resize(arg0, arg1, arg2, arg3);
            }
            catch (Exception e)
            {
                return(LuaDLL.toluaL_exception(L, e));
            }

            LuaDLL.lua_pushboolean(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: UnityEngine.Texture2D.Resize");
        }

        return(0);
    }
Example #15
0
 static int QPYX_GetTextureFormat_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 1);
         int QPYX_arg0_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 1);
         UnityEngine.TextureFormat QPYX_o_YXQP = CustomerUtil.GetTextureFormat(QPYX_arg0_YXQP);
         ToLua.Push(L_YXQP, QPYX_o_YXQP);
         return(1);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
Example #16
0
 static int GetTextureFormat(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         int arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
         UnityEngine.TextureFormat o = CustomerUtil.GetTextureFormat(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Example #17
0
    static int QPYX_get_format_YXQP(IntPtr L_YXQP)
    {
        object QPYX_o_YXQP = null;

        try
        {
            QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1);                        UnityEngine.Texture2D QPYX_obj_YXQP = (UnityEngine.Texture2D)QPYX_o_YXQP;
            UnityEngine.TextureFormat QPYX_ret_YXQP = QPYX_obj_YXQP.format;
            ToLua.Push(L_YXQP, QPYX_ret_YXQP);
            return(1);
        }
        catch (Exception QPYX_e_YXQP)            {
            return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index format on a nil value"));
        }
    }
 static int SupportsTextureFormat(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.TextureFormat arg0 = (UnityEngine.TextureFormat)LuaDLL.luaL_checknumber(L, 1);
         var o = UnityEngine.SystemInfo.SupportsTextureFormat(arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Example #19
0
 static int GetTextureFormat(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.Texture       arg0 = (UnityEngine.Texture)ToLua.CheckUnityObject(L, 1, typeof(UnityEngine.Texture));
         UnityEngine.TextureFormat o    = UnGfx.GetTextureFormat(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Example #20
0
        static void WriteBackInstance(CSHotFix.Runtime.Enviorment.AppDomain __domain, StackObject *ptr_of_this_method, IList <object> __mStack, ref UnityEngine.TextureFormat instance_of_this_method)
        {
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            switch (ptr_of_this_method->ObjectType)
            {
            case ObjectTypes.Object:
            {
                __mStack[ptr_of_this_method->Value] = instance_of_this_method;
            }
            break;

            case ObjectTypes.FieldReference:
            {
                var ___obj = __mStack[ptr_of_this_method->Value];
                if (___obj is ILTypeInstance)
                {
                    ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method;
                }
                else
                {
                    var t = __domain.GetType(___obj.GetType()) as CLRType;
                    t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method);
                }
            }
            break;

            case ObjectTypes.StaticFieldReference:
            {
                var t = __domain.GetType(ptr_of_this_method->Value);
                if (t is ILType)
                {
                    ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method;
                }
                else
                {
                    ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method);
                }
            }
            break;

            case ObjectTypes.ArrayReference:
            {
                var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as UnityEngine.TextureFormat[];
                instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method;
            }
            break;
            }
        }
    static int _CreateUnityEngine_Texture2D(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.Texture2D.ctor");
#endif
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.Texture2D obj = new UnityEngine.Texture2D(arg0, arg1);
                ToLua.PushSealed(L, obj);
                return(1);
            }
            else if (count == 4)
            {
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.TextureFormat arg2 = (UnityEngine.TextureFormat)ToLua.CheckObject(L, 3, typeof(UnityEngine.TextureFormat));
                bool arg3 = LuaDLL.luaL_checkboolean(L, 4);
                UnityEngine.Texture2D obj = new UnityEngine.Texture2D(arg0, arg1, arg2, arg3);
                ToLua.PushSealed(L, obj);
                return(1);
            }
            else if (count == 5)
            {
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.TextureFormat arg2 = (UnityEngine.TextureFormat)ToLua.CheckObject(L, 3, typeof(UnityEngine.TextureFormat));
                bool arg3 = LuaDLL.luaL_checkboolean(L, 4);
                bool arg4 = LuaDLL.luaL_checkboolean(L, 5);
                UnityEngine.Texture2D obj = new UnityEngine.Texture2D(arg0, arg1, arg2, arg3, arg4);
                ToLua.PushSealed(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.Texture2D.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Example #22
0
        private Bitmap readBlockImage(byte[] data, int w, int h)
        {
            switch (header.ddspf.dwFourCC)
            {
            case FOURCC_DXT1:
                format = UnityEngine.TextureFormat.DXT1;
                return(UncompressDXT1(data, w, h));

            case FOURCC_DXT5:
                format = UnityEngine.TextureFormat.DXT5;
                return(UncompressDXT5(data, w, h));

            default: break;
            }
            throw new Exception(string.Format("0x{0} texture compression not implemented.", header.ddspf.dwFourCC.ToString("X")));
        }
Example #23
0
        static StackObject *SupportsTextureFormat_34(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.TextureFormat format = (UnityEngine.TextureFormat) typeof(UnityEngine.TextureFormat).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = UnityEngine.SystemInfo.SupportsTextureFormat(format);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method ? 1 : 0;
            return(__ret + 1);
        }
    static int Resize(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3)
            {
                UnityEngine.Texture2D obj = (UnityEngine.Texture2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Texture2D));
                int  arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
                int  arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
                bool o    = obj.Resize(arg0, arg1);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else if (count == 5 && TypeChecker.CheckTypes <UnityEngine.TextureFormat, bool>(L, 4))
            {
                UnityEngine.Texture2D obj = (UnityEngine.Texture2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Texture2D));
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
                UnityEngine.TextureFormat arg2 = (UnityEngine.TextureFormat)ToLua.ToObject(L, 4);
                bool arg3 = LuaDLL.lua_toboolean(L, 5);
                bool o    = obj.Resize(arg0, arg1, arg2, arg3);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else if (count == 5 && TypeChecker.CheckTypes <UnityEngine.Experimental.Rendering.GraphicsFormat, bool>(L, 4))
            {
                UnityEngine.Texture2D obj = (UnityEngine.Texture2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Texture2D));
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
                UnityEngine.Experimental.Rendering.GraphicsFormat arg2 = (UnityEngine.Experimental.Rendering.GraphicsFormat)ToLua.ToObject(L, 4);
                bool arg3 = LuaDLL.lua_toboolean(L, 5);
                bool o    = obj.Resize(arg0, arg1, arg2, arg3);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Texture2D.Resize"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Example #25
0
    static int get_format(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Texture2D     obj = (UnityEngine.Texture2D)o;
            UnityEngine.TextureFormat ret = obj.format;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index format on a nil value"));
        }
    }
Example #26
0
    static int _CreateUnityEngine_Texture2D(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.Texture2D obj = new UnityEngine.Texture2D(arg0, arg1);
                ToLua.Push(L, obj);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(int), typeof(int), typeof(UnityEngine.TextureFormat), typeof(bool)))
            {
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.TextureFormat arg2 = (UnityEngine.TextureFormat)ToLua.CheckObject(L, 3, typeof(UnityEngine.TextureFormat));
                bool arg3 = LuaDLL.luaL_checkboolean(L, 4);
                UnityEngine.Texture2D obj = new UnityEngine.Texture2D(arg0, arg1, arg2, arg3);
                ToLua.Push(L, obj);
                return(1);
            }
            else if (count == 5 && TypeChecker.CheckTypes(L, 1, typeof(int), typeof(int), typeof(UnityEngine.TextureFormat), typeof(bool), typeof(bool)))
            {
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.TextureFormat arg2 = (UnityEngine.TextureFormat)ToLua.CheckObject(L, 3, typeof(UnityEngine.TextureFormat));
                bool arg3 = LuaDLL.luaL_checkboolean(L, 4);
                bool arg4 = LuaDLL.luaL_checkboolean(L, 5);
                UnityEngine.Texture2D obj = new UnityEngine.Texture2D(arg0, arg1, arg2, arg3, arg4);
                ToLua.Push(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.Texture2D.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Example #27
0
 static int QPYX__CreateUnityEngine_Texture2D_YXQP(IntPtr L_YXQP)
 {
     try
     {
         int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP);
         if (QPYX_count_YXQP == 2)
         {
             int QPYX_arg0_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 1);
             int QPYX_arg1_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 2);
             UnityEngine.Texture2D QPYX_obj_YXQP = new UnityEngine.Texture2D(QPYX_arg0_YXQP, QPYX_arg1_YXQP);
             ToLua.PushSealed(L_YXQP, QPYX_obj_YXQP);
             return(1);
         }
         else if (QPYX_count_YXQP == 4)
         {
             int QPYX_arg0_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 1);
             int QPYX_arg1_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 2);
             UnityEngine.TextureFormat QPYX_arg2_YXQP = (UnityEngine.TextureFormat)ToLua.CheckObject(L_YXQP, 3, typeof(UnityEngine.TextureFormat));
             bool QPYX_arg3_YXQP = LuaDLL.luaL_checkboolean(L_YXQP, 4);
             UnityEngine.Texture2D QPYX_obj_YXQP = new UnityEngine.Texture2D(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP, QPYX_arg3_YXQP);
             ToLua.PushSealed(L_YXQP, QPYX_obj_YXQP);
             return(1);
         }
         else if (QPYX_count_YXQP == 5)
         {
             int QPYX_arg0_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 1);
             int QPYX_arg1_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 2);
             UnityEngine.TextureFormat QPYX_arg2_YXQP = (UnityEngine.TextureFormat)ToLua.CheckObject(L_YXQP, 3, typeof(UnityEngine.TextureFormat));
             bool QPYX_arg3_YXQP = LuaDLL.luaL_checkboolean(L_YXQP, 4);
             bool QPYX_arg4_YXQP = LuaDLL.luaL_checkboolean(L_YXQP, 5);
             UnityEngine.Texture2D QPYX_obj_YXQP = new UnityEngine.Texture2D(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP, QPYX_arg3_YXQP, QPYX_arg4_YXQP);
             ToLua.PushSealed(L_YXQP, QPYX_obj_YXQP);
             return(1);
         }
         else
         {
             return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to ctor method: UnityEngine.Texture2D.New"));
         }
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
Example #28
0
 static int QPYX_CreateExternalTexture_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 6);
         int QPYX_arg0_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 1);
         int QPYX_arg1_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 2);
         UnityEngine.TextureFormat QPYX_arg2_YXQP = (UnityEngine.TextureFormat)ToLua.CheckObject(L_YXQP, 3, typeof(UnityEngine.TextureFormat));
         bool                  QPYX_arg3_YXQP     = LuaDLL.luaL_checkboolean(L_YXQP, 4);
         bool                  QPYX_arg4_YXQP     = LuaDLL.luaL_checkboolean(L_YXQP, 5);
         System.IntPtr         QPYX_arg5_YXQP     = ToLua.CheckIntPtr(L_YXQP, 6);
         UnityEngine.Texture2D QPYX_o_YXQP        = UnityEngine.Texture2D.CreateExternalTexture(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP, QPYX_arg3_YXQP, QPYX_arg4_YXQP, QPYX_arg5_YXQP);
         ToLua.PushSealed(L_YXQP, QPYX_o_YXQP);
         return(1);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
 static int CreateExternalTexture(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 6);
         int arg0 = (int)LuaDLL.luaL_checkinteger(L, 1);
         int arg1 = (int)LuaDLL.luaL_checkinteger(L, 2);
         UnityEngine.TextureFormat arg2 = (UnityEngine.TextureFormat)ToLua.CheckObject(L, 3, TypeTraits <UnityEngine.TextureFormat> .type);
         bool                  arg3     = LuaDLL.luaL_checkboolean(L, 4);
         bool                  arg4     = LuaDLL.luaL_checkboolean(L, 5);
         System.IntPtr         arg5     = ToLua.CheckIntPtr(L, 6);
         UnityEngine.Texture2D o        = UnityEngine.Texture2D.CreateExternalTexture(arg0, arg1, arg2, arg3, arg4, arg5);
         ToLua.PushSealed(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Example #30
0
    static int get_format(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.Texture2D.format");
#endif
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Texture2D     obj = (UnityEngine.Texture2D)o;
            UnityEngine.TextureFormat ret = obj.format;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index format on a nil value"));
        }
    }
Example #31
0
		private Bitmap readBlockImage(byte[] data, int w, int h) {
			switch (header.ddspf.dwFourCC) {
				case FOURCC_DXT1:
					format = UnityEngine.TextureFormat.DXT1;
					return UncompressDXT1(data, w, h);
				case FOURCC_DXT5:
					format = UnityEngine.TextureFormat.DXT5;
					return UncompressDXT5(data, w, h);
				default: break;
			}
			throw new Exception(string.Format("0x{0} texture compression not implemented.", header.ddspf.dwFourCC.ToString("X")));
		}
Example #32
0
		public DDSImage(byte[] rawdata) {
			using (MemoryStream ms = new MemoryStream(rawdata)) {
				using (BinaryReader r = new BinaryReader(ms)) {
					dwMagic = r.ReadInt32();
					if (dwMagic != 0x20534444) {
						throw new Exception("This is not a DDS!");
					}

					Read_DDS_HEADER(header, r);

					if (((header.ddspf.dwFlags & DDPF_FOURCC) != 0) && (header.ddspf.dwFourCC == FOURCC_DX10 /*DX10*/)) {
						throw new Exception("DX10 not supported yet!");
					}

					_mipMapCount = 1;
					if ((header.dwFlags & DDSD_MIPMAPCOUNT) != 0)
						_mipMapCount = header.dwMipMapCount;
					images = new Bitmap[_mipMapCount];

					//Version .4 <Denys.Bul*>
					int sliceSize = header.dwPitchOrLinearSize > 0 ? header.dwPitchOrLinearSize : header.dwWidth * header.dwHeight * 4;
					bdata = r.ReadBytes(sliceSize);

					for (int i = 0; i < mipMapCount; ++i) {
						// Version .2 changes <AmaroK86>
						int w = (int)(header.dwWidth / Math.Pow(2, i));
						int h = (int)(header.dwHeight / Math.Pow(2, i));

						if ((header.ddspf.dwFlags & DDPF_RGB) != 0) {
							format = UnityEngine.TextureFormat.ARGB32;
							images[i]= readLinearImage(bdata, w, h);
						} else if ((header.ddspf.dwFlags & DDPF_FOURCC) != 0) {
							images[i] = readBlockImage(bdata, w, h);
						} else if ((header.ddspf.dwFlags & DDPF_FOURCC) == 0 &&
									header.ddspf.dwRGBBitCount == 0x10 &&
									header.ddspf.dwRBitMask == 0xFF &&
									header.ddspf.dwGBitMask == 0xFF00 &&
									header.ddspf.dwBBitMask == 0x00 &&
									header.ddspf.dwABitMask == 0x00) {
							images[i] = UncompressV8U8(bdata, w, h);// V8U8 normalmap format
						}
					}

				}
			}
		}