Пример #1
0
        private static void UnpackShaders(string filter)
        {
            const string packedShadersGuid = "552f9a41dd13c0c44a9bb1aad0ec3598";
            var          path = AssetDatabase.GUIDToAssetPath(packedShadersGuid);

            if (string.IsNullOrEmpty(path))
            {
                EditorApplication.Beep();
                Debug.LogError("[TCP2 Unpack Shaders] Couldn't find file: \"TCP2 Packed Shaders.tcp2data\"\nPlease reimport Toony Colors Pro.");
                return;
            }

            var fullPath = Application.dataPath + path.Substring("Assets".Length);

            if (File.Exists(fullPath))
            {
                var files = Utils.ExtractArchive(fullPath, filter);

                var @continue = 0;
                if (files.Length > 8)
                {
                    do
                    {
                        @continue = EditorUtility.DisplayDialogComplex("TCP2 : Unpack Shaders", "You are about to import " + files.Length + " shaders in Unity.\nIt could take a few minutes!\nContinue?", "Yes", "No", "Help");
                        if (@continue == 2)
                        {
                            TCP2_GUI.OpenHelpFor("Unpack Shaders");
                        }
                    }while (@continue == 2);
                }

                if (@continue == 0 && files.Length > 0)
                {
                    var tcpRoot = Utils.FindReadmePath();
                    foreach (var f in files)
                    {
                        var filePath = tcpRoot + f.path;
                        var fileDir  = Path.GetDirectoryName(filePath);
                        if (!Directory.Exists(fileDir))
                        {
                            Directory.CreateDirectory(fileDir);
                        }
                        File.WriteAllText(filePath, f.content);
                    }

                    Debug.Log("Toony Colors Pro - Unpack Shaders:\n" + files.Length + (files.Length > 1 ? " shaders extracted." : " shader extracted."));
                    AssetDatabase.Refresh();
                }

                if (files.Length == 0)
                {
                    Debug.Log("Toony Colors Pro - Unpack Shaders:\nNothing to unpack. Shaders are probably already unpacked!");
                }
            }
        }
Пример #2
0
    private static void UnpackShaders(string filter)
    {
        var archFiles = Directory.GetFiles(TCP2_Utils.UnityToSystemPath(Application.dataPath), "TCP2 Packed Shaders.tcp2data", SearchOption.AllDirectories);

        if (archFiles == null || archFiles.Length == 0)
        {
            EditorApplication.Beep();
            Debug.LogError("[TCP2 Unpack Shaders] Couldn't find file: \"TCP2 Packed Shaders.tcp2data\"\nPlease reimport Toony Colors Pro 2.");
            return;
        }
        var archivePath = archFiles[0];

        if (archivePath.EndsWith(".tcp2data"))
        {
            var files = TCP2_Utils.ExtractArchive(archivePath, filter);

            var @continue = 0;
            if (files.Length > 8)
            {
                do
                {
                    @continue = EditorUtility.DisplayDialogComplex("TCP2 : Unpack Shaders", "You are about to import " + files.Length + " shaders in Unity.\nIt could take a few minutes!\nContinue?", "Yes", "No", "Help");
                    if (@continue == 2)
                    {
                        TCP2_GUI.OpenHelpFor("Unpack Shaders");
                    }
                }while(@continue == 2);
            }

            if (@continue == 0 && files.Length > 0)
            {
                var tcpRoot = TCP2_Utils.FindReadmePath();
                foreach (var f in files)
                {
                    var filePath = tcpRoot + f.path;
                    var fileDir  = Path.GetDirectoryName(filePath);
                    if (!Directory.Exists(fileDir))
                    {
                        Directory.CreateDirectory(fileDir);
                    }
                    File.WriteAllText(filePath, f.content);
                }

                Debug.Log("Toony Colors Pro 2 - Unpack Shaders:\n" + files.Length + (files.Length > 1 ? " shaders extracted." : " shader extracted."));
                AssetDatabase.Refresh();
            }

            if (files.Length == 0)
            {
                Debug.Log("Toony Colors Pro 2 - Unpack Shaders:\nNothing to unpack. Shaders are probably already unpacked!");
            }
        }
    }