public void Awake() { Singleton = this; //// Set time for the plugin //SetTimeFromUnity(Time.timeSinceLevelLoad); }
private static void UpdateByType(ResourceInfoEx info, byte[] data) { if (info.obj == null) { return; } if (info.obj is Texture2D) { int tfval = (int)info.propertyfield["m_TextureFormat"]; TextureFormat tf = (TextureFormat)tfval; bool minmip = (bool)info.propertyfield["m_MipMap"]; int width = (int)info.propertyfield["m_Width"]; int height = (int)info.propertyfield["m_Height"]; int lightmapformat = (int)info.propertyfield["m_LightmapFormat"]; Texture2D tex = (Texture2D)info.obj; int d3dformat = -1; if (tf == TextureFormat.ARGB32) { d3dformat = 21; } else if (tf == TextureFormat.DXT5) { d3dformat = 894720068; } else if (tf == TextureFormat.DXT1) { d3dformat = 827611204; } else if (tf == TextureFormat.Alpha8) { d3dformat = 28; } if (d3dformat != -1) { int usage = 0; // 0x00000200; int lockflag = 0; // 0x00002000; int levels = minmip ? 0 : 1; int pool = 0; IntPtr oldp = tex.GetNativeTexturePtr(); RenderingPlugin.ReleaseTexture(oldp); IntPtr pData = Marshal.AllocHGlobal(data.Length); Marshal.Copy(data, 0, pData, data.Length); IntPtr p = RenderingPlugin.CreateTexture(width, height, levels, usage, d3dformat, pool, lightmapformat, pData, data.Length, lockflag); Marshal.FreeHGlobal(pData); tex.UpdateExternalTexture(p); tex.name = info.objectname; } } }
private static UnityEngine.Object LoadByType(ResourceInfoEx info, byte[] data, Type t) { UnityEngine.Object retobj = null; if (t == typeof(Texture2D)) { int tfval = (int)info.propertyfield["m_TextureFormat"]; TextureFormat tf = (TextureFormat)tfval; bool minmip = (bool)info.propertyfield["m_MipMap"]; int width = (int)info.propertyfield["m_Width"]; int height = (int)info.propertyfield["m_Height"]; int lightmapformat = (int)info.propertyfield["m_LightmapFormat"]; Texture2D tex = null; int d3dformat = -1; if (tf == TextureFormat.ARGB32) { d3dformat = 21; } else if (tf == TextureFormat.DXT5) { d3dformat = 894720068; } else if (tf == TextureFormat.DXT1) { d3dformat = 827611204; } else if (tf == TextureFormat.Alpha8) { d3dformat = 28; } if (d3dformat != -1) { int usage = 0; // 0x00000200; int lockflag = 0; // 0x00002000; int levels = minmip ? 0 : 1; int pool = 0; IntPtr pData = Marshal.AllocHGlobal(data.Length); Marshal.Copy(data, 0, pData, data.Length); IntPtr p = RenderingPlugin.CreateTexture(width, height, levels, usage, d3dformat, pool, lightmapformat, pData, data.Length, lockflag); Marshal.FreeHGlobal(pData); tex = Texture2D.CreateExternalTexture(width, height, tf, true, false, p); tex.name = info.objectname; } retobj = tex; } info.refcount = 1; info.obj = retobj; return(retobj); }
private static void UnloadByType(ResourceInfoEx info) { if (info.obj == null) { return; } if (info.obj is Texture2D) { Texture2D tex = (Texture2D)info.obj; IntPtr oldp = tex.GetNativeTexturePtr(); RenderingPlugin.ReleaseTexture(oldp); tex.UpdateExternalTexture(IntPtr.Zero); Texture2D.Destroy(tex); } info.obj = null; info.refcount = 0; }
public void OnDestroy() { Singleton = null; }