示例#1
0
        private List <RandomColors> GetColorListForRace(RaceData rc)
        {
            UMATextRecipe utr = rc.baseRaceRecipe as UMATextRecipe;

            UMAPackedRecipeBase.UMAPackRecipe upr = utr.PackedLoad();

            List <string> cols = new List <string>();

            foreach (UMAPackedRecipeBase.PackedOverlayColorDataV3 pcd in upr.fColors)
            {
                if (pcd.name.Trim() != "-")
                {
                    cols.Add(pcd.name);
                }
            }

            List <RandomColors> newColors = new List <RandomColors>();

            foreach (string s in cols)
            {
                RandomColors rcs = new RandomColors(s, null);
                newColors.Add(rcs);
            }
            return(newColors);
        }
        public override UMATextRecipe GetRecipe(string filename, bool dynamicallyAdd = true)
        {
            UMATextRecipe recipe = UMAAssetIndexer.Instance.GetAsset <UMAWardrobeRecipe>(filename);

            if (recipe == null)
            {
                recipe = UMAAssetIndexer.Instance.GetAsset <UMAWardrobeCollection>(filename);
            }
            return(recipe);
        }
示例#3
0
        public static void UpdateRecipe(UMATextRecipe recipe)
        {
            UMAAssetIndexer.Instance.ReleaseReference(recipe);

            List <DynamicCharacterAvatar> Avatars = GetSceneEditTimeAvatars();

            if (recipe is UMAWardrobeRecipe)
            {
                foreach (DynamicCharacterAvatar dca in Avatars)
                {
                    var items = dca.preloadWardrobeRecipes.recipes;
                    foreach (var wi in items)
                    {
                        if (wi == null)
                        {
                            continue;
                        }
                        var rcp = wi._recipe;
                        if (rcp.name == recipe.name)
                        {
                            dca.GenerateSingleUMA();
                            break;
                        }
                    }
                }
                UMAAssetIndexer.Instance.ReleaseReference(recipe);
                return;
            }

            if (recipe is UMATextRecipe)
            {
                foreach (DynamicCharacterAvatar dca in Avatars)
                {
                    if (dca.activeRace.data != null)
                    {
                        RaceData rc = dca.activeRace.data;
                        if (recipe == rc.baseRaceRecipe)
                        {
                            dca.GenerateSingleUMA();
                        }
                    }
                }
            }
        }
        public static List <WardrobeSettings> GenerateWardrobeSet(Dictionary <string, UMATextRecipe> wardrobeRecipes, params string[] slotsToSave)
        {
            if (wardrobeRecipes == null)
            {
                return(null);
            }
            var wardrobeSet = new List <WardrobeSettings>();

            if (wardrobeRecipes.Count == 0)
            {
                return(wardrobeSet);
            }
            if (slotsToSave.Length > 0)
            {
                foreach (string s in slotsToSave)
                {
                    if (wardrobeRecipes.ContainsKey(s))
                    {
                        UMATextRecipe utr = wardrobeRecipes[s];
                        if (utr != null)
                        {
                            wardrobeSet.Add(new WardrobeSettings(s, utr.name));
                            continue;
                        }
                    }
                    wardrobeSet.Add(new WardrobeSettings(s, ""));
                }
            }
            else
            {
                foreach (KeyValuePair <string, UMATextRecipe> kp in wardrobeRecipes)
                {
                    wardrobeSet.Add(new WardrobeSettings(kp.Key, kp.Value.name));
                }
            }
            return(wardrobeSet);
        }
        /// <summary>
        /// Removes a list of downloadingAssetItems from the downloadingItems List.
        /// </summary>
        /// <param name="assetName"></param>
        public IEnumerator RemoveDownload(List <DownloadingAssetItem> itemsToRemove)
        {
            //Not used any more UMAs check the status of stuff they asked for themselves
            //Dictionary<UMAAvatarBase, List<string>> updatedUMAs = new Dictionary<UMAAvatarBase, List<string>>();
            foreach (DownloadingAssetItem item in itemsToRemove)
            {
                item.isBeingRemoved = true;
            }

            foreach (DownloadingAssetItem item in itemsToRemove)
            {
                string error = "";
                //we need to check everyitem in this batch belongs to an asset bundle that has actually been loaded
                LoadedAssetBundle loadedBundleTest   = AssetBundleManager.GetLoadedAssetBundle(item.containingBundle, out error);
                AssetBundle       loadedBundleABTest = loadedBundleTest.m_AssetBundle;
                if (loadedBundleABTest == null && (String.IsNullOrEmpty(error)))
                {
                    while (loadedBundleTest.m_AssetBundle == null)
                    {
                        //could say we are unpacking here
                        yield return(null);
                    }
                }
                if (!String.IsNullOrEmpty(error))
                {
                    Debug.LogError(error);
                    yield break;
                }
            }
            //Now every item in the batch should be in a loaded bundle that is ready to use.
            foreach (DownloadingAssetItem item in itemsToRemove)
            {
                if (item != null)
                {
                    string error          = "";
                    var    loadedBundle   = AssetBundleManager.GetLoadedAssetBundle(item.containingBundle, out error);
                    var    loadedBundleAB = loadedBundle.m_AssetBundle;
                    if (!String.IsNullOrEmpty(error))
                    {
                        Debug.LogError(error);
                        yield break;
                    }
                    var itemFilename = AssetBundleManager.AssetBundleIndexObject.GetFilenameFromAssetName(item.containingBundle, item.requiredAssetName, item.tempAsset.GetType().ToString());
                    if (item.tempAsset.GetType() == typeof(RaceData))
                    {
                        RaceData actualRace = loadedBundleAB.LoadAsset <RaceData>(itemFilename);
                        UMAContext.Instance.raceLibrary.AddRace(actualRace);
                        UMAContext.Instance.raceLibrary.UpdateDictionary();
                    }
                    else if (item.tempAsset.GetType() == typeof(SlotDataAsset))
                    {
                        SlotDataAsset thisSlot = null;
                        thisSlot = loadedBundleAB.LoadAsset <SlotDataAsset>(itemFilename);
                        if (thisSlot != null)
                        {
                            UMAContext.Instance.slotLibrary.AddSlotAsset(thisSlot);
                        }
                        else
                        {
                            Debug.LogWarning("[DynamicAssetLoader] could not add downloaded slot" + item.requiredAssetName);
                        }
                    }
                    else if (item.tempAsset.GetType() == typeof(OverlayDataAsset))
                    {
                        OverlayDataAsset thisOverlay = null;
                        thisOverlay = loadedBundleAB.LoadAsset <OverlayDataAsset>(itemFilename);
                        if (thisOverlay != null)
                        {
                            UMAContext.Instance.overlayLibrary.AddOverlayAsset(thisOverlay);
                        }
                        else
                        {
                            Debug.LogWarning("[DynamicAssetLoader] could not add downloaded overlay" + item.requiredAssetName + " from assetbundle " + item.containingBundle);
                        }
                    }
                    else if (item.tempAsset.GetType() == typeof(UMATextRecipe))
                    {
                        UMATextRecipe downloadedRecipe = loadedBundleAB.LoadAsset <UMATextRecipe>(itemFilename);
                        (UMAContext.Instance.dynamicCharacterSystem as UMACharacterSystem.DynamicCharacterSystem).AddRecipe(downloadedRecipe);
                    }
                    else if (item.tempAsset.GetType() == typeof(UMAWardrobeRecipe))
                    {
                        UMAWardrobeRecipe downloadedRecipe = loadedBundleAB.LoadAsset <UMAWardrobeRecipe>(itemFilename);
                        (UMAContext.Instance.dynamicCharacterSystem as UMACharacterSystem.DynamicCharacterSystem).AddRecipe(downloadedRecipe);
                    }
                    else if (item.dynamicCallback.Count > 0)
                    {
                        //get the asset as whatever the type of the tempAsset is
                        //send this as an array to the dynamicCallback
                        var downloadedAsset      = loadedBundleAB.LoadAsset(itemFilename, item.tempAsset.GetType());
                        var downloadedAssetArray = Array.CreateInstance(item.tempAsset.GetType(), 1);
                        downloadedAssetArray.SetValue(downloadedAsset, 0);
                        for (int i = 0; i < item.dynamicCallback.Count; i++)
                        {
                            item.dynamicCallback[i].DynamicInvoke(downloadedAssetArray);
                        }
                    }
                    if (!String.IsNullOrEmpty(error))
                    {
                        Debug.LogError(error);
                    }
                }
                downloadingItems.Remove(item);
            }
            if (downloadingItems.Count == 0)
            {
                areDownloadedItemsReady = true;
                //AssetBundleManager.UnloadAllAssetBundles();//we cant do this yet
            }
            //yield break;
        }
 public override void AddRecipe(UMATextRecipe recipe)
 {
     UMAAssetIndexer.Instance.AddAsset(typeof(UMATextRecipe), recipe.name, "", recipe);
 }
示例#7
0
        /// <summary>
        /// Removes a list of downloadingAssetItems from the downloadingItems List.
        /// </summary>
        /// <param name="assetName"></param>
        public IEnumerator RemoveDownload(List <DownloadingAssetItem> itemsToRemove)
        {
            //Not used any more UMAs check the status of stuff they asked for themselves
            //Dictionary<UMAAvatarBase, List<string>> updatedUMAs = new Dictionary<UMAAvatarBase, List<string>>();
            foreach (DownloadingAssetItem item in itemsToRemove)
            {
                item.isBeingRemoved = true;
            }

            foreach (DownloadingAssetItem item in itemsToRemove)
            {
                string error = "";
                //we need to check everyitem in this batch belongs to an asset bundle that has actually been loaded
                LoadedAssetBundle loadedBundleTest   = AssetBundleManager.GetLoadedAssetBundle(item.containingBundle, out error);
                AssetBundle       loadedBundleABTest = loadedBundleTest.m_AssetBundle;
                if (loadedBundleABTest == null && (String.IsNullOrEmpty(error)))
                {
                    while (loadedBundleTest.m_AssetBundle == null)
                    {
                        //could say we are unpacking here
                        yield return(null);
                    }
                }
                if (!String.IsNullOrEmpty(error))
                {
                    Debug.LogError(error);
                    yield break;
                }
            }
            //Now every item in the batch should be in a loaded bundle that is ready to use.
            foreach (DownloadingAssetItem item in itemsToRemove)
            {
                if (item != null)
                {
                    string error          = "";
                    var    loadedBundle   = AssetBundleManager.GetLoadedAssetBundle(item.containingBundle, out error);
                    var    loadedBundleAB = loadedBundle.m_AssetBundle;
                    if (!String.IsNullOrEmpty(error))
                    {
                        Debug.LogError(error);
                        yield break;
                    }
                    var assetType = item.tempAsset.GetType();
                    //deal with RuntimeAnimatorController funkiness
                    //the actual type of an instantiated clone of a RuntimeAnimatorController in the editor is UnityEditor.Animations.AnimatorController
                    if (assetType.ToString().IndexOf("AnimatorController") > -1)
                    {
                        assetType = typeof(RuntimeAnimatorController);
                    }
                    var itemFilename = AssetBundleManager.AssetBundleIndexObject.GetFilenameFromAssetName(item.containingBundle, item.requiredAssetName, assetType.ToString());
                    if (assetType == typeof(RaceData))
                    {
                        //HACK TO FIX RACEDATA DYNAMICDNACONVERTERS DYNAMICDNA ASSETS CAUSING LOAD FAILURES in UNITY 5.5+
                        //As of Unity 5.5 a bug has reappeared when loading some types of assets that reference assets in other bundles.
                        //AssetBundleManager successfully ensures these required bundles are loaded first, but even so Unity fils to load
                        //the required asset from them in some cases, notably it seems when the required asset is set in the field of a Prefab (like our DNAAssets are)
                        //To fix this generally we could 'LoadAllAssets' from any dependent bundles, but this could incur significant memory overhead
                        //So for now we will just fix this for UMA and hope a patch is forthcoming in a subsequent version of Unity
                        if (AssetBundleManager.AssetBundleIndexObject.GetAllDependencies(item.containingBundle).Length > 0)
                        {
                            var allDeps = AssetBundleManager.AssetBundleIndexObject.GetAllDependencies(item.containingBundle);
                            for (int i = 0; i < allDeps.Length; i++)
                            {
                                string            depsError  = "";
                                LoadedAssetBundle depsBundle = AssetBundleManager.GetLoadedAssetBundle(allDeps[i], out depsError);
                                if (String.IsNullOrEmpty(depsError) && depsBundle != null)
                                {
                                    depsBundle.m_AssetBundle.LoadAllAssets <DynamicUMADnaAsset>();
                                }
                            }
                        }
                        RaceData actualRace = loadedBundleAB.LoadAsset <RaceData>(itemFilename);
                        UMAContext.Instance.raceLibrary.AddRace(actualRace);
                        UMAContext.Instance.raceLibrary.UpdateDictionary();
                    }
                    else if (assetType == typeof(SlotDataAsset))
                    {
                        SlotDataAsset thisSlot = null;
                        thisSlot = loadedBundleAB.LoadAsset <SlotDataAsset>(itemFilename);
                        if (thisSlot != null)
                        {
                            UMAContext.Instance.slotLibrary.AddSlotAsset(thisSlot);
                        }
                        else
                        {
                            Debug.LogWarning("[DynamicAssetLoader] could not add downloaded slot" + item.requiredAssetName);
                        }
                    }
                    else if (assetType == typeof(OverlayDataAsset))
                    {
                        OverlayDataAsset thisOverlay = null;
                        thisOverlay = loadedBundleAB.LoadAsset <OverlayDataAsset>(itemFilename);
                        if (thisOverlay != null)
                        {
                            UMAContext.Instance.overlayLibrary.AddOverlayAsset(thisOverlay);
                        }
                        else
                        {
                            Debug.LogWarning("[DynamicAssetLoader] could not add downloaded overlay" + item.requiredAssetName + " from assetbundle " + item.containingBundle);
                        }
                    }
                    else if (assetType == typeof(UMATextRecipe))
                    {
                        UMATextRecipe downloadedRecipe = loadedBundleAB.LoadAsset <UMATextRecipe>(itemFilename);
                        (UMAContext.Instance.dynamicCharacterSystem as UMACharacterSystem.DynamicCharacterSystem).AddRecipe(downloadedRecipe);
                    }
                    else if (assetType == typeof(UMAWardrobeRecipe))
                    {
                        UMAWardrobeRecipe downloadedRecipe = loadedBundleAB.LoadAsset <UMAWardrobeRecipe>(itemFilename);
                        (UMAContext.Instance.dynamicCharacterSystem as UMACharacterSystem.DynamicCharacterSystem).AddRecipe(downloadedRecipe);
                    }
                    else if (item.dynamicCallback.Count > 0)
                    {
                        //get the asset as whatever the type of the tempAsset is
                        //send this as an array to the dynamicCallback
                        var downloadedAsset      = loadedBundleAB.LoadAsset(itemFilename, assetType);
                        var downloadedAssetArray = Array.CreateInstance(assetType, 1);
                        downloadedAssetArray.SetValue(downloadedAsset, 0);
                        for (int i = 0; i < item.dynamicCallback.Count; i++)
                        {
                            item.dynamicCallback[i].DynamicInvoke(downloadedAssetArray);
                        }
                    }
                    if (!String.IsNullOrEmpty(error))
                    {
                        Debug.LogError(error);
                    }
                }
                downloadingItems.Remove(item);
            }
            if (downloadingItems.Count == 0)
            {
                areDownloadedItemsReady = true;
                //AssetBundleManager.UnloadAllAssetBundles();//we cant do this yet
            }
            //yield break;
        }
示例#8
0
 public abstract void AddRecipe(UMATextRecipe recipe);
        /// <summary>
        /// Returns the recipe string as a DCSUniversalPackRecipe data model that can be used by any UMA
        /// </summary>
        /// <param name="context"></param>
        /// <param name="recipeToUnpack"></param>
        /// <param name="targetUTR">If set the wardrobeSet (if it exists) and the recipeType will assigned to UMATextRecipe assets fields (used by the Recipe Editor)</param>
        /// <returns></returns>
        public static DCSUniversalPackRecipe PackedLoadDCS(UMAContextBase context, string recipeToUnpack, UMATextRecipe targetUTR = null)
        {
            if ((recipeToUnpack == null) || (recipeToUnpack.Length == 0))
            {
                return(new DCSUniversalPackRecipe());
            }
            //first use the DCSRecipeChecker to check if this is a DCS recipe
            var typeInRecipe     = GetRecipesType(recipeToUnpack);
            var targetRecipeType = typeInRecipe != "Standard" ? typeInRecipe : (targetUTR != null ? targetUTR.recipeType : "Standard");

            if (targetUTR != null)
            {
                targetUTR.recipeType = targetRecipeType;
                if (RecipeHasWardrobeSet(recipeToUnpack))
                {
                    targetUTR.activeWardrobeSet = GetRecipesWardrobeSet(recipeToUnpack);
                }
            }
            //Right now the only recipeType that uses the DCSModel is "DynamicCharacterAvatar"
            DCSUniversalPackRecipe thisUnpackedUniversal = null;

            if (targetRecipeType == "DynamicCharacterAvatar" || targetRecipeType == "WardrobeCollection")
            {
                var thisUnpacked = JsonUtility.FromJson <DCSPackRecipe>(recipeToUnpack);
                thisUnpackedUniversal = new DCSUniversalPackRecipe(thisUnpacked);
            }
            else
            {
                var thisUnpacked = JsonUtility.FromJson <UMAPackRecipe>(recipeToUnpack);
                thisUnpackedUniversal = new DCSUniversalPackRecipe(thisUnpacked);
            }
            if (RecipeHasWardrobeSet(recipeToUnpack))
            {
                thisUnpackedUniversal.wardrobeSet = GetRecipesWardrobeSet(recipeToUnpack);
            }

            return(thisUnpackedUniversal);
        }
        public void GenerateAddressables()
        {
            try
            {
                //**********************************************************************************************
                //*  Clear out the old data
                //**********************************************************************************************
                SlotTracker    = new Dictionary <int, List <UMATextRecipe> >();
                OverlayTracker = new Dictionary <int, List <UMATextRecipe> >();
                TextureTracker = new Dictionary <int, List <UMATextRecipe> >();
                GroupTracker   = new Dictionary <int, AddressableAssetGroup>();

                ClearAddressableFlags(typeof(SlotDataAsset));
                ClearAddressableFlags(typeof(OverlayDataAsset));

                // Will generate an editor context if needed.
                UMAContextBase context = UMAAssetIndexer.Instance.GetContext();

                // Create the shared group that has each item packed separately.
                AddressableAssetGroup sharedGroup = AddressableUtility.AddressableSettings.CreateGroup(SharedGroupName, false, false, true, AddressableUtility.AddressableSettings.DefaultGroup.Schemas);
                sharedGroup.GetSchema <BundledAssetGroupSchema>().BundleMode = BundledAssetGroupSchema.BundlePackingMode.PackSeparately;

                List <UMATextRecipe> theRecipes = new List <UMATextRecipe>();

                //**********************************************************************************************
                //*  Add Races
                //**********************************************************************************************

                System.Type theType = UMAAssetIndexer.Instance.GetIndexedType(typeof(RaceData));
                var         races   = UMAAssetIndexer.Instance.GetAssetDictionary(theType).Values;

                foreach (AssetItem ai in races)
                {
                    RaceData race = ai.Item as RaceData;
                    if (race == null)
                    {
                        Debug.Log("Invalid race found!");
                        continue;
                    }
                    if (race.baseRaceRecipe as UMATextRecipe == null)
                    {
                        Debug.Log("Invalid base race recipe on race: " + race.raceName);
                    }
                    theRecipes.Add(race.baseRaceRecipe as UMATextRecipe);
                    if (ai.IsAlwaysLoaded)
                    {
                        AssetItem recipe = UMAAssetIndexer.Instance.GetAssetItem <UMATextRecipe>(race.baseRaceRecipe.name);
                        recipe.IsAlwaysLoaded = true;

                        List <AssetItem> recipeItems = UMAAssetIndexer.Instance.GetAssetItems(race.baseRaceRecipe as UMAPackedRecipeBase, true);
                        foreach (AssetItem recipeitem in recipeItems)
                        {
                            recipeitem.IsAlwaysLoaded = true;
                        }
                    }
                }



                var theRecipeItems = GetAddressableRecipes();

                GenerateCollectionLabels();

                GenerateLookups(context, theRecipeItems);

                float pos = 0.0f;
                float inc = 1.0f / theRecipes.Count;

                const string tprefix = "UTR_";
                const string wprefix = "UWR_";

                // Create the Addressable groups
                foreach (AssetItem recipeItem in theRecipeItems)
                {
                    UMATextRecipe uwr  = recipeItem.Item as UMATextRecipe;
                    int           iPos = Mathf.CeilToInt(pos);
                    EditorUtility.DisplayProgressBar("Generating", "Creating Group: " + uwr.name, iPos);
                    Debug.Log("Generating group: " + uwr.name);
                    string groupName;
                    if (uwr is UMAWardrobeRecipe)
                    {
                        groupName = wprefix + uwr.name;
                    }
                    else
                    {
                        groupName = tprefix + uwr.name;
                    }
                    AddressableAssetGroup recipeGroup = AddressableUtility.AddressableSettings.CreateGroup(groupName, false, false, true, AddressableUtility.AddressableSettings.DefaultGroup.Schemas);
                    recipeGroup.GetSchema <BundledAssetGroupSchema>().BundleMode = BundledAssetGroupSchema.BundlePackingMode.PackTogether;

                    if (GroupTracker.ContainsKey(uwr.GetInstanceID()))
                    {
                        Debug.Log("Group already exists????? " + uwr.name);
                        continue;
                    }
                    GroupTracker.Add(uwr.GetInstanceID(), recipeGroup);
                    pos += inc;
                }

                AddAddressableAssets(SlotTracker, sharedGroup);
                AddAddressableAssets(OverlayTracker, sharedGroup);
                AddAddressableAssets(TextureTracker, sharedGroup);

                AssignAddressableInformation();

                ReleaseReferences(UMAAssetIndexer.Instance.GetIndexedType(typeof(SlotDataAsset)));
                ReleaseReferences(UMAAssetIndexer.Instance.GetIndexedType(typeof(OverlayDataAsset)));

                CleanupAddressables(true);
            }
            finally
            {
                EditorUtility.ClearProgressBar();
                UMAAssetIndexer.Instance.DestroyEditorUMAContextBase();
                UMAAssetIndexer.Instance.ForceSave();
            }
        }
        public bool AddRecipeGroup(UMATextRecipe recipe)
        {
            List <AssetItem> items = UMAAssetIndexer.Instance.GetAssetItems(recipe, true);

            List <AssetItem> UniqueItems = new List <AssetItem>();

            foreach (AssetItem ai in items)
            {
                if (ai.IsAddressable)
                {
                    AddressableAssetEntry ae = AddressableUtility.GetAddressableAssetEntry(ai._Path);
                    if (ae != null && ae.parentGroup.Name == SharedGroupName)
                    {
                        continue;
                    }
                    UniqueItems.Add(ai);
                }
            }

            if (UniqueItems.Count == 0)
            {
                return(false);
            }

            // create the group.
            // add the non-unique items to the group
            // Set the addressable stuff;
            AddressableAssetGroup theGroup = AddressableUtility.AddressableSettings.FindGroup(recipe.name);

            if (theGroup != null)
            {
                AddressableUtility.AddressableSettings.RemoveGroup(theGroup);
            }
            theGroup = AddressableUtility.AddressableSettings.CreateGroup(recipe.name, false, false, true, AddressableUtility.AddressableSettings.DefaultGroup.Schemas);
            theGroup.GetSchema <BundledAssetGroupSchema>().BundleMode = BundledAssetGroupSchema.BundlePackingMode.PackTogether;

            foreach (AssetItem ai in UniqueItems)
            {
                ai.AddressableAddress = ""; // let the system assign it.
                ai.IsAddressable      = true;
                ai.AddressableGroup   = recipe.name;
                ai._SerializedItem    = null;
                ai.AddressableLabels  = recipe.AssignedLabel;

                AddAssetItemToGroup(theGroup, ai, recipe.name, recipe.AssignedLabel);
#if INCL_TEXTURES
                if (IsOverlayItem(ai))
                {
                    OverlayDataAsset od = ai.Item as OverlayDataAsset;
                    if (od == null)
                    {
                        continue;
                    }

                    foreach (Texture tex in od.textureList)
                    {
                        if (tex == null)
                        {
                            continue;
                        }
                        if (tex as Texture2D == null)
                        {
                            continue;
                        }

                        string Address = "Texture2D-" + tex.name + "-" + tex.GetInstanceID();

                        bool found = AssetDatabase.TryGetGUIDAndLocalFileIdentifier(tex.GetInstanceID(), out string texGUID, out long texlocalID);
                        if (found)
                        {
                            AddItemToGroup(theGroup, tex, Address, recipe.AssignedLabel);
                        }
                    }
                }
#endif
            }
            return(true);
        }
        /// <summary>
        /// Get all the UMATextRecipes/UMWardrobeRecipes
        /// </summary>
        /// <returns></returns>
        private List <AssetItem> GetAddressableRecipes()
        {
            List <AssetItem> theRecipes = new List <AssetItem>();
            Type             theType;

            //**********************************************************************************************
            //* Add Wardrobe Recipes
            //**********************************************************************************************

            theType = UMAAssetIndexer.Instance.GetIndexedType(typeof(UMAWardrobeRecipe));
            var wardrobe = UMAAssetIndexer.Instance.GetAssetDictionary(theType).Values;

            foreach (AssetItem ai in wardrobe)
            {
                UMAWardrobeRecipe uwr = ai.Item as UMAWardrobeRecipe;
                if (uwr != null)
                {
                    if (uwr.resourcesOnly)
                    {
                        var items = UMAAssetIndexer.Instance.GetAssetItems(uwr);
                        foreach (AssetItem resourceItem in items)
                        {
                            resourceItem.IsResource = true;
                        }
                        continue;
                    }
                    theRecipes.Add(ai);
                }
            }

            theType = UMAAssetIndexer.Instance.GetIndexedType(typeof(UMATextRecipe));
            var trecipes = UMAAssetIndexer.Instance.GetAssetDictionary(theType).Values;

            foreach (AssetItem ai in trecipes)
            {
                UMATextRecipe utr = ai.Item as UMATextRecipe;
                if (utr != null)
                {
                    if (utr.resourcesOnly)
                    {
                        var items = UMAAssetIndexer.Instance.GetAssetItems(utr);
                        foreach (AssetItem resourceItem in items)
                        {
                            resourceItem.IsResource = true;
                        }
                        continue;
                    }
                    theRecipes.Add(ai);
                }
            }

            theType = UMAAssetIndexer.Instance.GetIndexedType(typeof(UMAWardrobeCollection));
            var wcrecipes = UMAAssetIndexer.Instance.GetAssetDictionary(theType).Values;

            foreach (AssetItem ai in wcrecipes)
            {
                UMATextRecipe utr = ai.Item as UMATextRecipe;
                if (utr != null)
                {
                    if (utr.resourcesOnly)
                    {
                        var items = UMAAssetIndexer.Instance.GetAssetItems(utr);
                        foreach (AssetItem resourceItem in items)
                        {
                            resourceItem.IsResource = true;
                        }
                        continue;
                    }
                    theRecipes.Add(ai);
                }
            }

            return(theRecipes);
        }
        private void GenerateLookups(UMAContextBase context, List <AssetItem> wardrobe)
        {
            float pos = 0.0f;
            float inc = 1.0f / wardrobe.Count;

            // Get the slots, overlays, textures.
            // calculate the number of references for each of them.
            // Map the usage
            foreach (AssetItem recipeItem in wardrobe)
            {
                UMATextRecipe uwr  = recipeItem.Item as UMATextRecipe;
                int           iPos = Mathf.CeilToInt(pos);
                EditorUtility.DisplayProgressBar("Generating", "Calculating Usage: " + uwr.name, iPos);

                // todo: cache this
                UMAData.UMARecipe ur = UMAAssetIndexer.Instance.GetRecipe(uwr, context);

                if (ur.slotDataList == null)
                {
                    continue;
                }

                foreach (SlotData sd in ur.slotDataList)
                {
                    if (sd == null)
                    {
                        continue;
                    }

                    AssetItem ai = UMAAssetIndexer.Instance.GetAssetItem <SlotDataAsset>(sd.slotName);

                    if (ai != null && ai.IsAlwaysLoaded == false)
                    {
                        // is this a utility slot? if so, we need to not delete it as an orphan.
                        if (sd.asset.isUtilitySlot)
                        {
                            ai.IsAlwaysLoaded = true;
                        }
                    }

                    //if (!(ai != null && ai.IsAlwaysLoaded))
                    //{
                    //AddToTracker = false;
                    //}
                    //else
                    //{
                    int slotInstance = sd.asset.GetInstanceID();

                    if (!SlotTracker.ContainsKey(slotInstance))
                    {
                        ai.IsAddressable = true;
                        SlotTracker.Add(slotInstance, new List <UMATextRecipe>());
                    }
                    SlotTracker[slotInstance].Add(uwr);
                    if (!AddressLookup.ContainsKey(slotInstance))
                    {
                        AddressLookup.Add(slotInstance, "Slt-" + sd.slotName);
                    }
                    //}

                    List <OverlayData> odList = sd.GetOverlayList();

                    foreach (OverlayData od in odList)
                    {
                        if (od == null)
                        {
                            continue;
                        }


                        /* = GetAssetItem<OverlayDataAsset>(od.overlayName);
                         *
                         * if (ai != null && ai.IsAlwaysLoaded)
                         * {
                         *  continue;
                         * }*/

                        int OverlayInstance = od.asset.GetInstanceID();

                        if (!OverlayTracker.ContainsKey(OverlayInstance))
                        {
                            OverlayTracker.Add(OverlayInstance, new List <UMATextRecipe>());
                        }
                        OverlayTracker[OverlayInstance].Add(uwr);
                        if (!AddressLookup.ContainsKey(OverlayInstance))
                        {
                            ai.IsAddressable = true;
                            AddressLookup.Add(OverlayInstance, "Ovl-" + od.overlayName);
                        }
                        foreach (Texture tx in od.textureArray)
                        {
                            if (tx == null)
                            {
                                continue;
                            }
                            int TextureID = tx.GetInstanceID();
                            if (!TextureTracker.ContainsKey(TextureID))
                            {
                                TextureTracker.Add(TextureID, new List <UMATextRecipe>());
                            }
                            TextureTracker[TextureID].Add(uwr);
                            if (!AddressLookup.ContainsKey(TextureID))
                            {
                                AddressLookup.Add(TextureID, "Tex-" + tx.name);
                            }
                        }
                    }
                }
                pos += inc;
            }
        }
示例#14
0
 public override void AddRecipe(UMATextRecipe recipe)
 {
     dynamicCharacterSystem.AddRecipe(recipe);
 }