コード例 #1
0
 /// <summary>
 /// Sets any wardrobe slot. If a negative value is passed, then the slot is cleared.
 /// </summary>
 /// <param name="slotToChange">name of the wordrobe slot to change</param>
 /// <param name="fSlotNumber">Id number slot to change</param>
 public void SetSlot(string slotToChange, float fSlotNumber)
 {
     if (slotToChange == "WardrobeCollection")
     {
         SetWardrobeCollectionSlot(slotToChange, fSlotNumber);
     }
     else
     {
         var           thisRace   = Avatar.activeRace.name;
         int           slotNumber = (int)fSlotNumber;
         UMATextRecipe tr         = null;
         if (slotNumber >= 0)
         {
             tr = characterSystem.Recipes[thisRace][slotToChange][slotNumber];
             Debug.Log(tr.name);
             Avatar.SetSlot(tr);
         }
         else
         {
             Avatar.ClearSlot(slotToChange);
             Avatar.ReapplyWardrobeCollections();
         }
     }
     Avatar.BuildCharacter(true);
     //Update the dropdowns to reflect any changes after the character has built
     SetUpWardrobeDropdowns();
 }
コード例 #2
0
 public void Setup(DynamicCharacterAvatar avatar, UMATextRecipe recipe, string slot, string text)
 {
     Avatar  = avatar;
     Recipe  = recipe;
     Slot    = slot;
     theText = text;
 }
コード例 #3
0
        private bool CopyFromUTR(UMATextRecipe recipeToCopyFrom)
        {
            if (Debug.isDebugBuild)
            {
                Debug.Log("WardrobeConverts");
            }
            if (recipeToCopyFrom.recipeType != "Wardrobe" || recipeToCopyFrom.GetType() != typeof(UMATextRecipe))
            {
                return(false);
            }
            recipeType            = "Wardrobe";
            recipeString          = recipeToCopyFrom.recipeString;
            compatibleRaces       = recipeToCopyFrom.compatibleRaces;
            wardrobeSlot          = recipeToCopyFrom.wardrobeSlot;
            suppressWardrobeSlots = recipeToCopyFrom.suppressWardrobeSlots;
            Hides = recipeToCopyFrom.Hides;
            wardrobeRecipeThumbs = recipeToCopyFrom.wardrobeRecipeThumbs;
            name = recipeToCopyFrom.name;

            if (recipeToCopyFrom.OverrideDNA != null)
            {
                OverrideDNA = recipeToCopyFrom.OverrideDNA.Clone();
            }

            DisplayValue = recipeToCopyFrom.DisplayValue;
            return(true);
        }
コード例 #4
0
 private void ProcessDropeedRecipes(SerializedProperty thisRecipesProp, Object[] draggedObjects)
 {
     recipesIndexed = false;
     for (int i = 0; i < draggedObjects.Length; i++)
     {
         if (draggedObjects[i])
         {
             UMATextRecipe tempRecipeAsset = draggedObjects[i] as UMATextRecipe;
             if (!tempRecipeAsset)
             {
                 var path = AssetDatabase.GetAssetPath(draggedObjects[i]);
                 if (System.IO.Directory.Exists(path))
                 {
                     RecursiveScanFoldersForAssets(path, thisRecipesProp);
                 }
             }
             if (tempRecipeAsset && (tempRecipeAsset.recipeType == "Wardrobe" || tempRecipeAsset.recipeType == "WardrobeCollection"))
             {
                 AddRecipe(thisRecipesProp, tempRecipeAsset);
                 continue;
             }
         }
     }
     if (recipesIndexed)
     {
         recipesIndexed = false;
         UMAContextBase.Instance.ValidateDictionaries();
     }
 }
コード例 #5
0
 public UMAWardrobeRecipe(UMATextRecipe recipeToCopyFrom)
 {
     if (recipeToCopyFrom.recipeType == "Wardrobe")
     {
         CopyFromUTR(recipeToCopyFrom);
     }
 }
コード例 #6
0
 public void AddRecipe(UMATextRecipe upart)
 {
     if (upart != null)
     {
         AddRecipes(new UMATextRecipe[] { upart });
     }
 }
コード例 #7
0
    protected override void ConvertFromUTR(UMATextRecipe sourceUTR, bool andSelect = false)
    {
        var thisUTRPath = AssetDatabase.GetAssetPath(sourceUTR);

        //copy the settings from UMATextRecipe to UMADynamicCharacterAvatarRecipe
        if (CopyFromUTR(sourceUTR))
        {
            Debug.Log("Converted " + sourceUTR.name + " to an UMADynamicCharacterAvatarRecipe");
            //rename old UMATextRecipe recipe to *name*_old
            AssetDatabase.RenameAsset(thisUTRPath, sourceUTR.name + "_old");
            AssetDatabase.CreateAsset(this, thisUTRPath);
            //Delete the old Asset
            AssetDatabase.DeleteAsset(Path.Combine(Path.GetDirectoryName(thisUTRPath), (Path.GetFileNameWithoutExtension(thisUTRPath) + "_old" + Path.GetExtension(thisUTRPath))));
            AssetDatabase.SaveAssets();
            if (andSelect)
            {
                Selection.activeObject = this;
            }
        }
        else
        {
            Debug.Log("Conversion of " + sourceUTR.name + " to an UMADynmicCharacterAvatarRecipe failed. Was the recipeType 'DynamicCharacterAvatar'?");
            ScriptableObject.Destroy(this);
        }
    }
コード例 #8
0
 public UMADynamicCharacterAvatarRecipe(UMATextRecipe recipeToCopyFrom)
 {
     if (recipeToCopyFrom.recipeType == "DynamicCharacterAvatar")
     {
         CopyFromUTR(recipeToCopyFrom);
     }
 }
コード例 #9
0
ファイル: SlotHandler.cs プロジェクト: kanicha/HageExplosion
        private void AddButton(string theText, string SlotName, UMATextRecipe utr = null)
        {
            GameObject      go = GameObject.Instantiate(WardrobeButtonPrefab);
            WardrobeHandler wh = go.GetComponent <WardrobeHandler>();

            wh.Setup(Avatar, utr, SlotName, theText);
            wh.SetColors();

            go.transform.SetParent(WardrobePanel.transform);
        }
コード例 #10
0
		private void ProcessDropeedRecipes(SerializedProperty thisRecipesProp, Object[] draggedObjects)
		{
			for (int i = 0; i < draggedObjects.Length; i++)
			{
				if (draggedObjects[i])
				{
					UMATextRecipe tempRecipeAsset = draggedObjects[i] as UMATextRecipe;
					if (!tempRecipeAsset)
					{
						var path = AssetDatabase.GetAssetPath(draggedObjects[i]);
						if (System.IO.Directory.Exists(path))
						{
							RecursiveScanFoldersForAssets(path, thisRecipesProp);
						}
					}
					if (tempRecipeAsset && (tempRecipeAsset.recipeType == "Wardrobe" || tempRecipeAsset.recipeType == "WardrobeCollection"))
					{
						bool needToAddNew = true;
						for (int ii = 0; ii < thisRecipesProp.arraySize; ii++)
						{
							SerializedProperty thisElement = thisRecipesProp.GetArrayElementAtIndex(ii);
							if (thisElement.FindPropertyRelative("_recipeName").stringValue == tempRecipeAsset.name)
							{
								int compatibleRacesArraySize = tempRecipeAsset.compatibleRaces.Count;
								thisRecipesProp.GetArrayElementAtIndex(ii).FindPropertyRelative("_compatibleRaces").arraySize = compatibleRacesArraySize;
								for (int cr = 0; cr < compatibleRacesArraySize; cr++)
								{
									thisRecipesProp.GetArrayElementAtIndex(ii).FindPropertyRelative("_compatibleRaces").GetArrayElementAtIndex(cr).stringValue = tempRecipeAsset.compatibleRaces[cr];
								}
								needToAddNew = false;
							}
						}
						if (needToAddNew)
						{
							int newArrayElIndex = thisRecipesProp.arraySize;
							thisRecipesProp.InsertArrayElementAtIndex(newArrayElIndex);
							thisRecipesProp.serializedObject.ApplyModifiedProperties();
							thisRecipesProp.GetArrayElementAtIndex(newArrayElIndex).FindPropertyRelative("_recipeName").stringValue = tempRecipeAsset.name;
							int compatibleRacesArraySize = tempRecipeAsset.compatibleRaces.Count;
							thisRecipesProp.GetArrayElementAtIndex(newArrayElIndex).FindPropertyRelative("_compatibleRaces").arraySize = compatibleRacesArraySize;
							for (int cr = 0; cr < compatibleRacesArraySize; cr++)
							{
								thisRecipesProp.GetArrayElementAtIndex(newArrayElIndex).FindPropertyRelative("_compatibleRaces").GetArrayElementAtIndex(cr).stringValue = tempRecipeAsset.compatibleRaces[cr];
							}
							thisRecipesProp.serializedObject.ApplyModifiedProperties();
							GUI.changed = true;
							changed = true;
						}
						continue;
					}
				}
			}
		}
コード例 #11
0
        private void SaveAndStart(GameObject selectedChar)
        {
            //Save the selected UMA into a static string so we can access it from the Game Scene
            UMAAvatarBase avatar = selectedChar.GetComponent <UMAAvatarBase>();
            UMATextRecipe asset  = ScriptableObject.CreateInstance <UMATextRecipe>();

            asset.Save(avatar.umaData.umaRecipe, avatar.context);
            umaString = asset.recipeString;

            //Start network host
            manager.StartHost();
        }
コード例 #12
0
    void Initialize()
    {
        UMAInstance();

        gameObject = new GameObject(objectName);
        UpdateVec();

        umaContext = UMAContext.FindInstance();
        UMAGenerator generator = umaContext.umaGenerator;

        umaDynamicAvatar = gameObject.AddComponent <UMADynamicAvatar>();
        umaDynamicAvatar.Initialize();

        UMAData umaData = umaDynamicAvatar.umaData;

        umaDynamicAvatar.umaGenerator = generator;
        umaData.umaGenerator          = generator;

        UMATextRecipe recipe = UMATextRecipe.CreateInstance <UMATextRecipe>();

        recipe.Load(umaData.umaRecipe, umaContext);
        umaDynamicAvatar.umaRecipe = recipe;
        umaData.AddAdditionalRecipes(new UMARecipeBase[] { umaContext.umaTextRecipe }, umaContext);
        umaData.OnCharacterCreated   += CharacterCreated;
        umaData.OnCharacterUpdated   += CharacterUpdated;
        umaData.OnCharacterDestroyed += CharacterDestroyed;

        if (isExpress)
        {
            expressionPlayer = gameObject.AddComponent <UMAExpressionPlayer>();
            expressionPlayer.overrideMecanimEyes = true;
            expressionPlayer.overrideMecanimHead = true;
            expressionPlayer.overrideMecanimJaw  = true;
            expressionPlayer.overrideMecanimNeck = true;
        }

        umaData.umaRecipe.slotDataList = new SlotData[100];
        UMADnaHumanoid umaDna         = new UMADnaHumanoid();
        UMADnaTutorial umaTutorialDNA = new UMADnaTutorial();

        umaData.umaRecipe.AddDna(umaDna);
        umaData.umaRecipe.AddDna(umaTutorialDNA);

        ICharacterSlotOverly characterSlotOverlay = new CharacterSlotOverly(umaDynamicAvatar);

        characterAnim = new CharacterAnim(umaDynamicAvatar);
        //characterDna = new CharacterDna(umaDna, umaData, characterAnim, characterData);
        characterBase  = new CharacterBase(resType, characterSlotOverlay, umaData, umaDynamicAvatar, characterData);
        characterCloth = new CharacterCloth(resType, characterData, characterSlotOverlay, this, characterBase);
    }
コード例 #13
0
        /// <summary>
        /// If the given UMATextRecipe was of recipeType "DynamicCharacterAvatar", copies its to this UMADynamicCharacterAvatarRecipe, otherwise returns false.
        /// </summary>
        /// <param name="recipeToCopyFrom"></param>
        /// <returns></returns>
        private bool CopyFromUTR(UMATextRecipe recipeToCopyFrom)
        {
            if (recipeToCopyFrom.recipeType != "DynamicCharacterAvatar" || recipeToCopyFrom.GetType() != typeof(UMATextRecipe))
            {
                return(false);
            }
            recipeType = "DynamicCharacterAvatar";
            var recipeModel = JsonUtility.FromJson <DCSPackRecipe>(recipeToCopyFrom.recipeString);

            recipeModel.packedRecipeType = "DynamicCharacterAvatar";
            recipeString = JsonUtility.ToJson(recipeModel);
            name         = recipeToCopyFrom.name;
            return(true);
        }
コード例 #14
0
    public void RefreshUma()
    {
        if (umaDna == "")
        {
            return;
        }

        DynamicCharacterAvatar avatar = GetComponentInChildren <DynamicCharacterAvatar>();

        if (GetComponentInChildren <DynamicCharacterAvatar>() == null)
        {
            return;
        }

        string decompressed = CompressUMA.Compressor.DecompressDna(umaDna);

        avatar.ClearSlots();
        avatar.LoadFromRecipeString(decompressed);

        for (int i = 0; i < equipment.Count; i++)
        {
            ItemSlot      slot = equipment[i];
            EquipmentInfo info = equipmentInfo[i];

            //  valid item?
            if (slot.amount > 0)
            {
                EquipmentItem itemData = (EquipmentItem)slot.item.data;

                UMATextRecipe maleRecipe   = itemData.maleUmaRecipe;
                UMATextRecipe femaleRecipe = itemData.femaleUmaRecipe;

                if (avatar == null)
                {
                    return;
                }

                if (maleRecipe != null)
                {
                    avatar.SetSlot(maleRecipe);
                }

                if (femaleRecipe != null)
                {
                    avatar.SetSlot(femaleRecipe);
                }
            }
        }
    }
コード例 #15
0
ファイル: UMAMaker1.cs プロジェクト: UKirsche/MidgardWorker
    /// <summary>
    /// Save the UMA Avatar.
    /// </summary>
    public void Save()
    {
        UMATextRecipe recipe = ScriptableObject.CreateInstance <UMATextRecipe> ();

        recipe.Save(umaDynamicAvatar.umaData.umaRecipe, umaDynamicAvatar.context);
        SaveString = recipe.recipeString;
        Destroy(recipe);

        //Save String to  text file
        string       fileName = "Avatar.txt";
        StreamWriter stream   = File.CreateText(fileName);

        stream.WriteLine(SaveString);
        stream.Close();
    }
コード例 #16
0
ファイル: UMAMaker1.cs プロジェクト: UKirsche/MidgardWorker
    /// <summary>
    /// Load the UMA Avatar.
    /// </summary>
    public void Load()
    {
        //Load UMA-string from local text file
        string       fileName = "Avatar.txt";
        StreamReader stream   = File.OpenText(fileName);

        SaveString = stream.ReadLine();
        stream.Close();

        UMATextRecipe recipe = ScriptableObject.CreateInstance <UMATextRecipe> ();

        recipe.recipeString = SaveString;
        umaDynamicAvatar.Load(recipe);
        Destroy(recipe);
    }
コード例 #17
0
ファイル: UMAMaker1_Police.cs プロジェクト: igame3dbill/udg2
    void LoadText()
    {
        //Save string to text file
        string       fileName = "Assets/UMASavedTextFile.txt";
        StreamReader stream   = File.OpenText(fileName);

        myCustomUMA.SaveString = stream.ReadLine();
        stream.Close();

        //Generate UMA String
        UMATextRecipe recipe = ScriptableObject.CreateInstance <UMATextRecipe>();

        recipe.recipeString = myCustomUMA.SaveString;
        umaDynamicAvatar.Load(recipe);
        Destroy(recipe);
    }
コード例 #18
0
ファイル: UMAMaker1_Police.cs プロジェクト: igame3dbill/udg2
    //practical guide to uma part 14 https://youtu.be/ZKRQ4wzp0ac
    ////////////////// Load and Save //////////////////////

    void SaveText()
    {
        //Generate UMA String
        UMATextRecipe recipe = ScriptableObject.CreateInstance <UMATextRecipe>();

        recipe.Save(umaDynamicAvatar.umaData.umaRecipe, umaDynamicAvatar.context);
        myCustomUMA.SaveString = recipe.recipeString;
        Destroy(recipe);

        //Save string to text file
        string       fileName = "Assets/UMASavedTextFile.txt";
        StreamWriter stream   = File.CreateText(fileName);

        stream.WriteLine(myCustomUMA.SaveString);
        stream.Close();
    }
コード例 #19
0
 private bool CopyFromUTR(UMATextRecipe recipeToCopyFrom)
 {
     if (recipeToCopyFrom.recipeType != "Wardrobe" || recipeToCopyFrom.GetType() != typeof(UMATextRecipe))
     {
         return(false);
     }
     recipeType            = "Wardrobe";
     recipeString          = recipeToCopyFrom.recipeString;
     compatibleRaces       = recipeToCopyFrom.compatibleRaces;
     wardrobeSlot          = recipeToCopyFrom.wardrobeSlot;
     suppressWardrobeSlots = recipeToCopyFrom.suppressWardrobeSlots;
     Hides = recipeToCopyFrom.Hides;
     wardrobeRecipeThumbs = recipeToCopyFrom.wardrobeRecipeThumbs;
     name         = recipeToCopyFrom.name;
     DisplayValue = recipeToCopyFrom.DisplayValue;
     return(true);
 }
コード例 #20
0
        /**
         * Given an AssetLoaderController in input,a UMA avator's name and a UMADynamicAvator
         * create and spawn a new uma avator. It is possible to pass also a callback
         * that it's executed after the uma avator is created.
         * */
        public static GameObject createUMAAvator(AssetLoaderController assetLoaderController,
                                                 string umaAvatorName,
                                                 UMADynamicAvatar umaDynamicAvator,
                                                 Action <UMAData> onCharacterCreatedCallback = null)
        {
            GameObject thisUma = null;

            if (assetLoaderController != null && umaAvatorName != null &&
                umaDynamicAvator != null)
            {
                //Set/spawn a UMA Avator
                thisUma = umaDynamicAvator.gameObject;
                UMADynamicAvatar thisUmaDynamicAvator = thisUma.GetComponent <UMADynamicAvatar>();

                thisUmaDynamicAvator.context      = assetLoaderController.context;
                thisUmaDynamicAvator.umaGenerator = assetLoaderController.generator;
                thisUmaDynamicAvator.loadOnStart  = false;
                thisUmaDynamicAvator.Initialize();
                thisUmaDynamicAvator.animationController = assetLoaderController.thirdPersonController;
                UMATextRecipe recipe = assetLoaderController.umaCharactersTemplates[umaAvatorName];
                thisUmaDynamicAvator.Load(recipe);

                if (onCharacterCreatedCallback != null)
                {
                    thisUma.GetComponent <UMAData>().OnCharacterCreated += onCharacterCreatedCallback;
                }
            }
            else
            {
                string partOfTheError = "given in input is null";
                if (assetLoaderController == null)
                {
                    throw new System.ArgumentException("AssetLoader " + partOfTheError);
                }
                else if (umaAvatorName == null)
                {
                    throw new System.ArgumentException("UMA's avator name " + partOfTheError);
                }
                else if (umaDynamicAvator == null)
                {
                    throw new System.ArgumentException("DyanamicAvator " + partOfTheError);
                }
            }
            return(thisUma);
        }
コード例 #21
0
        private bool AddRecipe(SerializedProperty thisRecipesProp, UMATextRecipe tempRecipeAsset)
        {
            bool needToAddNew = true;

            for (int ii = 0; ii < thisRecipesProp.arraySize; ii++)
            {
                SerializedProperty thisElement = thisRecipesProp.GetArrayElementAtIndex(ii);
                if (thisElement.FindPropertyRelative("_recipeName").stringValue == tempRecipeAsset.name)
                {
                    int compatibleRacesArraySize = tempRecipeAsset.compatibleRaces.Count;
                    thisRecipesProp.GetArrayElementAtIndex(ii).FindPropertyRelative("_compatibleRaces").arraySize = compatibleRacesArraySize;
                    for (int cr = 0; cr < compatibleRacesArraySize; cr++)
                    {
                        thisRecipesProp.GetArrayElementAtIndex(ii).FindPropertyRelative("_compatibleRaces").GetArrayElementAtIndex(cr).stringValue = tempRecipeAsset.compatibleRaces[cr];
                    }
                    needToAddNew = false;
                }
            }
            if (needToAddNew)
            {
                if (!UMAContextBase.Instance.HasRecipe(tempRecipeAsset.name))
                {
                    UMAContextBase.Instance.AddRecipe(tempRecipeAsset);
                    recipesIndexed = true;
                }
                int newArrayElIndex = thisRecipesProp.arraySize;
                thisRecipesProp.InsertArrayElementAtIndex(newArrayElIndex);
                thisRecipesProp.serializedObject.ApplyModifiedProperties();
                thisRecipesProp.GetArrayElementAtIndex(newArrayElIndex).FindPropertyRelative("_recipeName").stringValue = tempRecipeAsset.name;
                int compatibleRacesArraySize = tempRecipeAsset.compatibleRaces.Count;
                thisRecipesProp.GetArrayElementAtIndex(newArrayElIndex).FindPropertyRelative("_compatibleRaces").arraySize = compatibleRacesArraySize;
                for (int cr = 0; cr < compatibleRacesArraySize; cr++)
                {
                    thisRecipesProp.GetArrayElementAtIndex(newArrayElIndex).FindPropertyRelative("_compatibleRaces").GetArrayElementAtIndex(cr).stringValue = tempRecipeAsset.compatibleRaces[cr];
                }
                thisRecipesProp.serializedObject.ApplyModifiedProperties();
                GUI.changed = true;
                changed     = true;
                return(true);
            }
            return(false);
        }
コード例 #22
0
ファイル: TestCustomizerDD.cs プロジェクト: grendelbiter/UMA
    //Decided this may be more confusing than useful...Just left here in case I change my mind...
    public void UpdateSuppressedWardrobeDropdowns(UMATextRecipe suppressedBy)
    {
        if (suppressedBy.suppressWardrobeSlots == null)
        {
            return;
        }
        var suppressedSlots = suppressedBy.suppressWardrobeSlots;

        foreach (Transform child in wardrobeDropdownPanel.transform)
        {
            child.GetComponent <Dropdown>().captionImage.overrideSprite = null;
            var thisSlot = child.GetComponent <CSWardrobeSlotChangerDD>().wardrobeSlotToChange;
            if (suppressedSlots.Contains(thisSlot))
            {
                child.GetComponent <Dropdown>().value = 0;
                //make the suppressed slot show the image of the item it is being suppressed by
                child.GetComponent <Dropdown>().captionImage.overrideSprite = suppressedBy.GetWardrobeRecipeThumbFor(thisRace);
            }
        }
    }
コード例 #23
0
        /// <summary>
        /// Get a recipe from the DCS dictionary, optionally 'dynamicallyAdding' it from Resources/AssetBundles if the component is set up to do this.
        /// </summary>
        public UMATextRecipe GetRecipe(string filename, bool dynamicallyAdd = true)
        {
            UMATextRecipe foundRecipe = null;

            if (RecipeIndex.ContainsKey(filename))
            {
                foundRecipe = RecipeIndex[filename];
            }
            else
            {
                if (dynamicallyAdd)
                {
                    GatherRecipeFiles(filename);
                    if (RecipeIndex.ContainsKey(filename))
                    {
                        foundRecipe = RecipeIndex[filename];
                    }
                }
            }
            return(foundRecipe);
        }
コード例 #24
0
ファイル: TestCustomizerDD.cs プロジェクト: grendelbiter/UMA
    /// <summary>
    /// Sets any wardrobe slot. If a negative value is passed, then the slot is cleared.
    /// </summary>
    /// <param name="slotToChange">name of the wordrobe slot to change</param>
    /// <param name="fSlotNumber">Id number slot to change</param>
    public void SetSlot(string slotToChange, float fSlotNumber)
    {
        var           thisRace         = Avatar.activeRace.name;
        int           slotNumber       = (int)fSlotNumber;
        string        prioritySlot     = "";
        List <string> prioritySlotOver = new List <string>();
        UMATextRecipe tr = null;

        if (slotNumber >= 0)
        {
            tr = characterSystem.Recipes[thisRace][slotToChange][slotNumber];
            prioritySlotOver = tr.suppressWardrobeSlots;
            prioritySlot     = tr.wardrobeSlot;
            Avatar.SetSlot(tr);
        }
        else
        {
            Avatar.ClearSlot(slotToChange);
        }
        if (prioritySlotOver.Count > 0)
        {
            foreach (Transform child in wardrobeDropdownPanel.transform)
            {
                if (child.gameObject.activeSelf)
                {
                    var thisSlot = child.GetComponent <CSWardrobeSlotChangerDD>().wardrobeSlotToChange;
                    if (prioritySlotOver.Contains(thisSlot))
                    {
                        child.GetComponent <Dropdown>().value = 0;
                        child.GetComponent <Dropdown>().CancelInvoke();
                    }
                }
            }
        }
        Avatar.BuildCharacter(true, prioritySlot, prioritySlotOver);
        //Update the dropdowns to reflect any changes
        SetUpWardrobeDropdowns();
    }
コード例 #25
0
    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);
    }
コード例 #26
0
        public void CacheAllUMA(string assetName)
        {
            umaCharactersAsset = AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/" + assetName);
            Object[] allAssets = null;

            /*
             * The first process that execute AssetBundle.LoadFromFile will load the asset,
             * so we nned to check this before calling LoadAllAssets() or an exception
             * will be thrown.
             * **/
            if (umaCharactersAsset != null)
            {
                allAssets = umaCharactersAsset.LoadAllAssets();
            }
            else
            {
                Debug.Log("Uma assets already loaded");
            }

            //Cache all available UMAs
            foreach (Object asset in allAssets)
            {
                if (asset.GetType() == typeof(UMATextRecipe))
                {
                    UMATextRecipe umaRecipe = (UMATextRecipe)asset;
                    umaCharactersTemplates.Add(umaRecipe.name, umaRecipe);
                }
                else
                {
                    thirdPersonController = (RuntimeAnimatorController)asset;
                }
            }

            generator = MonoBehaviour.FindObjectOfType <UMAGenerator>();
            context   = MonoBehaviour.FindObjectOfType <UMAContext>();
        }
コード例 #27
0
        /// <summary>
        /// Removes a list of downloadingAssetItems from the downloadingItems List.
        /// </summary>
        /// <param name="itemsToRemove"></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))
                {
                    if (Debug.isDebugBuild)
                    {
                        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))
                    {
                        if (Debug.isDebugBuild)
                        {
                            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))
                    {
                        RaceData actualRace = loadedBundleAB.LoadAsset <RaceData>(itemFilename);
                        UMAContextBase.Instance.AddRace(actualRace);
                    }
                    else if (assetType == typeof(SlotDataAsset))
                    {
                        SlotDataAsset thisSlot = null;
                        thisSlot = loadedBundleAB.LoadAsset <SlotDataAsset>(itemFilename);
                        if (thisSlot != null)
                        {
                            UMAContextBase.Instance.AddSlotAsset(thisSlot);
                        }
                        else
                        {
                            if (Debug.isDebugBuild)
                            {
                                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)
                        {
                            UMAContextBase.Instance.AddOverlayAsset(thisOverlay);
                        }
                        else
                        {
                            if (Debug.isDebugBuild)
                            {
                                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);
                        UMAContextBase.Instance.AddRecipe(downloadedRecipe);
                    }
                    else if (assetType == typeof(UMAWardrobeRecipe))
                    {
                        UMAWardrobeRecipe downloadedRecipe = loadedBundleAB.LoadAsset <UMAWardrobeRecipe>(itemFilename);
                        UMAContextBase.Instance.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))
                    {
                        if (Debug.isDebugBuild)
                        {
                            Debug.LogError(error);
                        }
                    }
                }
                downloadingItems.Remove(item);
            }
            if (downloadingItems.Count == 0)
            {
                areDownloadedItemsReady = true;
                //AssetBundleManager.UnloadAllAssetBundles();//we cant do this yet
            }
            //yield break;
        }
コード例 #28
0
 //cant do static virtual in c# so we cant make child classes have their own static version of this- you have to create an instance first which is a pain
 protected virtual void ConvertFromUTR(UMATextRecipe sourceUTR, bool andSelect = false)
 {
 }
コード例 #29
0
    /// <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(UMAContext 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);
    }
コード例 #30
0
ファイル: UMAAssetTreeView.cs プロジェクト: ALAZOUARI/ChatBot
        void CellGUI(Rect cellRect, TreeViewItem <AssetTreeElement> item, AssetColumns column, ref RowGUIArgs args)
        {
            // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
            CenterRectUsingSingleLineHeight(ref cellRect);

            if (item.data.depth == 0)
            {
                HeaderCellGUI(cellRect, item, column, ref args);
                return;
            }

            AssetItem        ai      = item.data.ai;
            AssetTreeElement element = item.data;

            switch (column)
            {
            case AssetColumns.Selection:
            {
                // EditorGUI.Toggle(cellRect, item.data.ai._SerializedItem != null);
                bool newVal = EditorGUI.Toggle(cellRect, element.Checked);
                if (newVal != element.Checked)
                {
                    element.Checked = newVal;
                    RecalcTypeChecks(element.type);
                }
            }
            break;

            case AssetColumns.Type:
            {
                EditorGUI.LabelField(cellRect, element.type.Name);
            }
            break;

            case AssetColumns.Always:
            {
                cellRect.x     += kCheckboxOffset;
                cellRect.width -= kCheckboxOffset;
                bool clicked = EditorGUI.Toggle(cellRect, ai.IsAlwaysLoaded);
                if (clicked != ai.IsAlwaysLoaded)
                {
                    ai.IsAlwaysLoaded = clicked;
                    UMAAssetIndexer.Instance.ForceSave();
                }
            }
            break;

            case AssetColumns.IsResource:
            {
                cellRect.x     += kCheckboxOffset;
                cellRect.width -= kCheckboxOffset;
                EditorGUI.Toggle(cellRect, ai.IsResource);
            }
            break;

            case AssetColumns.Name:
            {
                // Do toggle
                Rect toggleRect = cellRect;
                toggleRect.x    += GetContentIndent(item);
                toggleRect.width = kToggleWidth;
                //if (toggleRect.xMax < cellRect.xMax)
                //	item.data.enabled = EditorGUI.Toggle(toggleRect, item.data.enabled); // hide when outside cell rect

                // Default icon and label
                args.rowRect = cellRect;
                base.RowGUI(args);
            }
            break;

            case AssetColumns.IsAddressable:
            {
                cellRect.x     += kCheckboxOffset;
                cellRect.width -= kCheckboxOffset;
                EditorGUI.Toggle(cellRect, ai.IsAddressable);
            }
            break;

            case AssetColumns.Group:
                EditorGUI.LabelField(cellRect, ai.AddressableGroup);
                break;

            case AssetColumns.Labels:
            {
                if (!string.IsNullOrEmpty(ai.AddressableLabels))
                {
                    Rect Button = new Rect(cellRect);
                    Button.width   = 32;
                    Button.height -= 2;

                    if (GUI.Button(Button, "View", EditorStyles.toolbarButton))
                    {
                        List <string> labels = new List <string>();
                        labels.AddRange(ai.AddressableLabels.Split(';'));
                        DisplayListWindow.ShowDialog("Addressable Labels", owningWindow.position, labels);
                    }
                    cellRect.x     += 32;
                    cellRect.width -= 32;
                    EditorGUI.LabelField(cellRect, ai.AddressableLabels);
                }
            }
            break;

            case AssetColumns.Buttons:
            {
                float BtnWidth   = (cellRect.width / 3) - (kToggleWidth * 2);
                Rect  ButtonRect = new Rect(cellRect);
                ButtonRect.width = BtnWidth;

                if (GUI.Button(ButtonRect, "Inspect", EditorStyles.toolbarButton))
                {
                    UnityEngine.Object o = AssetDatabase.LoadMainAssetAtPath(ai._Path);
                    InspectorUtlity.InspectTarget(o);
                }

                /*
                 * ButtonRect.x = ButtonRect.x + BtnWidth;
                 * if (item.data.ai._SerializedItem == null)
                 * {
                 *      if(GUI.Button(ButtonRect, "Add Ref", EditorStyles.toolbarButton))
                 *      {
                 *              ai.CacheSerializedItem();
                 *              Repaint();
                 *      }
                 * }
                 * else
                 * {
                 *      if(GUI.Button(ButtonRect, "Rmv Ref",EditorStyles.toolbarButton))
                 *      {
                 *              ai.ReleaseItem();
                 *              Repaint();
                 *      }
                 * }
                 */
#if UMA_ADDRESSABLES
                if (ai.Item is UMATextRecipe)
                {
                    UMATextRecipe recipe = ai.Item as UMATextRecipe;

                    if (owningWindow.LoadedLabels.Contains(recipe.AssignedLabel))
                    {
                        ButtonRect.x     = ButtonRect.x + ButtonRect.width;
                        ButtonRect.width = 110;

                        if (GUI.Button(ButtonRect, "Update Groups", EditorStyles.toolbarButton))
                        {
                            UMAAssetIndexer.Instance.AddRecipeGroup(recipe);
                            owningWindow.LoadedLabels.Add(recipe.AssignedLabel);
                        }
                    }
                    else
                    {
                        ButtonRect.x     = ButtonRect.x + ButtonRect.width;
                        ButtonRect.width = 110;

                        if (GUI.Button(ButtonRect, "Make Addressable", EditorStyles.toolbarButton))
                        {
                            UMAAssetIndexer.Instance.AddRecipeGroup(recipe);
                            owningWindow.LoadedLabels.Add(recipe.AssignedLabel);
                        }
                    }
                }
#endif
                ButtonRect.x     = ButtonRect.x + ButtonRect.width;
                ButtonRect.width = 32;
                if (GUI.Button(ButtonRect, "Ping", EditorStyles.toolbarButton))
                {
                    UnityEngine.Object o = AssetDatabase.LoadMainAssetAtPath(ai._Path);
                    EditorGUIUtility.PingObject(o);
                }

                ButtonRect.x     = ButtonRect.x + 32;
                ButtonRect.width = kToggleWidth;
                if (GUI.Button(ButtonRect, "X", EditorStyles.toolbarButton))
                {
                    // remove from index.
                    // remove from tree.

                    List <AssetTreeElement> RemoveMe = new List <AssetTreeElement>();
                    UMAAssetIndexer.Instance.RemoveAsset(ai._Type, ai._Name);
                    RemoveMe.Add(item.data);
                    this.treeModel.RemoveElements(RemoveMe);
                    owningWindow.RecountTypes();
                    RecalcTypeChecks(element.type);
                    Repaint();
                }
            }
            break;
            }
        }