public void Start()
        {
            UMAAssetIndexer index = UMAAssetIndexer.Instance;

            races = index.GetAllAssets <RaceData>();
#if UMA_ADDRESSABLES
            // Preload all the races.
            List <string> labels = new List <string>();
            labels.Add("UMA_Recipes");

            // Because of a bug in the current addressables implementation (crashes if you pass a
            // label that doesn't exist), we'll need to check first to see if they are there.
            // If so, they'll need to be loaded first, so they can be sorted into the availablerecipes.
            // Your app will know this in advance, and know whether to just call
            // LoadLabelList.
            // But since we don't know that for this sample, we'll check for resource locators, which
            // doesn't crash.

            var op = Addressables.LoadResourceLocationsAsync("UMA_Recipes");

            if (op.Result != null && op.Result.Count > 1)
            {
                var recipeOp = UMAAssetIndexer.Instance.LoadLabelList(labels, true); // Load the recipes!
                recipeOp.Completed += Recipes_Loaded;
            }

            if (RaceDropdown != null)
            {
                RaceDropdown.options.Clear();
                foreach (RaceData race in races)
                {
                    RaceDropdown.options.Add(new Dropdown.OptionData(race.raceName));
                }
            }
            else
            {
                if (PreloadAndUnload)
                {
                    var asyncop = UMAAssetIndexer.Instance.Preload(races, true); // Base races will always be loaded.
                    asyncop.Completed += Asyncop_Completed;
                }
            }
#else
            Avatar.gameObject.SetActive(true);
            if (RaceDropdown != null)
            {
                RaceDropdown.options.Clear();
                foreach (RaceData race in races)
                {
                    RaceDropdown.options.Add(new Dropdown.OptionData(race.raceName));
                }
            }
#endif
        }
Esempio n. 2
0
    public override void OnInspectorGUI()
    {
        UAI = target as UMAAssetIndexer;

        if (Event.current.type == EventType.Layout)
        {
            Cleanup();
        }

        ShowTypes();

        // Draw and handle the Drag/Drop
        GUILayout.Space(20);
        Rect dropArea = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true));

        GUI.Box(dropArea, "Drag Indexable Assets here. Non indexed assets will be ignored.");
        GUILayout.Space(20);
        DropAreaGUI(dropArea);

        System.Type[] Types = UAI.GetTypes();
        if (Toggles.Count != Types.Length)
        {
            SetFoldouts(false);
        }

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Collapse All"))
        {
            SetFoldouts(false);
        }

        if (GUILayout.Button("Expand All"))
        {
            SetFoldouts(true);
        }
        if (GUILayout.Button("Reindex Names"))
        {
            UAI.RebuildIndex();
        }
        if (GUILayout.Button("Clear"))
        {
            UAI.Clear();
        }
        GUILayout.EndHorizontal();

        foreach (System.Type t in Types)
        {
            if (t != typeof(AnimatorController)) // Somewhere, a kitten died because I typed that.
            {
                ShowArray(t);
            }
        }
    }
Esempio n. 3
0
        public static void AddSelectedToGlobalLibrary()
        {
            int             added = 0;
            UMAAssetIndexer UAI   = UMAAssetIndexer.Instance;

            foreach (Object o in Selection.objects)
            {
                System.Type type = o.GetType();
                if (UAI.IsIndexedType(type))
                {
                    UAI.EvilAddAsset(type, o);
                    added++;
                }
            }
            UAI.ForceSave();
            EditorUtility.DisplayDialog("Success", added + " item(s) added to Global Library", "OK");
        }
Esempio n. 4
0
    public static void Init()
    {
        UMAAssetIndexer ua = UMAAssetIndexer.Instance;

        Selection.activeObject = ua.gameObject;
    }
Esempio n. 5
0
        public override void OnInspectorGUI()
        {
            UAI = target as UMAAssetIndexer;

            if (Event.current.type == EventType.Layout)
            {
                Cleanup();
            }

            ShowTypes();

            // Draw and handle the Drag/Drop
            GUILayout.Space(20);
            Rect dropArea = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true));

            GUI.Box(dropArea, "Drag Indexable Assets here. Non indexed assets will be ignored.");
            GUILayout.Space(20);
            DropAreaGUI(dropArea);

            System.Type[] Types = UAI.GetTypes();
            if (Toggles.Count != Types.Length)
            {
                SetFoldouts(false);
            }

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Reindex Names"))
            {
                UAI.RebuildIndex();
            }
            if (GUILayout.Button("Add Build References"))
            {
                UAI.AddReferences();
                Resources.UnloadUnusedAssets();
            }
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Rebuild From Project (Adds Everything)"))
            {
                UAI.Clear();
                UAI.AddEverything(IncludeText);
                Resources.UnloadUnusedAssets();
            }
            IncludeText = GUILayout.Toggle(IncludeText, "Include TextAssets");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Clear References"))
            {
                UAI.ClearReferences();
                Resources.UnloadUnusedAssets();
            }
            if (GUILayout.Button("Clear All"))
            {
                UAI.Clear();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Collapse All"))
            {
                SetFoldouts(false);
            }

            if (GUILayout.Button("Expand All"))
            {
                SetFoldouts(true);
            }

            GUILayout.EndHorizontal();

            //bool PreSerialize = UAI.SerializeAllObjects;
            ////UAI.SerializeAllObjects = EditorGUILayout.Toggle("Serialize for build (SLOW)", UAI.SerializeAllObjects);
            //if (UAI.SerializeAllObjects != PreSerialize)
            //{
            //	UAI.ForceSave();
            //}
            UAI.AutoUpdate = EditorGUILayout.Toggle("Process Updates", UAI.AutoUpdate);
            GUILayout.BeginHorizontal();

            Filter = EditorGUILayout.TextField("Filter Library", Filter);
            GUI.SetNextControlName("TheDumbUnityBuggyField");
            if (GUILayout.Button("-", GUILayout.Width(20)))
            {
                Filter = "";
                // 10 year old unity bug that no one wants to fix.
                GUI.FocusControl("TheDumbUnityBuggyField");
            }
            GUILayout.EndHorizontal();

            bool   HasErrors  = false;
            string ErrorTypes = "";

            NotInBuildCount = 0;

            foreach (System.Type t in Types)
            {
                if (t != typeof(AnimatorController))                 // Somewhere, a kitten died because I typed that.
                {
                    if (ShowArray(t, Filter))
                    {
                        HasErrors   = true;
                        ErrorTypes += t.Name + " ";
                    }
                }
            }
            string bldMessage = "(" + NotInBuildCount + ") Item(s) not in build";

            GUILayout.BeginHorizontal();
            if (HasErrors)
            {
                GUILayout.Label(ErrorTypes + "Have error items! " + bldMessage);
            }
            else
            {
                GUILayout.Label("All items appear OK. " + bldMessage);
            }
            GUILayout.EndHorizontal();
        }