Ejemplo n.º 1
0
        /// <summary>
        /// Connect copied objects to prefabs if original object is connected, and sets helper reference back to new prefab reference
        /// Also recursively calls itself in all children
        /// </summary>
        /// <param name="toMine">Whether we are copying theirs to mine (true) or mie to theirs (false)</param>
        void ConnectPrefabsAfterCopy(bool toMine)
        {
            var original = toMine ? theirs : mine;
            var copy     = toMine ? mine : theirs;

            if (Util.IsPrefabParent(original) && PrefabUtility.GetPrefabType(original) == PrefabType.PrefabInstance)
            {
                copy      = PrefabUtility.ConnectGameObjectToPrefab(copy, (GameObject)PrefabUtility.GetPrefabParent(original));
                copy.name = original.name;                 // ConnectPrefab will rename to prefab name

                // ConnectPrefab will override transform
                var copyTransform     = copy.transform;
                var originalTransform = original.transform;
                copyTransform.localPosition = originalTransform.localPosition;
                copyTransform.localRotation = originalTransform.localRotation;
                copyTransform.localScale    = originalTransform.localScale;
            }

            if (toMine)
            {
                mine = copy;
            }
            else
            {
                theirs = copy;
            }

            if (children != null)
            {
                foreach (var child in children)
                {
                    child.ConnectPrefabsAfterCopy(toMine);
                }
            }
        }
        private static void BuildAssets()
        {
            EditorUtility.ClearConsole();

            if (UnityEditorUtility.scriptCompilationFailed)
            {
                return;
            }

            try
            {
                var result = MetadataAssetUtility.GenerateMetadataEntityScripts();
                EditorPrefs.SetBool(ScriptsGeneratedPrefKey, result);

                if (result)
                {
                    UnityEditorUtility.DisplayProgressBar("Hold on...", "Compiling metadata entity scripts...", 0f);
                }
                else
                {
                    if (UnityEditorUtility.DisplayDialog("Error", "Failed to generate metadata entity scripts!", "OK"))
                    {
                        UnityEditorUtility.ClearProgressBar();
                    }
                }
            }
            catch (System.Exception e)
            {
                Debug.LogException(e);
            }
        }
Ejemplo n.º 3
0
        void Install(BoltPackage package)
        {
            string       packageName = package.name;
            PackageFlags flags       = package.packageFlags;

            if ((flags & PackageFlags.WarnForProjectOverwrite) == PackageFlags.WarnForProjectOverwrite)
            {
                if (ProjectExists())
                {
                    if (EditorUtility.DisplayDialog("Warning",
                                                    "Importing this package will overwrite the existing bolt project file that contains all your states, events, etc. Are you sure?",
                                                    "Yes", "No") == false)
                    {
                        return;
                    }
                }
            }

            if ((flags & PackageFlags.RunInitialSetup) == PackageFlags.RunInitialSetup)
            {
                InitialSetup();
            }

            AssetDatabase.ImportPackage(PackagePath(packageName), false);

            currentStage = BoltSetupStage.Bolt;
        }
Ejemplo n.º 4
0
        public override void DuplicateItem(int index)
        {
            var source = crudList[index];

            var item = UnityEngine.Object.Instantiate <InventoryItemBase>(source);

            item.ID    = (crudList.Count > 0) ? crudList.Max(o => o.ID) + 1 : 0;
            item.name += "(duplicate)";

            string prefabPath = InventoryScriptableObjectUtility.GetSaveFolderForFolderName("Items") + "/item_" + System.DateTime.Now.ToFileTimeUtc() + "_PFB.prefab";

            var prefab = PrefabUtility.CreatePrefab(prefabPath, item.gameObject);

            prefab.layer = InventorySettingsManager.instance.settings.itemWorldLayer;

            AssetDatabase.SetLabels(prefab, new string[] { "InventoryProPrefab" });

            AddItem(prefab.gameObject.GetComponent <InventoryItemBase>());

            EditorUtility.SetDirty(prefab);                              // To save it.

            UnityEngine.Object.DestroyImmediate(item.gameObject, false); // Destroy the instance created

            window.Repaint();
        }
Ejemplo n.º 5
0
        private void DrawSupport()
        {
            DrawInputWithLabel("Bolt Support", () =>
            {
                GUILayout.BeginVertical();
                GUILayout.Space(5);
                GUILayout.Label(BoltWizardText.SUPPORT, textLabel);
                GUILayout.EndVertical();
            }, false);
            GUILayout.Space(15);

            DrawStepOption(discordIcon, discordHeader, discordText,
                           callback: OpenURL("https://discord.gg/0ya6ZpOvnShSCtbb"));
            DrawStepOption(bugtrackerIcon, bugtrackerHeader, bugtrackerText,
                           callback: OpenURL("https://github.com/BoltEngine/Bolt-Tracker"));
            DrawStepOption(documentationIcon, documentationHeader, documentationText,
                           callback: OpenURL("https://doc.photonengine.com/en-us/bolt/current/setup/overview"));
            DrawStepOption(reviewIcon, reviewHeader, reviewText,
                           callback: OpenURL("https://assetstore.unity.com/packages/tools/network/photon-bolt-free-127156"));

            // Action

            if (beforeNextCallback == null)
            {
                beforeNextCallback = () =>
                {
                    RunCompiler = EditorUtility.DisplayDialog(BoltWizardText.FINISH_TITLE, BoltWizardText.FINISH_QUESTION,
                                                              "Yes", "No");
                    return(true);
                };
            }
        }
Ejemplo n.º 6
0
        public override void AddItem(InventoryItemBase item, bool editOnceAdded = true)
        {
            base.AddItem(item, editOnceAdded);
            UpdateAssetName(item);

            EditorUtility.SetDirty(ItemManager.database); // To save it.
        }
Ejemplo n.º 7
0
        private static void AddWaypointToGroupOnClick(WaypointGroup group, int afterIndex, Vector3 worldPosition)
        {
            if (Event.current.alt)
            {
                // when using alt the user is likely panning around an object, ignore the add method.
                return;
            }

            Handles.Label(worldPosition, "Inserted waypoint at: " + worldPosition);
            Handles.color = Color.green;
            Handles.SphereCap(-1, worldPosition, Quaternion.identity, 0.5f);

            var afterIndexClamped = Mathf.Max(0, afterIndex - 1);

            if (afterIndexClamped > 0 && afterIndexClamped < group.waypoints.Length)
            {
                Handles.DrawAAPolyLine(LineWidth, group.waypoints[afterIndexClamped].transform.position, worldPosition);
            }

            Handles.color = Color.white;

            // Connect from the last to a new waypoint
            if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                Undo.RecordObject(group, "Added waypoint");
                group.InsertWaypointAfter(group.transform.worldToLocalMatrix * (worldPosition - group.transform.localPosition), afterIndex);

                _selectedWaypointGroup = group;
                _selectedWaypointIndex = afterIndex;

                EditorUtility.SetDirty(group);
            }
        }
Ejemplo n.º 8
0
        public override void RemoveItem(int i)
        {
            AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(ItemManager.database.items[i]));
            base.RemoveItem(i);

            EditorUtility.SetDirty(ItemManager.database); // To save it.
        }
Ejemplo n.º 9
0
        public override void RemoveItem(int i)
        {
//            var l = new List<InventoryItemBase>(ItemManager.database.items);
            var allUsingCategory = ItemManager.database.items.Where(o => o.category == crudList[i]).ToArray();

            if (allUsingCategory.Length == 0)
            {
                base.RemoveItem(i);
            }
            else
            {
                var window = ReplaceWithDialog.Get((index, editorWindow) =>
                {
                    if (index == -1)
                    {
                        Debug.Log("Not replacing - Deleting category");
                    }
                    else
                    {
                        Debug.Log("Replace category with " + ItemManager.database.categories[index].name);
                        foreach (var item in allUsingCategory)
                        {
                            item.category = ItemManager.database.categories[index];
                            EditorUtility.SetDirty(item);
                        }
                    }

                    base.RemoveItem(i);
                    editorWindow.Close();
                }, "Category", allUsingCategory.Length, ItemManager.database.itemCategoriesStrings);
                window.Show();
            }
        }
Ejemplo n.º 10
0
            /// <summary>
            /// Display Dialog to add a scene to build settings
            /// </summary>
            static public void AddBuildScene(BuildScene buildScene, bool force = false, bool enabled = true)
            {
                if (force == false)
                {
                    int selection = EditorUtility.DisplayDialogComplex(
                        "Add Scene To Build",
                        "You are about to add scene at " + buildScene.assetPath + " To the Build Settings.",
                        "Add as Enabled",                 // option 0
                        "Add as Disabled",                // option 1
                        "Cancel (do nothing)");           // option 2

                    switch (selection)
                    {
                    case 0:                     // enabled
                        enabled = true;
                        break;

                    case 1:                     // disabled
                        enabled = false;
                        break;

                    default:
                    case 2:                     // cancel
                        return;
                    }
                }

                EditorBuildSettingsScene        newScene   = new EditorBuildSettingsScene(buildScene.assetGUID, enabled);
                List <EditorBuildSettingsScene> tempScenes = EditorBuildSettings.scenes.ToList();

                tempScenes.Add(newScene);
                EditorBuildSettings.scenes = tempScenes.ToArray();
            }
Ejemplo n.º 11
0
        private void DrawSupport()
        {
            this.DrawInputWithLabel("Support", () =>
            {
                GUILayout.BeginVertical();
                GUILayout.Space(5);
                GUILayout.Label(WizardText.SUPPORT, this.textLabelStyle);
                GUILayout.EndVertical();
            }, false);

            GUILayout.Space(15);

            this.DrawStepOption(this.discordIcon, WizardText.DISCORD_HEADER, WizardText.DISCORD_TEXT, callback: this.OpenURL(EditorIntegration.UrlDiscordGeneral));
            this.DrawStepOption(this.documentationIcon, WizardText.DOCUMENTATION_HEADER, WizardText.DOCUMENTATION_TEXT, callback: this.OpenURL(EditorIntegration.UrlRealtimeDocsOnline));

            // Action

            if (this.beforeNextCallback == null)
            {
                this.beforeNextCallback = () =>
                {
                    return(EditorUtility.DisplayDialog(WizardText.FINISH_TITLE, WizardText.FINISH_QUESTION, "Yes", "No"));
                };
            }
        }
        internal static bool GenerateMetadataEntityScripts()
        {
            var result   = false;
            var settings = MetadataAssetSettings.Load();

            MetadataAssetSettings.CreateEntityScriptsStoreFolder(settings);

            if (string.IsNullOrEmpty(settings.ExcelWorkbookFilesFolderPath))
            {
                if (UnityEditorUtility.DisplayDialog("Error", "'Excel Workbook Files Folder Path' is not valid path!", "OK"))
                {
                    UnityEditorUtility.ClearProgressBar();
                }
            }
            else
            {
                ForEachExcelFile(settings.ExcelWorkbookFilesFolderPath, (table, fileName, index, length) =>
                {
                    if (table == null)
                    {
                        return;
                    }

                    var info     = $"Generating Metadata Entity Script: {fileName}.cs... {index + 1}/{length}";
                    var progress = (float)(index + 1) / length;
                    UnityEditorUtility.DisplayProgressBar("Hold on...", info, progress);
                    var rawInfoList = CreateMetadataEntityRawInfoList(settings, table);
                    result          = GenerateMetadataEntityScript(settings, fileName, rawInfoList);
                });
            }

            UnityEditorUtility.ClearProgressBar();
            return(result);
        }
Ejemplo n.º 13
0
        private void ErrorCallback(string err)
        {
            UnityEngine.Debug.LogError(err);

            requestingAppId = false;
            this.setupState = SetupState.RegistrationError;
            EditorUtility.ClearProgressBar();
        }
Ejemplo n.º 14
0
        public override void RemoveItem(int i)
        {
            AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(ItemManager.database.items[i]));
            //UnityEngine.Object.DestroyImmediate(((InventoryItemBase)itemEditorInspectorList[i].target).gameObject);
            //itemEditorInspectorList.RemoveAt(i);
            base.RemoveItem(i);

            EditorUtility.SetDirty(ItemManager.database);             // To save it.
        }
Ejemplo n.º 15
0
        protected override void CreateNewItem()
        {
            var picker = CreateNewItemEditor.Get((System.Type type, GameObject obj, EditorWindow thisWindow) =>
            {
                InventoryScriptableObjectUtility.SetPrefabSaveFolderIfNotSet();
                string prefabPath = InventoryScriptableObjectUtility.GetSaveFolderForFolderName("Items") + "/item_" + System.DateTime.Now.ToFileTimeUtc() + "_PFB.prefab";

                //var obj = GameObject.CreatePrimitive(PrimitiveType.Cube);
                var instanceObj = UnityEngine.Object.Instantiate <GameObject>(obj); // For unity 5.3+ - Source needs to be instance object.
                var prefab      = PrefabUtility.CreatePrefab(prefabPath, instanceObj);
                UnityEngine.Object.DestroyImmediate(instanceObj);

                if (InventorySettingsManager.instance != null && InventorySettingsManager.instance.settings != null)
                {
                    prefab.layer = InventorySettingsManager.instance.settings.itemWorldLayer;
                }
                else
                {
                    Debug.LogWarning("Couldn't set item layer because there's no InventorySettingsManager in the scene");
                }

                AssetDatabase.SetLabels(prefab, new string[] { "InventoryProPrefab" });

                var comp = (InventoryItemBase)prefab.AddComponent(type);
                comp.ID  = (crudList.Count > 0) ? crudList.Max(o => o.ID) + 1 : 0;
                EditorUtility.SetDirty(comp); // To save it.

                prefab.GetOrAddComponent <ItemTrigger>();
                prefab.GetOrAddComponent <ItemTriggerInputHandler>();
                if (prefab.GetComponent <SpriteRenderer>() == null)
                {
                    // This is not a 2D object
                    if (prefab.GetComponent <Collider>() == null)
                    {
                        prefab.AddComponent <BoxCollider>();
                    }

                    var sphereCollider       = prefab.GetOrAddComponent <SphereCollider>();
                    sphereCollider.isTrigger = true;
                    sphereCollider.radius    = 1f;

                    prefab.GetOrAddComponent <Rigidbody>();
                }

                // Avoid deleting the actual prefab / model, only the cube / internal models without an asset path.
                if (string.IsNullOrEmpty(AssetDatabase.GetAssetPath(obj)))
                {
                    Object.DestroyImmediate(obj);
                }

                AddItem(comp, true);
                thisWindow.Close();
            });

            picker.Show();
        }
Ejemplo n.º 16
0
            /// <summary>
            /// Display Dialog to remove a scene from build settings (or just disable it)
            /// </summary>
            static public void RemoveBuildScene(BuildScene buildScene, bool force = false)
            {
                bool onlyDisable = false;

                if (force == false)
                {
                    int selection = -1;

                    string title   = "Remove Scene From Build";
                    string details = string.Format("You are about to remove the following scene from build settings:\n    {0}\n    buildIndex: {1}\n\n{2}",
                                                   buildScene.assetPath, buildScene.buildIndex,
                                                   "This will modify build settings, but the scene asset will remain untouched.");
                    string confirm = "Remove From Build";
                    string alt     = "Just Disable";
                    string cancel  = "Cancel (do nothing)";

                    if (buildScene.scene.enabled)
                    {
                        details  += "\n\nIf you want, you can also just disable it instead.";
                        selection = EditorUtility.DisplayDialogComplex(title, details, confirm, alt, cancel);
                    }
                    else
                    {
                        selection = EditorUtility.DisplayDialog(title, details, confirm, cancel) ? 0 : 2;
                    }

                    switch (selection)
                    {
                    case 0:                     // remove
                        break;

                    case 1:                     // disable
                        onlyDisable = true;
                        break;

                    default:
                    case 2:                     // cancel
                        return;
                    }
                }

                // User chose to not remove, only disable the scene
                if (onlyDisable)
                {
                    SetBuildSceneState(buildScene, false);
                }
                // User chose to fully remove the scene from build settings
                else
                {
                    List <EditorBuildSettingsScene> tempScenes = EditorBuildSettings.scenes.ToList();
                    tempScenes.RemoveAll(scene => scene.guid.Equals(buildScene.assetGUID));
                    EditorBuildSettings.scenes = tempScenes.ToArray();
                }
            }
Ejemplo n.º 17
0
        // Utils

        private void Save()
        {
            if (Watch.ElapsedMilliseconds > 5000)
            {
                Watch.Reset();
                Watch.Start();

                EditorUtility.SetDirty(AppSettingsScriptableObject);
                AssetDatabase.SaveAssets();
            }
        }
Ejemplo n.º 18
0
        /*private void RepairPrefabLinks()
         * {
         *      var crudListCopy = crudList;
         *
         *      for(int i = 0; i < crudListCopy.Count; i++)
         *      {
         *              InventoryItemBase realPrefab = null;
         *
         *              if(DevdogPrefabUtility.IsComponentReferenceIsBroken(crudListCopy[i], ref realPrefab))
         *              {
         *                      crudListCopy[i] = realPrefab;
         *              }
         *      }
         *
         *      crudList = crudListCopy;
         *
         * }*/

        protected override void SyncIDs()
        {
            Debug.Log("Item ID's out of sync, force updating...");

            //RepairPrefabLinks();


            List <InventoryItemBase> crudListResult = new List <InventoryItemBase>();
            var crudListCopy             = crudList;
            InventoryItemBase realPrefab = null;
            uint lastID = 0;

            for (int i = 0, j = 0; i < crudListCopy.Count; ++i)
            {
                var item = crudListCopy[i];
                if (item != null)
                {
                    var editor = GetEditor(item, (int)lastID);
                    InventoryItemBase inventoryItemBase = editor.target as InventoryItemBase;
                    inventoryItemBase.ID = lastID++;
                    crudListResult.Add(UpdatePrefab(inventoryItemBase, item));
                }

                /*else if(DevdogPrefabUtility.IsComponentReferenceIsBroken(crudListCopy[i], ref realPrefab))
                 * {
                 *      item = realPrefab;
                 *
                 *      var editor = GetEditor(item, (int)lastID);
                 *      InventoryItemBase inventoryItemBase = editor.target as InventoryItemBase;
                 *      inventoryItemBase.ID = lastID++;
                 *      crudListResult.Add(UpdatePrefab(inventoryItemBase, item));
                 * }*/
                else
                {
                    /*
                     * Debug.Log("Item is null" + item.GetInstanceID());
                     *
                     * var editor = itemEditorInspectorList[(int)lastID];
                     *
                     * if (editor != null && itemEditorInspectorList[i].target != null)
                     * {
                     *      InventoryItemBase inventoryItemBase = editor.target as InventoryItemBase;
                     *      UnityEngine.Object.DestroyImmediate(inventoryItemBase.gameObject);
                     * }
                     *
                     * itemEditorInspectorList.RemoveAt((int)lastID);
                     */
                }
            }

            crudList     = crudListResult;
            selectedItem = null;
            EditorUtility.SetDirty(ItemManager.database);
        }
Ejemplo n.º 19
0
        // Utils

        private void Save()
        {
            if (watch.ElapsedMilliseconds > 5000)
            {
                watch.Reset();
                watch.Start();

                EditorUtility.SetDirty(BoltRuntimeSettings.instance);
                AssetDatabase.SaveAssets();
            }
        }
Ejemplo n.º 20
0
        private void OnDestroy()
        {
            if (EditorPrefs.GetBool(FirstStartupKey, false) == false)
            {
                if (!EditorUtility.DisplayDialog(WizardText.CLOSE_MSG_TITLE, WizardText.CLOSE_MSG_QUESTION, "Yes", "Back"))
                {
                    EditorApplication.update += ReOpen;
                }
            }

            ready = false;
        }
Ejemplo n.º 21
0
        public static void Create(ConektonUtilityConstant.PlatformType type)
        {
            (string folderName, string linkFolderName) = GetFolderNames(type);

            if (Directory.Exists(folderName))
            {
                return;
            }

            if (!Directory.Exists(linkFolderName))
            {
                UEditorUtility.DisplayDialog("Target SDK folder is not found", "Please it locate under this project folder (not under the Assets folder).", "OK", "");
                Debug.LogWarning("This editor script will make a symbolic link of the target SDK folder under the Assets folder. Please put the target SDK folder under this project folder directly.");
                return;
            }

            switch (type)
            {
            case ConektonUtilityConstant.PlatformType.Nreal:
                RemoveSDKFolder(ConektonUtilityConstant.PlatformType.Oculus);
                break;

            case ConektonUtilityConstant.PlatformType.Oculus:
                RemoveSDKFolder(ConektonUtilityConstant.PlatformType.Nreal);
                break;
            }

            Process proc = new Process();

#if UNITY_EDITOR_WIN
            proc.StartInfo.FileName  = System.Environment.GetEnvironmentVariable("ComSpec");
            proc.StartInfo.Arguments = $"/c mklink /D \"{folderName}\" \"{linkFolderName}\"";
            proc.StartInfo.Verb      = "RunAs";
            proc.Start();
#else
            proc.StartInfo.FileName               = System.Environment.GetEnvironmentVariable("SHELL");
            proc.StartInfo.UseShellExecute        = false;
            proc.StartInfo.RedirectStandardInput  = true;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.Verb = "RunAs";
            proc.Start();
            proc.StandardInput.WriteLine($"ln -s \"{linkFolderName}\" \"{folderName}\"");
            proc.StandardInput.WriteLine("exit");
            proc.StandardInput.Flush();
#endif
            proc.WaitForExit();
            proc.Close();

            AssetDatabase.Refresh();
        }
        public override void RemoveItem(int i)
        {
            var allUsingStat = ItemManager.database.items.Where(o => o.stats.Any(s => s.stat == crudList[i])).ToArray();

            foreach (var item in allUsingStat)
            {
                var l = item.stats.ToList();
                l.RemoveAll(o => o.stat.ID == crudList[i].ID);
                item.stats = l.ToArray();

                EditorUtility.SetDirty(item);
            }

            base.RemoveItem(i);
        }
Ejemplo n.º 23
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            var t      = (UNetEquipmentCollectionCreator)target;
            var bridge = t.GetComponent <UNetActionsBridge>();

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            using (new VerticalLayoutBlock("box"))
            {
                EditorGUILayout.LabelField("Editor", UnityEditor.EditorStyles.boldLabel);
                EditorGUILayout.LabelField("Copy collection data from CollectionUI component");

                _collectionUI = (EquipmentCollectionUI)EditorGUILayout.ObjectField(_collectionUI, typeof(EquipmentCollectionUI), true);
                if (_collectionUI != null)
                {
                    if (GUILayout.Button("Copy (overwrites old)"))
                    {
                        var collection = new EquipmentCollection <IEquippableItemInstance>(0, t.GetComponent <IEquippableCharacter <IEquippableItemInstance> >(), null);
                        _collectionUI.collection = collection;
//                        _collectionUI.IndexSlotsAndMountPoints();

                        t.slots = new UnitySerializedEquipmentCollectionSlot[_collectionUI.collection.slotCount];
                        for (int i = 0; i < _collectionUI.collection.slotCount; i++)
                        {
                            var equipmentTypes = new UnityEquipmentType[collection.slots[i].equipmentTypes.Length];
                            for (int j = 0; j < equipmentTypes.Length; j++)
                            {
                                equipmentTypes[j] = bridge.equipmentTypeDatabase.Get(new Identifier(collection.slots[i].equipmentTypes[j].ID)).result;
                            }

                            t.slots[i] = new UnitySerializedEquipmentCollectionSlot()
                            {
                                equipmentTypes = equipmentTypes,
                            };
                        }

                        EditorUtility.SetDirty(t);
                        GUI.changed = true;

                        Debug.Log($"Copied {_collectionUI.collection.slotCount} slots to player", t);
                        _collectionUI.collection = null;
                    }
                }
            }
        }
Ejemplo n.º 24
0
        protected override void SyncIDs()
        {
            Debug.Log("Item ID's out of sync, force updating...");

            crudList = crudList.Where(o => o != null).ToList();
            uint lastID = 0;

            foreach (var item in crudList)
            {
                item.ID = lastID++;
                EditorUtility.SetDirty(item);
            }

            GUI.changed = true;
            EditorUtility.SetDirty(ItemManager.database);
        }
        internal static bool CreateMetadataDatabaseFiles()
        {
            var result   = false;
            var settings = MetadataAssetSettings.Load();

            MetadataAssetSettings.CreateMetadataPersistentStoreFolder(settings);
            DeleteTempDbFiles();

            var dbFolderPath = EditorPath.ConvertToAbsolutePath(settings.MetadataPersistentStorePath);

            ForEachExcelFile(settings.ExcelWorkbookFilesFolderPath, (table, fileName, index, length) =>
            {
                if (table == null)
                {
                    return;
                }

                var entityClassName = fileName.ToTitleCase();
                var info            = $"Creating Database File for Entity {entityClassName}... {index + 1}/{length}";
                var progress        = (float)(index + 1) / length;
                UnityEditorUtility.DisplayProgressBar("Hold on...", info, progress);

                var rawInfoList     = CreateMetadataEntityRawInfoList(settings, table);
                var entityClassType = GetEntityClassType(settings, entityClassName);

                if (entityClassType != null)
                {
                    var entityDataList = CreateEntityDataList(settings, table, entityClassType, rawInfoList);
                    typeof(MetadataAssetUtility).InvokeGenericStaticMethod("InsertEntityData", new[] { entityClassType }, new object[] { dbFolderPath, entityClassName, rawInfoList, entityDataList, index });
                    result = true;
                }
                else
                {
                    UnityDebug.LogErrorFormat(null, "Can not find the entity class: {0}.cs!", entityClassName);
                    result = false;
                }
            });

            // Copy MetadataEntityDBConfig database file.
            if (result)
            {
                CopyDatabaseFile(dbFolderPath, MetadataEntityDBConfig.DatabaseLocalAddress);
            }

            UnityEditorUtility.ClearProgressBar();
            return(result);
        }
        private static void OnScriptsReloaded()
        {
            var scriptsGenerated = EditorPrefs.GetBool(ScriptsGeneratedPrefKey);

            if (!scriptsGenerated)
            {
                return;
            }

            UnityEditorUtility.ClearProgressBar();
            EditorPrefs.SetBool(ScriptsGeneratedPrefKey, false);

            if (!UnityEditorUtility.scriptCompilationFailed)
            {
                try
                {
                    var result = MetadataAssetUtility.CreateMetadataDatabaseFiles();

                    if (result)
                    {
                        if (UnityEditorUtility.DisplayDialog("Success", "Build success!", "OK"))
                        {
                            UnityEditorUtility.ClearProgressBar();
                        }
                    }
                    else
                    {
                        if (UnityEditorUtility.DisplayDialog("Error", "Failed to create metadata database files!", "OK"))
                        {
                            UnityEditorUtility.ClearProgressBar();
                        }
                    }
                }
                catch (System.Exception e)
                {
                    Debug.LogException(e);
                }
            }
            else
            {
                if (UnityEditorUtility.DisplayDialog("Error", "Failed to compile metadata entity scripts!", "OK"))
                {
                    UnityEditorUtility.ClearProgressBar();
                }
            }
        }
Ejemplo n.º 27
0
        public void OnGUI()
        {
            DrawToolbar();

            if (toolbarIndex < 0 || toolbarIndex >= editors.Count || editors.Count == 0)
            {
                toolbarIndex = 0;
                CreateEditors();
            }

            // Draw the editor
            editors[toolbarIndex].Draw();

            if (GUI.changed && LosManager.instance != null)
            {
                EditorUtility.SetDirty(LosManager.instance.settings); // To make sure it gets saved.
            }
        }
        public static void SetPrefabSaveFolder()
        {
            string absolutePath = EditorUtility.SaveFolderPanel("Choose a folder to save your item prefabs", "", "");

            prefabsSaveFolder = "Assets" + absolutePath.Replace(Application.dataPath, "");

            if (isPrefabsSaveFolderValid)
            {
                CreateFolderIfDoesNotExistAlready(prefabsSaveFolder, "Items");
                CreateFolderIfDoesNotExistAlready(prefabsSaveFolder, typeof(StatDefinition).Name);
                CreateFolderIfDoesNotExistAlready(prefabsSaveFolder, typeof(ItemCategory).Name);
                CreateFolderIfDoesNotExistAlready(prefabsSaveFolder, typeof(ItemRarity).Name);
                CreateFolderIfDoesNotExistAlready(prefabsSaveFolder, typeof(EquipmentType).Name);
                CreateFolderIfDoesNotExistAlready(prefabsSaveFolder, typeof(CurrencyDefinition).Name);
                CreateFolderIfDoesNotExistAlready(prefabsSaveFolder, typeof(CraftingCategory).Name);
                CreateFolderIfDoesNotExistAlready(prefabsSaveFolder, typeof(CraftingBlueprint).Name);
                CreateFolderIfDoesNotExistAlready(prefabsSaveFolder, "Settings");
            }
        }
Ejemplo n.º 29
0
        protected override void SyncIDs()
        {
            if (updatingPrefabs)
            {
                return;
            }
            updatingPrefabs = true;
            Debug.Log("Item ID's out of sync, force updating...");

            crudList = crudList.Where(o => o != null).Distinct().ToList();

            List <GameObject> brokenPrefabs = new List <GameObject>();

            foreach (var o in crudList)
            {
                if (IsMissingComponent(o.gameObject))
                {
                    brokenPrefabs.Add(o.gameObject);
                }
            }

            if (brokenPrefabs.Count > 0)
            {
                Selection.objects = brokenPrefabs.ToArray();
                Debug.LogError("Fix Broken Prefabs First");
                return;
            }

            uint id = 0;

            foreach (var item in crudList)
            {
                UpdatePrefab(item, id);

                id++;
            }

            selectedItem = null;
            AssetDatabase.SaveAssets();
            EditorUtility.SetDirty(ItemManager.database);
            updatingPrefabs = false;
        }
Ejemplo n.º 30
0
        private void SuccessCallback(AccountServiceResponse response)
        {
            if (response.ReturnCode == AccountServiceReturnCodes.Success)
            {
                this.setupState = SetupState.RegisteredSuccessful;

                appIdOrEmail = response.ApplicationIds[((int)ServiceTypes.Realtime).ToString()];

                // Save App ID
                AppSettingsInstance.AppIdRealtime = appIdOrEmail;
            }
            else
            {
                this.setupState = SetupState.AlreadyRegistered;
                UnityEngine.Debug.LogWarning("It was not possible to process your request, please go to the Photon Cloud Dashboard.");
                UnityEngine.Debug.LogWarningFormat("Return Code: {0}", response.ReturnCode);
            }

            requestingAppId = false;
            EditorUtility.ClearProgressBar();
        }
Ejemplo n.º 31
0
 private static extern void INTERNAL_CALL_Internal_DisplayCustomMenu(ref Rect screenPosition, string[] options, int[] enabled, int[] separator, int[] selected, EditorUtility.SelectMenuItemFunction callback, object userData);
Ejemplo n.º 32
0
 internal static void DisplayCustomMenuWithSeparators(Rect position, string[] options, bool[] enabled, bool[] separator, int[] selected, EditorUtility.SelectMenuItemFunction callback, object userData)
 {
   Vector2 screenPoint = GUIUtility.GUIToScreenPoint(new Vector2(position.x, position.y));
   position.x = screenPoint.x;
   position.y = screenPoint.y;
   int[] enabled1 = new int[options.Length];
   int[] separator1 = new int[options.Length];
   for (int index = 0; index < options.Length; ++index)
   {
     enabled1[index] = !enabled[index] ? 0 : 1;
     separator1[index] = !separator[index] ? 0 : 1;
   }
   EditorUtility.Internal_DisplayCustomMenu(position, options, enabled1, separator1, selected, callback, userData);
   EditorUtility.ResetMouseDown();
 }
Ejemplo n.º 33
0
 internal static void DisplayCustomMenu(Rect position, string[] options, bool[] enabled, int[] selected, EditorUtility.SelectMenuItemFunction callback, object userData)
 {
   bool[] separator = new bool[options.Length];
   EditorUtility.DisplayCustomMenuWithSeparators(position, options, enabled, separator, selected, callback, userData);
 }
Ejemplo n.º 34
0
 public static void DisplayCustomMenu(Rect position, GUIContent[] options, int selected, EditorUtility.SelectMenuItemFunction callback, object userData)
 {
   int[] selected1 = new int[1]{ selected };
   string[] options1 = new string[options.Length];
   for (int index = 0; index < options.Length; ++index)
     options1[index] = options[index].text;
   EditorUtility.DisplayCustomMenu(position, options1, selected1, callback, userData);
 }
Ejemplo n.º 35
0
		internal static void DisplayCustomMenuWithSeparators(Rect position, string[] options, bool[] enabled, bool[] separator, int[] selected, EditorUtility.SelectMenuItemFunction callback, object userData)
		{
			Vector2 vector = GUIUtility.GUIToScreenPoint(new Vector2(position.x, position.y));
			position.x = vector.x;
			position.y = vector.y;
			int[] array = new int[options.Length];
			int[] array2 = new int[options.Length];
			for (int i = 0; i < options.Length; i++)
			{
				array[i] = ((!enabled[i]) ? 0 : 1);
				array2[i] = ((!separator[i]) ? 0 : 1);
			}
			EditorUtility.Internal_DisplayCustomMenu(position, options, array, array2, selected, callback, userData);
			EditorUtility.ResetMouseDown();
		}
Ejemplo n.º 36
0
		public static void DisplayCustomMenu(Rect position, GUIContent[] options, int selected, EditorUtility.SelectMenuItemFunction callback, object userData)
		{
			int[] selected2 = new int[]
			{
				selected
			};
			string[] array = new string[options.Length];
			for (int i = 0; i < options.Length; i++)
			{
				array[i] = options[i].text;
			}
			EditorUtility.DisplayCustomMenu(position, array, selected2, callback, userData);
		}