Exemplo n.º 1
0
        public static void ManageInventory()
        {
            InventoryInventorWindow window = (InventoryInventorWindow)GetWindow(typeof(InventoryInventorWindow), false, "Inventory Inventor");

            window.manager.outputPath = InventorSettings.GetSerializedSettings().FindProperty("m_LastPath").stringValue;
            window.minSize            = new Vector2(375f, 355f);
            window.wantsMouseMove     = true;
            window.Show();
        }
Exemplo n.º 2
0
 static void OnInit()
 {
     if (!EditorApplication.isUpdating && !EditorApplication.isCompiling)
     {
         SerializedObject settings = InventorSettings.GetSerializedSettings();
         if (settings != null)
         {
             EditorApplication.update -= OnInit;
             m_Instance = FindObjectOfType <AutoUpdater>();
             if (m_Instance == null && !EditorApplication.isPlayingOrWillChangePlaymode)
             {
                 m_Instance = CreateInstance <AutoUpdater>();
                 if (settings.FindProperty("m_AutoUpdate").boolValue)
                 {
                     Updater.CheckForUpdates(true);
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        private static void OnScriptsReloaded()
        {
            if (InventorSettings.GetSerializedSettings().FindProperty("m_Updating").boolValue)
            {
                // Get Main Path
                string mainPath = GetSettingsPath().Substring(0, GetSettingsPath().LastIndexOf("Editor") - 1);

                // Upgrade Presets
                InventoryPresetUtility.UpgradeAll(false);

                // Display Changes
                if (File.Exists(mainPath + "/CHANGES.md"))
                {
                    EditorApplication.update += OnUpdatedUpdate;
                }

                // Disable Updating Flag
                var settings = InventorSettings.GetSerializedSettings();
                settings.FindProperty("m_Updating").boolValue = false;
                settings.ApplyModifiedProperties();
            }
        }
Exemplo n.º 4
0
        // Draws the creation window GUI.
        private void DrawCreateWindow()
        {
            EditorGUILayout.BeginVertical();

            // Check for avatars in the scene.
            EditorGUILayout.BeginVertical(GUILayout.Height(54f));
            GUILayout.FlexibleSpace();
            SelectAvatarDescriptor();
            if (manager.avatar == null)
            {
                EditorGUILayout.HelpBox("No Avatars found in the current Scene!", MessageType.Warning);
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
            DrawLine();

            // List optional settings.
            EditorGUILayout.LabelField("Optional Settings", EditorStyles.boldLabel);
            EditorGUILayout.BeginVertical(new GUIStyle(GUI.skin.GetStyle("Box")));
            // Expressions Menu
            manager.menu = (VRCExpressionsMenu)EditorGUILayout.ObjectField(new GUIContent("Expressions Menu", "The Expressions Menu you want the inventory controls added to. Leave this empty if you don't want any menus to be affected.\n(Controls will be added as a submenu.)"), manager.menu, typeof(VRCExpressionsMenu), true);
            EditorGUI.BeginChangeCheck();
            // Animator Controller
            manager.controller = (AnimatorController)EditorGUILayout.ObjectField(new GUIContent("Animator Controller", "The Animator Controller to modify.\n(If left empty, a new Animator Controller will be created and used.)"), manager.controller, typeof(AnimatorController), false);
            if (EditorGUI.EndChangeCheck())
            {
                manager.PreviewRemoval(out layers, out parameters, out expression);
            }
            EditorGUILayout.EndVertical();
            GUILayout.Space(3);
            DrawLine();

            // List Inventory Settings.
            EditorGUILayout.LabelField("Inventory Settings", EditorStyles.boldLabel);
            EditorGUILayout.BeginVertical(new GUIStyle(GUI.skin.GetStyle("Box")));
            // Preset
            EditorGUI.BeginChangeCheck();
            manager.preset = (InventoryPreset)EditorGUILayout.ObjectField(new GUIContent("Preset", "The preset to apply to the Animator."), manager.preset, typeof(InventoryPreset), false);
            if (EditorGUI.EndChangeCheck() && manager.preset != null && manager.preset.LastPath != null && manager.preset.LastPath != "")
            {
                manager.outputPath = manager.preset.LastPath;
            }
            // Refresh Rate
            manager.refreshRate = Mathf.Clamp(EditorGUILayout.FloatField(new GUIContent("Refresh Rate", "How long each synced (or unsaved) toggle is given to synchronize with late joiners (seconds per item)."), manager.refreshRate), 0f, float.MaxValue);
            EditorGUILayout.EndVertical();
            GUILayout.Space(3);
            DrawLine();

            // List Output Settings.
            EditorGUILayout.LabelField("Output Settings", EditorStyles.boldLabel);
            EditorGUILayout.BeginVertical(new GUIStyle(GUI.skin.GetStyle("Box")), GUILayout.Height(50f));
            GUILayout.FlexibleSpace();

            // The File Destination
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(new GUIContent("Destination", "The folder where generated files will be saved to."));
            // Format file path to fit in a button.
            string displayPath = (manager.outputPath != null) ? manager.outputPath.Replace('\\', '/') : "";

            while (new GUIStyle(GUI.skin.GetStyle("Box"))
            {
                richText = true
            }.CalcSize(new GUIContent("<i>" + displayPath + "</i>")).x > windowSize.width - EditorGUIUtility.labelWidth - 48f)
            {
                displayPath = "..." + displayPath.Substring(4);
            }
            if (displayPath.IndexOf("...") == 0 && displayPath.IndexOf('/') != -1)
            {
                displayPath = "..." + displayPath.Substring(displayPath.IndexOf('/'));
            }
            // Destination.
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("<i>" + displayPath + "</i>", (manager.outputPath != null) ? manager.outputPath.Replace('\\', '/') : ""), new GUIStyle(GUI.skin.GetStyle("Button"))
            {
                richText = true, active = GUI.skin.GetStyle("Button").active
            }, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }))
            {
                string absPath = EditorUtility.OpenFolderPanel("Destination Folder", "", "");
                if (absPath.StartsWith(Application.dataPath))
                {
                    manager.outputPath = "Assets" + absPath.Substring(Application.dataPath.Length);
                    SerializedObject settings = InventorSettings.GetSerializedSettings();
                    settings.FindProperty("m_LastPath").stringValue = manager.outputPath;
                    settings.ApplyModifiedProperties();
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginHorizontal();
            // Overwrite All.
            EditorGUILayout.PrefixLabel(new GUIContent("Overwrite All", "Automatically overwrite existing files if needed."));
            manager.autoOverwrite = !Convert.ToBoolean(GUILayout.Toolbar(Convert.ToInt32(!manager.autoOverwrite), new string[] { "Yes", "No" }));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            DrawLine();

            // Create Button.
            if (GUILayout.Button("Create"))
            {
                manager.CreateInventory();
                EditorUtility.ClearProgressBar();
                manager.PreviewRemoval(out layers, out parameters, out expression);
            }
            EditorGUILayout.EndVertical();

            // Repaint when hovering over window (needed for Destination button).
            if (mouseOverWindow != null && mouseOverWindow == this)
            {
                Repaint();
                focused = true;
            }
            else if (focused && mouseOverWindow == null)
            {
                Repaint();
                focused = false;
            }
        }
Exemplo n.º 5
0
        // Downloads and installs a given version of the package.
        public static void DownloadUpdate(string version)
        {
            string downloadURL = "https://github.com/Joshuarox100/VRC-Inventory-Inventor/releases/download/" + version + "/Inventory.Inventor." + version.Substring(1) + ".unitypackage";
            string filePath    = $"{Application.persistentDataPath}/Files/Inventory.Inventor." + version.Substring(1) + ".unitypackage";
            //Debug.Log("Download URL: " + downloadURL + "\nFile Path: " + filePath);

            // Create hidden object to run the coroutine.
            GameObject temp = new GameObject {
                hideFlags = HideFlags.HideInHierarchy
            };

            // Run a coroutine to retrieve the GitHub data.
            NetworkManager manager = temp.AddComponent <NetworkManager>();

            manager.StartCoroutine(NetworkManager.GetFileRequest(downloadURL, filePath, (UnityWebRequest req) =>
            {
                // Log potential errors
                if (req.isNetworkError || req.isHttpError)
                {
                    // Log any errors that may happen
                    EditorUtility.DisplayDialog("Inventory Inventor", "Failed to download the latest version.\n(Check console for details.)", "Close");
                    Debug.LogError("Inventory Inventor: " + req.error);
                }
                else
                {
                    if (File.Exists(filePath))
                    {
                        // Store the current settings
                        string path        = GetSettingsPath();
                        string mainPath    = path.Substring(0, path.LastIndexOf("Editor") - 1);
                        bool foundSettings = false;
                        if (File.Exists(path))
                        {
                            AssetDatabase.MoveAsset(path, mainPath + "/SETTINGS.asset");
                            foundSettings = true;
                        }

                        // Delete the previous version
                        DeleteCurrentVersion(mainPath);

                        // Import and delete the downloaded package
                        AssetDatabase.ImportPackage(filePath, false);
                        File.Delete(filePath);

                        // Restore the previous settings
                        if (foundSettings)
                        {
                            if (!Directory.Exists(mainPath + "/Editor"))
                            {
                                Directory.CreateDirectory(mainPath + "/Editor");
                            }
                            AssetDatabase.MoveAsset(mainPath + "/SETTINGS.asset", path);

                            // Enable Updating Flag
                            var settings = InventorSettings.GetSerializedSettings();
                            settings.FindProperty("m_Updating").boolValue = true;
                            settings.ApplyModifiedProperties();
                        }

                        // Refresh the Database
                        AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("Inventory Inventor", "Failed to install the latest version.\n(File could not be found.)", "Close");
                    }
                }
                DestroyImmediate(temp);
            }));
        }