Beispiel #1
0
        public static Texture2DArray GifToTextureArray(string path)
        {
            Texture2DArray array = null;

            if ((Type.GetType("System.Drawing.Image, System.Drawing") != null))
            {
                Type       t_img                 = Type.GetType("System.Drawing.Image, System.Drawing");
                MethodInfo m_from_file           = t_img.GetMethod("FromFile", new Type[] { typeof(string) });
                MethodInfo m_get_frame_count     = t_img.GetMethod("GetFrameCount");
                MethodInfo m_select_active_frame = t_img.GetMethod("SelectActiveFrame");

                MethodInfo   m_dispose = t_img.GetMethod("Dispose");
                PropertyInfo p_width   = t_img.GetProperty("Width");
                PropertyInfo p_height  = t_img.GetProperty("Width");

                Type         t_frame_dim  = Type.GetType("System.Drawing.Imaging.FrameDimension, System.Drawing");
                PropertyInfo p_frame_time = t_frame_dim.GetProperty("Time");

                Type            t_bitmap            = Type.GetType("System.Drawing.Bitmap, System.Drawing");
                PropertyInfo    p_bitmap_raw_format = t_bitmap.GetProperty("RawFormat");
                ConstructorInfo c_bitmap            = t_bitmap.GetConstructor(new Type[] { t_img });

                Type       t_format = Type.GetType("System.Drawing.Imaging.ImageFormat, System.Drawing");
                MethodInfo m_save   = t_img.GetMethod("Save", new Type[] { typeof(MemoryStream), t_format });

                EditorUtility.DisplayProgressBar("Creating Texture Array for " + path, "", 0);
                object IMG    = m_from_file.Invoke(null, new object[] { path });
                int    Length = (int)m_get_frame_count.Invoke(IMG, new object[] { p_frame_time.GetValue(null, null) });

                m_select_active_frame.Invoke(IMG, new object[] { p_frame_time.GetValue(null, null), 0 });
                array = new Texture2DArray((int)p_width.GetValue(IMG, null), (int)p_height.GetValue(IMG, null), Length, TextureFormat.RGBA32, true, false);

                for (int i = 0; i < Length; i++)
                {
                    EditorUtility.DisplayProgressBar("Creating Texture Array for " + path, "Converting frame #" + i, (float)i / Length);
                    m_select_active_frame.Invoke(IMG, new object[] { p_frame_time.GetValue(null, null), i });
                    object       bitmap   = c_bitmap.Invoke(new object[] { IMG });
                    MemoryStream msFinger = new MemoryStream();
                    m_save.Invoke(IMG, new object[] { msFinger, p_bitmap_raw_format.GetValue(bitmap, null) });
                    Texture2D texture = new Texture2D((int)p_width.GetValue(IMG, null), (int)p_height.GetValue(IMG, null));
                    texture.LoadImage(msFinger.ToArray());
                    array.SetPixels(texture.GetPixels(), i);
                }
                m_dispose.Invoke(IMG, null);
                EditorUtility.ClearProgressBar();

                array.Apply();
                string newPath = path.Replace(".gif", ".asset");
                AssetDatabase.CreateAsset(array, newPath);
            }
            else
            {
                UnityFixer.CheckAPICompatibility();
                UnityFixer.CheckDrawingDll();
                Debug.LogWarning("System.Drawing could not be found. Trying to automatically fix by adding csc/mcs.");
            }
            return(array);
        }
Beispiel #2
0
 private static void AssetsDeleted(string[] assets)
 {
     ShaderHelper.AssetsDeleted(assets);
     UnityFixer.OnAssetDeleteCheckDrawingDLL(assets);
     if (CheckForEditorRemove(assets))
     {
         Debug.Log("ShaderEditor is being deleted.");
         Config.Singleton.verion = "0";
         Config.Singleton.Save();
         ModuleHandler.OnEditorRemove();
     }
 }
Beispiel #3
0
        static OnCompileHandler()
        {
            //Init Editor Variables with paths
            ShaderEditor.GetShaderEditorDirectoryPath();

            Config.OnCompile();
            ModuleHandler.OnCompile();
            TrashHandler.EmptyThryTrash();

            UnityFixer.CheckAPICompatibility(); //check that Net_2.0 is ApiLevel
            UnityFixer.CheckDrawingDll();       //check that drawing.dll is imported
        }
Beispiel #4
0
 private static void AssetsDeleted(string[] assets)
 {
     VRCInterface.SetVRCDefineSybolIfSDKDeleted(assets);
     ShaderHelper.AssetsDeleted(assets);
     UnityFixer.OnAssetDeleteCheckDrawingDLL(assets);
     if (CheckForEditorRemove(assets))
     {
         Debug.Log("ThryEditor is being deleted.");
         Config.Get().verion = "0";
         Config.Get().save();
         ModuleHandler.OnEditorRemove();
     }
 }
Beispiel #5
0
 public static void CheckDrawingDll()
 {
     if (Type.GetType("System.Drawing.Image, System.Drawing") == null)
     {
         string    filename = GetRSPFilename();
         RSP_State state    = CheckRSPState(filename);
         switch (state)
         {
         case RSP_State.missing:
         case RSP_State.missing_drawing_dll:
             AddDrawingDLLToRSP(PATH.RSP_NEEDED_PATH + filename + ".rsp");
             break;
         }
         UnityFixer.CheckAPICompatibility();
     }
     UnityHelper.SetDefineSymbol(DEFINE_SYMBOLS.IMAGING_EXISTS, true, true);
 }