Beispiel #1
0
 public static void UpdateModule(ModuleHeader module)
 {
     module.is_being_installed_or_removed = true;
     Helper.SaveValueToFile("update_module_url", module.url, PATH.AFTER_COMPILE_DATA);
     Helper.SaveValueToFile("update_module_name", module.available_module.name, PATH.AFTER_COMPILE_DATA);
     RemoveModule(module);
 }
Beispiel #2
0
 public static void VRCSDKUpdateCallback(string data)
 {
     Helper.SaveValueToFile("update_vrc_sdk", "false", PATH.AFTER_COMPILE_DATA);
     AssetDatabase.ImportPackage(PATH.TEMP_VRC_SDK_PACKAGE, false);
     File.Delete(PATH.TEMP_VRC_SDK_PACKAGE);
     Update();
 }
 public static void UpdateModule(ModuleHeader module)
 {
     module.is_being_installed_or_removed = true;
     Helper.SaveValueToFile("update_module_url", module.url, ".thry_after_compile_data");
     Helper.SaveValueToFile("update_module_name", module.available_module.name, ".thry_after_compile_data");
     RemoveModule(module);
 }
Beispiel #4
0
 public static void VRCSDKUpdateCallback(string data)
 {
     Helper.SaveValueToFile("update_vrc_sdk", "false", ".thry_after_compile_data");
     AssetDatabase.ImportPackage(TEMP_VRC_SDK_PACKAGE_PATH, false);
     File.Delete(TEMP_VRC_SDK_PACKAGE_PATH);
     Update();
 }
            static Startup()
            {
                string url  = Helper.LoadValueFromFile("update_module_url", ".thry_after_compile_data");
                string name = Helper.LoadValueFromFile("update_module_name", ".thry_after_compile_data");

                if (url != null && url.Length > 0 && name != null && name.Length > 0)
                {
                    InstallModule(url, name);
                    Helper.SaveValueToFile("update_module_url", "", ".thry_after_compile_data");
                    Helper.SaveValueToFile("update_module_url", "", ".thry_after_compile_data");
                }
            }
Beispiel #6
0
        public static void OnCompile()
        {
            string url  = Helper.LoadValueFromFile("update_module_url", PATH.AFTER_COMPILE_DATA);
            string name = Helper.LoadValueFromFile("update_module_name", PATH.AFTER_COMPILE_DATA);

            if (url != null && url.Length > 0 && name != null && name.Length > 0)
            {
                InstallModule(url, name);
                Helper.SaveValueToFile("update_module_url", "", PATH.AFTER_COMPILE_DATA);
                Helper.SaveValueToFile("update_module_url", "", PATH.AFTER_COMPILE_DATA);
            }
        }
        private void TextureSettingsGUI()
        {
            EditorGUIUtility.labelWidth = 100;
            EditorGUIUtility.fieldWidth = 150;
            EditorGUILayout.LabelField("Texture options:", EditorStyles.boldLabel);
            bool changed = GuiHelper.GUIDataStruct <TextureData>(textureSettings, new string[] { "name" });

            if (changed)
            {
                Helper.SaveValueToFile("gradient_texture_options_" + prop.name, Parser.ObjectToString(textureSettings), ".thry_persistent_data");
                UpdateGradientPreviewTexture();
            }
        }
 public void OnDestroy()
 {
     if (gradient_has_been_edited)
     {
         if (data.preview_texture.GetType() == typeof(Texture2D))
         {
             string  file_name = GradientFileName(data.gradient, prop.targets[0].name);;
             Texture saved     = Helper.SaveTextureAsPNG((Texture2D)data.preview_texture, "Assets/Textures/Gradients/" + file_name, textureSettings);
             file_name = Regex.Replace(file_name, @"\.((png)|(jpg))$", "");
             Helper.SaveValueToFile(file_name, Parser.ObjectToString(data.gradient), ".thry_gradients");
             prop.textureValue = saved;
         }
     }
     else
     {
         UpdatePreviewTexture(privious_preview_texture);
     }
 }
Beispiel #9
0
 private static void DeleteVRCSDKFolder()
 {
     if (!Get().sdk_is_installed)
     {
         Helper.SaveValueToFile("delete_vrc_sdk", "false", PATH.AFTER_COMPILE_DATA);
         if (Helper.LoadValueFromFile("update_vrc_sdk", PATH.AFTER_COMPILE_DATA) == "true")
         {
             DownloadAndInstallVRCSDK();
         }
         else
         {
             Settings.is_changing_vrc_sdk = false;
         }
     }
     if (Get().sdk_path != null && Directory.Exists(Get().sdk_path))
     {
         Directory.Delete(Get().sdk_path, true);
         AssetDatabase.Refresh();
     }
     Update();
 }
Beispiel #10
0
 public void UpdateVRCSDK()
 {
     Helper.SaveValueToFile("update_vrc_sdk", "true", PATH.AFTER_COMPILE_DATA);
     this.RemoveVRCSDK();
 }
Beispiel #11
0
 public void RemoveVRCSDK(bool refresh)
 {
     Helper.SaveValueToFile("delete_vrc_sdk", "true", PATH.AFTER_COMPILE_DATA);
     Helper.SetDefineSymbol(DEFINE_SYMBOLS.VRC_SDK_INSTALLED, false);
     AssetDatabase.Refresh();
 }
Beispiel #12
0
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            string text             = "";
            int    selectedAlphabet = 0;

            if (ThryEditor.currentlyDrawing.currentProperty.property_data == null)
            {
                ThryEditor.currentlyDrawing.currentProperty.property_data = new TextData {
                    text = Helper.LoadValueFromFile(editor.target.name + ":" + prop.name, PATH.TEXT_INFO_FILE), selectedAlphabet = 0
                }
            }
            ;
            text             = ((TextData)ThryEditor.currentlyDrawing.currentProperty.property_data).text;
            selectedAlphabet = ((TextData)ThryEditor.currentlyDrawing.currentProperty.property_data).selectedAlphabet;

            string[]      guids        = AssetDatabase.FindAssets("alphabet t:texture");
            List <string> alphabetList = new List <string>();

            for (int i = 0; i < guids.Length; i++)
            {
                string p        = AssetDatabase.GUIDToAssetPath(guids[i]);
                int    index    = p.LastIndexOf("/") + 1;
                int    indexEnd = p.LastIndexOf(".");
                string name     = p.Substring(index, indexEnd - index);
                if (!name.StartsWith("alphabet_"))
                {
                    continue;
                }
                alphabetList.Add(name);
            }
            string[] alphabets = alphabetList.ToArray();

            Rect textPosition = position;

            textPosition.width *= 3f / 4;
            EditorGUI.BeginChangeCheck();
            text = EditorGUI.DelayedTextField(textPosition, new GUIContent("       " + label.text, label.tooltip), text);

            Rect popUpPosition = position;

            popUpPosition.width /= 4f;
            popUpPosition.x     += popUpPosition.width * 3;
            selectedAlphabet     = EditorGUI.Popup(popUpPosition, selectedAlphabet, alphabets);

            if (EditorGUI.EndChangeCheck())
            {
                foreach (Material m in ThryEditor.currentlyDrawing.materials)
                {
                    Helper.SaveValueToFile(m.name + ":" + prop.name, text, PATH.TEXT_INFO_FILE);
                }
                ThryEditor.currentlyDrawing.currentProperty.property_data = new TextData {
                    text = text, selectedAlphabet = selectedAlphabet
                };
                prop.textureValue = Converter.TextToTexture(text, alphabets[selectedAlphabet]);
                Debug.Log("text '" + text + "' saved as texture.");
            }

            EditorGUI.BeginChangeCheck();
            editor.TexturePropertyMiniThumbnail(position, prop, "", "");
            if (EditorGUI.EndChangeCheck())
            {
                if (prop.textureValue.name.StartsWith("text_"))
                {
                    text = prop.textureValue.name.Replace("text_", "").Replace("_", " ");
                }
                else
                {
                    text = "<texture>";
                }
                ThryEditor.currentlyDrawing.currentProperty.property_data = text;
                foreach (Material m in ThryEditor.currentlyDrawing.materials)
                {
                    Helper.SaveValueToFile(m.name + ":" + prop.name, "<texture>", PATH.TEXT_INFO_FILE);
                }
            }
        }
Beispiel #13
0
 public void UpdateVRCSDK()
 {
     Helper.SaveValueToFile("update_vrc_sdk", "true", ".thry_after_compile_data");
     this.RemoveVRCSDK();
 }
Beispiel #14
0
 public void RemoveVRCSDK(bool refresh)
 {
     Helper.SaveValueToFile("delete_vrc_sdk", "true", ".thry_after_compile_data");
     Helper.SetDefineSymbol(Settings.DEFINE_SYMBOLE_VRC_SDK_INSTALLED, false);
     AssetDatabase.Refresh();
 }
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            GradientData data;

            if (ThryEditor.currentlyDrawing.property_data != null)
            {
                data = (GradientData)ThryEditor.currentlyDrawing.property_data;
            }
            else
            {
                data = new GradientData(); data.saved = true; ThryEditor.currentlyDrawing.property_data = data;
            }

            if (data.gradientObj == null)
            {
                data.gradientObj = GradientObject.CreateInstance <GradientObject>();
                if (prop.textureValue != null)
                {
                    data.texture = (Texture2D)prop.textureValue;
                    TextureUpdated(ref data);
                }
                else
                {
                    data.texture            = new Texture2D(256, 1);
                    data.serializedGradient = new SerializedObject(data.gradientObj);
                    data.colorGradient      = data.serializedGradient.FindProperty("gradient");
                }
                data.saved = true;
            }
            EditorGUI.BeginChangeCheck();
            editor.TexturePropertyMiniThumbnail(position, prop, "", "");
            if (EditorGUI.EndChangeCheck())
            {
                data.texture = (Texture2D)prop.textureValue;
                TextureUpdated(ref data);
            }
            EditorGUI.BeginChangeCheck();
            EditorGUI.PropertyField(position, data.colorGradient, new GUIContent("       " + label.text, label.tooltip));
            string windowName = "";

            if (EditorWindow.focusedWindow != null)
            {
                windowName = EditorWindow.focusedWindow.titleContent.text;
            }
            bool isGradientEditor = windowName == "Gradient Editor";

            if (isGradientEditor)
            {
                data.gradientWindow = EditorWindow.focusedWindow;
            }
            bool changed = EditorGUI.EndChangeCheck();

            if (changed)
            {
                if (data.texture == prop.textureValue)
                {
                    data.texture = new Texture2D(256, 1);
                }
                data.serializedGradient.ApplyModifiedProperties();
                GradientToTexture(ref data);
                prop.textureValue = data.texture;
                data.saved        = false;
            }

            if (data.gradientWindow == null && !data.saved)
            {
                byte[] encoding = data.texture.EncodeToPNG();

                string gradient_data = GradientToString(ref data);
                string gradient_name = Config.Get().gradient_name;
                gradient_name = gradient_name.Replace("<material>", editor.target.name);
                gradient_name = gradient_name.Replace("<hash>", "" + gradient_data.GetHashCode());
                gradient_name = gradient_name.Replace("<prop>", prop.name);

                string path = "Assets/Textures/Gradients/" + gradient_name;
                Debug.Log("Gradient saved at \"" + path + "\".");
                Helper.writeBytesToFile(encoding, path);

                Helper.SaveValueToFile(gradient_name, gradient_data, GRADIENT_INFO_FILE_PATH);

                AssetDatabase.ImportAsset(path);
                Texture tex = (Texture)EditorGUIUtility.Load(path);
                tex.wrapMode = TextureWrapMode.Clamp;
                SetTextureImporterFormat((Texture2D)tex, true);
                prop.textureValue = tex;
                data.saved        = true;
            }
        }