public unsafe static bool LoadImage(Texture2D tex, byte[] data, bool markNonReadable) { if (method_LoadImage_ptr == IntPtr.Zero) { method_LoadImage_ptr = UnityInternals.ResolveICall("UnityEngine.ImageConversion::LoadImage(UnityEngine.Texture2D,System.Byte[],System.Boolean)"); if (method_LoadImage_ptr == IntPtr.Zero) { MelonLogger.Error("Failed to resolve icall UnityEngine.ImageConversion::LoadImage(UnityEngine.Texture2D,System.Byte[],System.Boolean)"); return(false); } if (method_LoadImage_ptr != IntPtr.Zero) { ImageConversion_LoadImage = (ImageConversion_LoadImage_Delegate)Marshal.GetDelegateForFunctionPointer(method_LoadImage_ptr, typeof(ImageConversion_LoadImage_Delegate)); } } if (ImageConversion_LoadImage != null) { IntPtr dataPtr = UnityInternals.array_new(InternalClassPointerStore <byte> .NativeClassPtr, (uint)data.Length); for (var i = 0; i < data.Length; i++) { IntPtr arrayStartPointer = (IntPtr)((long)dataPtr + 4 * IntPtr.Size); ((byte *)arrayStartPointer.ToPointer())[i] = data[i]; } return(ImageConversion_LoadImage(tex.Pointer, dataPtr, markNonReadable)); } MelonLogger.Error("Failed to run UnityEngine.ImageConversion::LoadImage(UnityEngine.Texture2D,System.Byte[],System.Boolean)"); return(false); }
public unsafe static bool LoadImage(Texture2D tex, byte[] data, bool markNonReadable) { if (ImageConversion_LoadImage == null) { MelonLogger.Error("Failed to run UnityEngine.ImageConversion::LoadImage(UnityEngine.Texture2D,System.Byte[],System.Boolean)"); return(false); } IntPtr dataPtr = UnityInternals.array_new(InternalClassPointerStore <byte> .NativeClassPtr, (uint)data.Length); for (var i = 0; i < data.Length; i++) { IntPtr arrayStartPointer = (IntPtr)((long)dataPtr + 4 * IntPtr.Size); ((byte *)arrayStartPointer.ToPointer())[i] = data[i]; } return(ImageConversion_LoadImage(tex.Pointer, dataPtr, markNonReadable)); }
public unsafe void SetPixelsImpl(int x, int y, int w, int h, Color[] pixel, int miplevel, int frame) { IntPtr pixelArrayPtr = UnityInternals.array_new(InternalClassPointerStore <Color> .NativeClassPtr, (uint)pixel.Length); for (var i = 0; i < pixel.Length; i++) { IntPtr arrayStartPointer = (IntPtr)((long)pixelArrayPtr + 4 * IntPtr.Size); ((Color *)arrayStartPointer.ToPointer())[i] = pixel[i]; } if (type_SetPixelsImpl == 0) { m_SetPixelsImpl_2017(UnityInternals.ObjectBaseToPtrNotNull(this), x, y, w, h, pixelArrayPtr, miplevel); } else if (type_SetPixelsImpl == 1) { m_SetPixelsImpl_2018(UnityInternals.ObjectBaseToPtrNotNull(this), x, y, w, h, pixelArrayPtr, miplevel, frame); } }