private void FindMatchingOverlayDataAssets()
        {
            HashSet <Object> selectedAssets = new HashSet <Object>();

            string[] guids = AssetDatabase.FindAssets("t:OverlayDataAsset");

            //TODO add progress bar.
            for (int i = 0; i < guids.Length; i++)
            {
                OverlayDataAsset overlay = AssetDatabase.LoadAssetAtPath <OverlayDataAsset>(AssetDatabase.GUIDToAssetPath(guids[i]));
                if (overlay == null)
                {
                    continue;
                }

                if (UMAMaterial.Equals(overlay.material, target as UMAMaterial))
                {
                    selectedAssets.Add(overlay);
                }
            }

            if (selectedAssets.Count > 0)
            {
                Debug.Log(selectedAssets.Count + " matching OverlayDataAssets found.");
                Object[] selected = new Object[selectedAssets.Count];
                selectedAssets.CopyTo(selected);
                Selection.objects = selected;
            }
            else
            {
                EditorUtility.DisplayDialog("None found", "No matching OverlayDataAssets were found.", "OK");
            }
        }
Ejemplo n.º 2
0
    public void CreatPrefab()
    {
        #region cloths
        EditorUtility.DisplayProgressBar(sex.ToString(), "clothes resources are dealing...", 1 / 7f);
        IEditorCloth cloths = EditorClothFactory.Creat(sex, restype);
        cloths.CreatPrefab();
        #endregion

        #region race
        EditorUtility.DisplayProgressBar(sex.ToString(), "create race...", 2 / 7f);
        TPoseEditor pose = TPoseEditorFactory.Creat(sex, obj, restype);
        RaceData    rd   = pose.CreatTPose();
        #endregion

        #region animator

        EditorUtility.DisplayProgressBar(sex.ToString(), "animations resources are dealing...", 3 / 7f);
        IEditorAnimation          anim       = EditorAnimationFactory.Creat(sex, restype);
        RuntimeAnimatorController controller = anim.Creat();

        #endregion

        #region base
        EditorUtility.DisplayProgressBar(sex.ToString(), "body parts resources are dealing...", 5 / 7f);

        List <SlotOverlayItem> sos = new List <SlotOverlayItem>();

        SlotOverlayItem     eyeItem      = new SlotOverlayItem();
        BaseClothItemEditor eyes         = new EyesEditor(obj, restype);
        SlotDataAsset       eyes_slot    = eyes.CreatSlot();
        OverlayDataAsset    eyes_overlay = eyes.CreatOverlay();
        eyeItem.slot      = eyes_slot;
        eyeItem.overlay   = eyes_overlay;
        eyeItem.partIndex = eyes.WearPos;

        SlotOverlayItem     faceItem     = new SlotOverlayItem();
        BaseClothItemEditor face         = new FaceEditor(obj, restype);
        SlotDataAsset       face_slot    = face.CreatSlot();
        OverlayDataAsset    face_overlay = face.CreatOverlay();
        faceItem.slot      = face_slot;
        faceItem.overlay   = face_overlay;
        faceItem.partIndex = face.WearPos;


        sos.Add(eyeItem);
        sos.Add(faceItem);
        #endregion

        #region CharacterPlayer
        EditorUtility.DisplayProgressBar(sex.ToString(), "create character...", 7 / 7f);
        Dictionary <string, object> dic = new Dictionary <string, object>();
        dic["animatorController"] = controller;
        dic["race"] = rd;
        dic["sos"]  = sos;

        string      assetpath = string.Format("{0}/{1}.prefab", prefabFold, obj.Name);
        IPrefabItem prefab    = new PrefabItem(assetpath);
        prefab.CreatPrefab(null, CreatPrefabFinish, dic);
        #endregion
    }
Ejemplo n.º 3
0
    public OverlayDataAsset CreatOverlay()
    {
        if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(filename) || diffuse == null)
        {
            Debug.LogError("path or filename or texture is null !!!");
            return(null);
        }

        OverlayDataAsset oda = OverlayDataAsset.CreateInstance <OverlayDataAsset>();

        oda.overlayName = filename;
        oda.material    = uMaterial.Load();
        oda.textureList = new Texture2D[] { diffuse };
        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }

        string      p       = path + "/" + filename + "_" + UMAUtils.Overlay + ".asset";
        IObjectBase objBase = new ObjectBase(p);

        objBase.CreatAsset(oda);
        objBase.Save();

        return(oda);
    }
Ejemplo n.º 4
0
    public override void AddOverlayAsset(OverlayDataAsset overlay)
    {
        ValidateDictionary();
        var hash = UMAUtils.StringToHash(overlay.overlayName);

        if (overlayDictionary.ContainsKey(hash))
        {
            for (int i = 0; i < overlayElementList.Length; i++)
            {
                if (overlayElementList[i].overlayName == overlay.overlayName)
                {
                    overlayElementList[i] = overlay;
                    break;
                }
            }
        }
        else
        {
            var list = new OverlayDataAsset[overlayElementList.Length + 1];
            for (int i = 0; i < overlayElementList.Length; i++)
            {
                list[i] = overlayElementList[i];
            }
            list[list.Length - 1] = overlay;
            overlayElementList    = list;
        }
        overlayDictionary[hash] = overlay;
    }
Ejemplo n.º 5
0
 /// <summary>
 /// Gets the asset hash and name for the given object
 /// </summary>
 private void GetEvilAssetNameAndHash(System.Type type, Object o, ref string assetName, int assetHash)
 {
     if (o is SlotDataAsset)
     {
         SlotDataAsset sd = o as SlotDataAsset;
         assetName = sd.slotName;
         assetHash = sd.nameHash;
     }
     else if (o is OverlayDataAsset)
     {
         OverlayDataAsset od = o as OverlayDataAsset;
         assetName = od.overlayName;
         assetHash = od.nameHash;
     }
     else if (o is RaceData)
     {
         RaceData rd = o as RaceData;
         assetName = rd.raceName;
         assetHash = UMAUtils.StringToHash(assetName);
     }
     else
     {
         assetName = o.name;
         assetHash = UMAUtils.StringToHash(assetName);
     }
 }
Ejemplo n.º 6
0
 public void AddOverlayWithNameAndColor(int slotIndex, OverlayDataAsset overlay, Color color)
 {
     if (slotIndex < 0)
     {
         return;
     }
     umaContext.overlayLibrary.AddOverlayAsset(overlay);
     umaDynamicAvatar.umaData.umaRecipe.slotDataList[slotIndex].AddOverlay(umaContext.overlayLibrary.InstantiateOverlay(overlay.overlayName, color));
 }
Ejemplo n.º 7
0
    public void SetOverlayColor(int slotIndex, OverlayDataAsset overlay, Color color)
    {
        if (slotIndex < 0)
        {
            return;
        }

        umaDynamicAvatar.umaData.umaRecipe.slotDataList[slotIndex].SetOverlayColor(color, new string[] { overlay.overlayName });
    }
Ejemplo n.º 8
0
        private OverlayDataAsset[] GetOverlayDataArray()
        {
            int arrayCount = m_OverlayDataCount.intValue;

            OverlayDataAsset[] OverlayDataArray = new OverlayDataAsset[arrayCount];

            for (int i = 0; i < arrayCount; i++)
            {
                OverlayDataArray[i] = m_Object.FindProperty(string.Format(kArrayData, i)).objectReferenceValue as OverlayDataAsset;
            }
            return(OverlayDataArray);
        }
        void DoDelayedSave()
        {
            OverlayDataAsset od = target as OverlayDataAsset;

            if (od.doSave && Time.realtimeSinceStartup > (od.lastActionTime + 0.5f))
            {
                od.doSave         = false;
                od.lastActionTime = Time.realtimeSinceStartup;
                EditorUtility.SetDirty(target);
                AssetDatabase.SaveAssets();
                UMAUpdateProcessor.UpdateOverlay(target as OverlayDataAsset);
            }
        }
Ejemplo n.º 10
0
    public OverlayDataAsset GetOverlay()
    {
        #region 创建
        EditorUmaMaterial uMaterial = EditorUmaMaterialFactory.Creat(Name);

        IObjectBase texture_diffuse = new ObjectBase(texturePath);
        (new CharacterTexture(texturePath)).Handle();
        Texture2D dif = texture_diffuse.Load <Texture2D>();

        OverlayEditor    oeditor = new OverlayEditor(Fold, dif, Name, uMaterial);
        OverlayDataAsset overlay = oeditor.CreatOverlay();
        #endregion
        return(overlay);
    }
Ejemplo n.º 11
0
        private OverlayDataAsset CreateOverlay(string path, SlotDataAsset sd)
        {
            OverlayDataAsset asset = ScriptableObject.CreateInstance <OverlayDataAsset>();

            asset.overlayName = slotName + "_Overlay";
            asset.material    = sd.material;
            AssetDatabase.CreateAsset(asset, path);
            AssetDatabase.SaveAssets();
            if (addToGlobalLibrary)
            {
                UMAAssetIndexer.Instance.EvilAddAsset(typeof(OverlayDataAsset), asset);
            }
            return(asset);
        }
Ejemplo n.º 12
0
    public OverlayDataAsset CreatOverlay()
    {
        string      fold        = string.Format("{0}/{1}/{2}", baseFold, PartName, UMAUtils.Slot);
        string      texturePath = string.Format("{0}/{1}/{2}/{3}_{4}.png", CharacterConst.rootPath, resType.ToString(), gameObject.name, gameObject.name, PartName);
        string      filename    = string.Format("{0}_{1}", gameObject.name, PartName);
        IObjectBase textureObj  = new ObjectBase(texturePath);
        Texture2D   t           = textureObj.Load <Texture2D>();

        (new CharacterTexture(texturePath)).Handle();

        OverlayEditor    oe  = new OverlayEditor(fold, t, filename, uMaterial);
        OverlayDataAsset oda = oe.CreatOverlay();

        return(oda);
    }
Ejemplo n.º 13
0
        private void CreateOverlay(string path, SlotDataAsset sd)
        {
            OverlayDataAsset asset = ScriptableObject.CreateInstance <OverlayDataAsset>();

            asset.overlayName = slotName + "_Overlay";
            asset.material    = sd.material;
            AssetDatabase.CreateAsset(asset, path);
            AssetDatabase.SaveAssets();
            if (addToGlobalLibrary)
            {
                UMAAssetIndexer.Instance.EvilAddAsset(typeof(OverlayDataAsset), asset);
            }
            if (addToLocalLibrary && UMAContext.Instance != null)
            {
                if (UMAContext.Instance.overlayLibrary != null)
                {
                    UMAContext.Instance.overlayLibrary.AddOverlayAsset(asset);
                }
            }
        }
Ejemplo n.º 14
0
        private void DropAreaGUI(Rect dropArea)
        {
            var evt = Event.current;

            if (evt.type == EventType.DragUpdated)
            {
                if (dropArea.Contains(evt.mousePosition))
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                }
            }

            if (evt.type == EventType.DragPerform)
            {
                if (dropArea.Contains(evt.mousePosition))
                {
                    DragAndDrop.AcceptDrag();
                    UnityEngine.Object[] draggedObjects = DragAndDrop.objectReferences;
                    for (int i = 0; i < draggedObjects.Length; i++)
                    {
                        if (draggedObjects[i])
                        {
                            OverlayDataAsset tempOverlayData = draggedObjects[i] as OverlayDataAsset;
                            if (tempOverlayData)
                            {
                                AddOverlayData(tempOverlayData);
                                continue;
                            }
                            var path = AssetDatabase.GetAssetPath(draggedObjects[i]);
                            if (System.IO.Directory.Exists(path))
                            {
                                RecursiveScanFoldersForAssets(path);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 15
0
        static void InitializeUMA()
        {//Initialize UMA context
         // UMA
            GameObject uma = new GameObject();

            uma.name = "UMA";
            GameObject parent;

            if (parent = Selection.activeGameObject)
            {
                uma.transform.SetParent(parent.transform);
            }

            // Race Library
            GameObject races = new GameObject();

            races.name = "RaceLibrary";
            races.transform.SetParent(uma.transform);
            RaceLibrary raceLibrary = races.AddComponent <RaceLibrary>();

            //null search in all assets folder, t means type, so we are searching Uma.RaceData
            string[] racesData = AssetDatabase.FindAssets("t: RaceData", null);
            foreach (string data in racesData)
            {
                //get the path
                string   racePath  = AssetDatabase.GUIDToAssetPath(data);
                RaceData raceAsset = AssetDatabase.LoadAssetAtPath <RaceData>(racePath);
                raceLibrary.AddRace(raceAsset);
            }

            // Slots
            GameObject slots = new GameObject();

            slots.name = "SlotLibrary";
            slots.transform.SetParent(uma.transform);

            SlotLibrary slotLibrary = slots.AddComponent <SlotLibrary>();

            //null search in all assets folder, t means type, so we are searching Uma.RaceData
            string[] slotsData = AssetDatabase.FindAssets("t: SlotDataAsset", null);
            foreach (string data in slotsData)
            {
                //get the path
                string        slotPath  = AssetDatabase.GUIDToAssetPath(data);
                SlotDataAsset slotAsset = AssetDatabase.LoadAssetAtPath <SlotDataAsset>(slotPath);
                slotLibrary.AddSlotAsset(slotAsset);
            }

            // Overlays
            GameObject overlays = new GameObject();

            overlays.name = "OverlayLibrary";
            overlays.transform.SetParent(uma.transform);

            OverlayLibrary overlayLibrary = overlays.AddComponent <OverlayLibrary>();

            //null search in all assets folder, t means type, so we are searching Uma.RaceData
            string[] overlaysData = AssetDatabase.FindAssets("t: OverlayDataAsset", null);
            foreach (string data in overlaysData)
            {
                //get the path
                string           overlayPath  = AssetDatabase.GUIDToAssetPath(data);
                OverlayDataAsset overlayAsset = AssetDatabase.LoadAssetAtPath <OverlayDataAsset>(overlayPath);
                overlayLibrary.AddOverlayAsset(overlayAsset);
            }

            // Context
            GameObject context = new GameObject();

            context.name = "ContextLibrary";
            context.transform.SetParent(uma.transform);

            UMAContext umaContext = context.AddComponent <UMAContext>();

            umaContext.raceLibrary    = raceLibrary;
            umaContext.slotLibrary    = slotLibrary;
            umaContext.overlayLibrary = overlayLibrary;

            // Generators
            UMAGenerator generator = MonoBehaviour.Instantiate <UMAGenerator>
                                         (AssetDatabase.LoadAssetAtPath <UMAGenerator>(CommonNames.umaFolderGeneratorPrefabPath));

            generator.name = "UMAGenerator";
            generator.transform.SetParent(uma.transform);

            UMADefaultMeshCombiner meshCombiner = generator.gameObject.AddComponent <UMADefaultMeshCombiner>();

            generator.meshCombiner = meshCombiner;

            //Mixers for random UMA creation
            //Male
            GameObject maleRecipeMixer = new GameObject();

            maleRecipeMixer.name = "MaleRecipeMixer";
            UMA.Examples.UMARecipeMixer maleRecipeMixerScript = maleRecipeMixer.AddComponent <UMA.Examples.UMARecipeMixer>();
            maleRecipeMixerScript.raceData = raceLibrary.GetRace("HumanMale");

            UMA.Examples.UMARecipeMixer.RecipeSection[] maleRecipeSection = new UMA.Examples.UMARecipeMixer.RecipeSection[3];

            //Male Recipe Section : Body
            maleRecipeSection[0]               = new UMA.Examples.UMARecipeMixer.RecipeSection();
            maleRecipeSection[0].name          = "Body";
            maleRecipeSection[0].selectionRule = UMA.Examples.UMARecipeMixer.SelectionType.IncludeOne;
            maleRecipeSection[0].recipes       = new UMARecipeBase[2];
            string[] maleBodyRecipePath = AssetDatabase.FindAssets("MaleBase t: UMATextRecipe", null);
            maleRecipeSection[0].recipes[0] = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(maleBodyRecipePath[0]));
            string[] maleBody2RecipePath = AssetDatabase.FindAssets("MaleBase2 t: UMATextRecipe", null);
            maleRecipeSection[0].recipes[1] = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(maleBody2RecipePath[0]));

            //Male Recipe Section : Underwear
            maleRecipeSection[1]               = new UMA.Examples.UMARecipeMixer.RecipeSection();
            maleRecipeSection[1].name          = "Clothing";
            maleRecipeSection[1].selectionRule = UMA.Examples.UMARecipeMixer.SelectionType.IncludeOne;
            maleRecipeSection[1].recipes       = new UMARecipeBase[1];
            //string[] maleUnderwearRecipePath = AssetDatabase.FindAssets("MaleUnderwear t: UMATextRecipe", null);
            //maleRecipeSection[1].recipes[0] = AssetDatabase.LoadAssetAtPath<UMATextRecipe>(AssetDatabase.GUIDToAssetPath(maleUnderwearRecipePath[0]));
            string[] maleOutfit1RecipePath = AssetDatabase.FindAssets("MaleOutfit1 t: UMATextRecipe", null);
            foreach (string hairPath in maleOutfit1RecipePath)
            {
                UMATextRecipe umaTextRecipe = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(hairPath));
                if (umaTextRecipe.name == "MaleOutfit1")
                {
                    maleRecipeSection[1].recipes[0] = umaTextRecipe;
                }
            }

            //Male Recipe Section : Hair
            maleRecipeSection[2]               = new UMA.Examples.UMARecipeMixer.RecipeSection();
            maleRecipeSection[2].name          = "Hair";
            maleRecipeSection[2].selectionRule = UMA.Examples.UMARecipeMixer.SelectionType.IncludeSome;
            maleRecipeSection[2].recipes       = new UMARecipeBase[2];
            string[] maleBeardRecipePath = AssetDatabase.FindAssets("MaleBeard t: UMATextRecipe", null);
            foreach (string hairPath in maleBeardRecipePath)
            {
                UMATextRecipe umaTextRecipe = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(hairPath));
                if (umaTextRecipe.name == "MaleBeard")
                {
                    maleRecipeSection[2].recipes[0] = umaTextRecipe;
                }
            }
            string[] maleHairRecipePath = AssetDatabase.FindAssets("MaleHair t: UMATextRecipe", null);
            foreach (string hairPath in maleHairRecipePath)
            {
                UMATextRecipe umaTextRecipe = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(hairPath));
                if (umaTextRecipe.name == "MaleHair")
                {
                    maleRecipeSection[2].recipes[1] = umaTextRecipe;
                }
            }

            maleRecipeMixerScript.recipeSections = maleRecipeSection;

            maleRecipeMixer.GetComponent <Transform>().SetParent(uma.transform);

            //Female
            GameObject femaleRecipeMixer = new GameObject();

            femaleRecipeMixer.name = "FemaleRecipeMixer";
            UMA.Examples.UMARecipeMixer femaleRecipeMixerScript = femaleRecipeMixer.AddComponent <UMA.Examples.UMARecipeMixer>();
            femaleRecipeMixerScript.raceData = raceLibrary.GetRace("HumanFemale");
            UMA.Examples.UMARecipeMixer.RecipeSection[] femaleRecipeSection = new UMA.Examples.UMARecipeMixer.RecipeSection[3];

            //Female Recipe Section : Body
            femaleRecipeSection[0]               = new UMA.Examples.UMARecipeMixer.RecipeSection();
            femaleRecipeSection[0].name          = "Body";
            femaleRecipeSection[0].selectionRule = UMA.Examples.UMARecipeMixer.SelectionType.IncludeOne;
            femaleRecipeSection[0].recipes       = new UMARecipeBase[1];
            string[] femaleBodyRecipePath = AssetDatabase.FindAssets("HumanFemale Base Recipe t: UMATextRecipe", null);
            femaleRecipeSection[0].recipes[0] = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(femaleBodyRecipePath[0]));

            //Female Recipe Section : Underwear
            femaleRecipeSection[1]               = new UMA.Examples.UMARecipeMixer.RecipeSection();
            femaleRecipeSection[1].name          = "Clothing";
            femaleRecipeSection[1].selectionRule = UMA.Examples.UMARecipeMixer.SelectionType.IncludeOne;
            femaleRecipeSection[1].recipes       = new UMARecipeBase[2];
            //string[] femaleUnderwearRecipePath = AssetDatabase.FindAssets("FemaleUnderwear t: UMATextRecipe", null);
            string[] femaleOutfit1RecipePath = AssetDatabase.FindAssets("FemaleOutfit1 t: UMATextRecipe", null);
            string[] femaleOutfit2RecipePath = AssetDatabase.FindAssets("FemaleOutfit2 t: UMATextRecipe", null);
            //femaleRecipeSection[1].recipes[0] = AssetDatabase.LoadAssetAtPath<UMATextRecipe>(AssetDatabase.GUIDToAssetPath(femaleUnderwearRecipePath[0]));
            femaleRecipeSection[1].recipes[0] = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(femaleOutfit1RecipePath[0]));
            femaleRecipeSection[1].recipes[1] = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(femaleOutfit2RecipePath[0]));

            //Female Recipe Section : Hair
            femaleRecipeSection[2]               = new UMA.Examples.UMARecipeMixer.RecipeSection();
            femaleRecipeSection[2].name          = "Hair";
            femaleRecipeSection[2].selectionRule = UMA.Examples.UMARecipeMixer.SelectionType.IncludeOne;
            femaleRecipeSection[2].recipes       = new UMARecipeBase[3];
            string[] femaleHairRecipePath      = AssetDatabase.FindAssets("FemaleHair t: UMATextRecipe", null);
            string[] femaleHairLongRecipePath  = AssetDatabase.FindAssets("FemaleHairLong t: UMATextRecipe", null);
            string[] femaleHairShortRecipePath = AssetDatabase.FindAssets("FemaleHairShort t: UMATextRecipe", null);

            foreach (string hairPath in femaleHairRecipePath)
            {
                UMATextRecipe umaTextRecipe = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(hairPath));
                if (umaTextRecipe.name == "FemaleHair")
                {
                    femaleRecipeSection[2].recipes[0] = umaTextRecipe;
                }
            }

            femaleRecipeSection[2].recipes[1] = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(femaleHairLongRecipePath[0]));
            femaleRecipeSection[2].recipes[2] = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(femaleHairShortRecipePath[0]));

            femaleRecipeMixerScript.recipeSections = femaleRecipeSection;

            femaleRecipeMixer.GetComponent <Transform>().SetParent(uma.transform);

            //Shared colors table
            GameObject recipeMixerController = new GameObject();

            recipeMixerController.name = "RecipeMixerController";
            RecipeMixerController recipeMixerControllerScript = recipeMixerController.AddComponent <RecipeMixerController>();

            SharedColorTable[] sharedColorTable = recipeMixerControllerScript.sharedColors;

            string[][] sharedColorsPath = new string[5][];
            sharedColorsPath[0] = AssetDatabase.FindAssets("HumanHairLinear", null);
            sharedColorsPath[1] = AssetDatabase.FindAssets("HumanSkinLinear", null);
            sharedColorsPath[2] = AssetDatabase.FindAssets("ClothingUnderwear", null);
            sharedColorsPath[3] = AssetDatabase.FindAssets("ClothingTops", null);
            sharedColorsPath[4] = AssetDatabase.FindAssets("ClothingBottoms", null);

            sharedColorTable[0] = AssetDatabase.LoadAssetAtPath <SharedColorTable>(AssetDatabase.GUIDToAssetPath(sharedColorsPath[0][0]));
            sharedColorTable[1] = AssetDatabase.LoadAssetAtPath <SharedColorTable>(AssetDatabase.GUIDToAssetPath(sharedColorsPath[1][0]));
            sharedColorTable[2] = AssetDatabase.LoadAssetAtPath <SharedColorTable>(AssetDatabase.GUIDToAssetPath(sharedColorsPath[2][0]));
            sharedColorTable[3] = AssetDatabase.LoadAssetAtPath <SharedColorTable>(AssetDatabase.GUIDToAssetPath(sharedColorsPath[3][0]));
            sharedColorTable[4] = AssetDatabase.LoadAssetAtPath <SharedColorTable>(AssetDatabase.GUIDToAssetPath(sharedColorsPath[4][0]));

            recipeMixerController.transform.SetParent(uma.transform);
        }
Ejemplo n.º 16
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
                        //FIXED as of Unity5.6.2f1
#if UNITY_5_5 || UNITY_5_6_0 || UNITY_5_6_1
                        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>();
                                }
                            }
                        }
#endif
                        RaceData actualRace = loadedBundleAB.LoadAsset <RaceData>(itemFilename);
                        UMAContext.Instance.raceLibrary.AddRace(actualRace);
                        UMAContext.Instance.raceLibrary.UpdateDictionary();
                        //Refresh DCS so that anything that this race is cross compatible with gets added to its list of available recipes
                        (UMAContext.Instance.dynamicCharacterSystem as DynamicCharacterSystem).RefreshRaceKeys();
                    }
                    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 DynamicCharacterSystem).AddRecipe(downloadedRecipe);
                    }
                    else if (assetType == typeof(UMAWardrobeRecipe))
                    {
                        UMAWardrobeRecipe downloadedRecipe = loadedBundleAB.LoadAsset <UMAWardrobeRecipe>(itemFilename);
                        (UMAContext.Instance.dynamicCharacterSystem as 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;
        }
Ejemplo n.º 17
0
        void OnGUI()
        {
            GUILayout.Label("UMA Slot Builder");
            GUILayout.Space(20);
            normalReferenceMesh = EditorGUILayout.ObjectField("Seams Mesh (Optional)  ", normalReferenceMesh, typeof(SkinnedMeshRenderer), false) as SkinnedMeshRenderer;
            slotMesh            = EditorGUILayout.ObjectField("Slot Mesh  ", slotMesh, typeof(SkinnedMeshRenderer), false) as SkinnedMeshRenderer;
            slotMaterial        = EditorGUILayout.ObjectField("UMAMaterial	 ", slotMaterial, typeof(UMAMaterial), false) as UMAMaterial;
            slotFolder          = EditorGUILayout.ObjectField("Slot Destination Folder", slotFolder, typeof(UnityEngine.Object), false) as UnityEngine.Object;
            EnforceFolder(ref slotFolder);
            RootBone            = EditorGUILayout.TextField("Root Bone (ex:'Global')", RootBone);
            slotName            = EditorGUILayout.TextField("Slot Name", slotName);
            binarySerialization = EditorGUILayout.Toggle(new GUIContent("Binary Serialization", "Forces the created Mesh object to be serialized as binary. Recommended for large meshes and blendshapes."), binarySerialization);

            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            EditorGUILayout.BeginHorizontal();
            createOverlay = EditorGUILayout.Toggle("Create Overlay", createOverlay);
            EditorGUILayout.LabelField(slotName + "_Overlay");
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            createRecipe = EditorGUILayout.Toggle("Create Wardrobe Recipe ", createRecipe);
            EditorGUILayout.LabelField(slotName + "_Recipe");
            EditorGUILayout.EndHorizontal();
            addToGlobalLibrary = EditorGUILayout.Toggle("Add To Global Library", addToGlobalLibrary);
            if (UMAContext.Instance != null)
            {
                if (UMAContext.Instance.slotLibrary != null)
                {
                    addToLocalLibrary = EditorGUILayout.Toggle("Add to Scene Library", addToLocalLibrary);
                }
            }

            if (GUILayout.Button("Create Slot"))
            {
                Debug.Log("Processing...");
                SlotDataAsset sd = CreateSlot();
                if (sd != null)
                {
                    Debug.Log("Success.");
                    string AssetPath = AssetDatabase.GetAssetPath(sd.GetInstanceID());
                    if (addToGlobalLibrary)
                    {
                        UMAAssetIndexer.Instance.EvilAddAsset(typeof(SlotDataAsset), sd);
                    }
                    if (addToLocalLibrary && UMAContext.Instance != null)
                    {
                        if (UMAContext.Instance.slotLibrary != null)
                        {
                            UMAContext.Instance.slotLibrary.AddSlotAsset(sd);
                        }
                    }
                    OverlayDataAsset od = null;
                    if (createOverlay)
                    {
                        od = CreateOverlay(AssetPath.Replace(sd.name, sd.slotName + "_Overlay"), sd);
                    }
                    if (createRecipe)
                    {
                        CreateRecipe(AssetPath.Replace(sd.name, sd.slotName + "_Recipe"), sd, od);
                    }
                }
            }


            if (slotMesh != null)
            {
                if (slotMesh.localBounds.size.x > 10.0f || slotMesh.localBounds.size.y > 10.0f || slotMesh.localBounds.size.z > 10.0f)
                {
                    EditorGUILayout.HelpBox("This slot's size is very large. It's import scale may be incorrect!", MessageType.Warning);
                }

                if (slotMesh.localBounds.size.x < 0.01f || slotMesh.localBounds.size.y < 0.01f || slotMesh.localBounds.size.z < 0.01f)
                {
                    EditorGUILayout.HelpBox("This slot's size is very small. It's import scale may be incorrect!", MessageType.Warning);
                }

                if (slotName == null || slotName == "")
                {
                    slotName = slotMesh.name;
                }
                if (RootBone == null || RootBone == "")
                {
                    RootBone = "Global";
                }
            }

            GUILayout.Label("", EditorStyles.boldLabel);
            Rect dropArea = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true));

            GUI.Box(dropArea, "Drag meshes here");
            GUILayout.Label("Automatic Drag and Drop processing", EditorStyles.boldLabel);
            relativeFolder = EditorGUILayout.ObjectField("Relative Folder", relativeFolder, typeof(UnityEngine.Object), false) as UnityEngine.Object;
            EnforceFolder(ref relativeFolder);

            DropAreaGUI(dropArea);
        }
        public override void OnInspectorGUI()
        {
            OverlayDataAsset od = target as OverlayDataAsset;

            if (od.lastActionTime == 0)
            {
                od.lastActionTime = Time.realtimeSinceStartup;
            }

            serializedObject.Update();

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(_overlayName);
            EditorGUILayout.PropertyField(_overlayType);
            EditorGUILayout.PropertyField(_rect);
            EditorGUILayout.LabelField("Note: It is recommended to use UV coordinates (0.0 -> 1.0) in 2.10+ for rect fields.", EditorStyles.helpBox);

            EditorGUILayout.PropertyField(_umaMaterial);

            if (_umaMaterial != null && _umaMaterial.objectReferenceValue != null)
            {
                int textureChannelCount  = 0;
                SerializedObject tempObj = new SerializedObject(_umaMaterial.objectReferenceValue);
                _channels = tempObj.FindProperty("channels");

                if (_channels == null)
                {
                    EditorGUILayout.HelpBox("Channels not found!", MessageType.Error);
                }
                else
                {
                    textureChannelCount = _channels.arraySize;
                }

                od.textureFoldout = GUIHelper.FoldoutBar(od.textureFoldout, "Texture Channels");

                if (od.textureFoldout)
                {
                    GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.875f, 1f));
                    EditorGUILayout.PropertyField(_textureList.FindPropertyRelative("Array.size"));
                    for (int i = 0; i < _textureList.arraySize; i++)
                    {
                        SerializedProperty textureElement = _textureList.GetArrayElementAtIndex(i);
                        string             materialName   = "Unknown";

                        if (i < _channels.arraySize)
                        {
                            SerializedProperty channel = _channels.GetArrayElementAtIndex(i);
                            if (channel != null)
                            {
                                SerializedProperty materialPropertyName = channel.FindPropertyRelative("materialPropertyName");
                                if (materialPropertyName != null)
                                {
                                    materialName = materialPropertyName.stringValue;
                                }
                            }
                        }

                        EditorGUILayout.PropertyField(textureElement, new GUIContent(materialName));
                    }
                    GUIHelper.EndVerticalPadded(10);
                }

                if (_textureList.arraySize != textureChannelCount)
                {
                    EditorGUILayout.HelpBox("Overlay Texture count and UMA Material channel count don't match!", MessageType.Error);
                }

                if (!_textureList.hasMultipleDifferentValues)
                {
                    bool allValid = true;
                    for (int i = 0; i < _textureList.arraySize; i++)
                    {
                        if (_textureList.GetArrayElementAtIndex(i).objectReferenceValue == null)
                        {
                            allValid = false;
                        }
                    }
                    if (!allValid)
                    {
                        EditorGUILayout.HelpBox("Not all textures in Texture List set. This overlay will only work as an additional overlay in a recipe", MessageType.Warning);
                    }
                }
            }
            else
            {
                EditorGUILayout.HelpBox("No UMA Material selected!", MessageType.Warning);
            }

            GUILayout.Space(20f);
            od.additionalFoldout = GUIHelper.FoldoutBar(od.additionalFoldout, "Additional Parameters");
            if (od.additionalFoldout)
            {
                GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.875f, 1f));
                EditorGUILayout.PropertyField(_alphaMask);
                EditorGUILayout.PropertyField(_tags, true);
                EditorGUILayout.PropertyField(_occlusionEntries, true);
                GUIHelper.EndVerticalPadded(10);
            }

            serializedObject.ApplyModifiedProperties();
            if (EditorGUI.EndChangeCheck())
            {
                od.lastActionTime = Time.realtimeSinceStartup;
                od.doSave         = true;
            }
        }
Ejemplo n.º 19
0
    public List <SlotOverlayItem> CreatData()
    {
        List <SlotOverlayItem> sos = new List <SlotOverlayItem>();
        int    submeshIndex        = 0;
        bool   first         = false;
        string firstSlotPath = null;

        for (int i = 0; i < sharedMaterials.Count; i++)
        {
            SlotOverlayItem item         = new SlotOverlayItem();
            string          materialName = sharedMaterials[i];
            string          name         = baseName + "-" + i;
            if (!first)
            {
                #region slot
                SlotEditor    so        = new SlotEditor(slotMesh, name, slotFold, Mat);
                SlotDataAsset firstSlot = so.Creat();
                item.slot     = firstSlot;
                firstSlotPath = string.Format("{0}/{1}_{2}.asset", PathHelper.GetRelativeAssetPath(slotFold), name, UMAUtils.Slot);
                #endregion

                first = true;
            }
            else
            {
                #region slot
                string target = string.Format("{0}/{1}_{2}.asset", PathHelper.GetRelativeAssetPath(slotFold), name, UMAUtils.Slot);
                FileUtil.CopyFileOrDirectory(firstSlotPath, target);

                AssetDatabase.Refresh();

                ObjectBase    obj     = new ObjectBase(target);
                SlotDataAsset slotSub = obj.Load <SlotDataAsset>();
                slotSub.subMeshIndex = i;
                item.slot            = slotSub;
                #endregion
            }

            #region overlay
            OverlayEditor oe = null;
            if (materialName.EndsWith(CharacterConst.Common))
            {
                oe = new OverlayEditor(overlayFold, comTexture, name, Mat);
            }
            else
            {
                oe = new OverlayEditor(overlayFold, diff, name, Mat);
            }

            OverlayDataAsset overlay = oe.CreatOverlay();
            item.overlay = overlay;
            #endregion

            #region index
            item.partIndex = wearpos * 10 + i;
            #endregion

            sos.Add(item);
        }


        return(sos);
    }
Ejemplo n.º 20
0
 private void SetOverlayData(int index, OverlayDataAsset overlayElement)
 {
     m_Object.FindProperty(string.Format(kArrayData, index)).objectReferenceValue = overlayElement;
     isDirty = true;
 }
Ejemplo n.º 21
0
        void OnGUI()
        {
            GUILayout.Label("UMA Slot Builder");
            GUILayout.Space(20);
            normalReferenceMesh = EditorGUILayout.ObjectField("Seams Mesh (Optional)  ", normalReferenceMesh, typeof(SkinnedMeshRenderer), false) as SkinnedMeshRenderer;
            var newslotMesh = EditorGUILayout.ObjectField("Slot Mesh  ", slotMesh, typeof(SkinnedMeshRenderer), false) as SkinnedMeshRenderer;

            if (newslotMesh != slotMesh)
            {
                errmsg   = "";
                slotMesh = newslotMesh;
            }


            slotMaterial = EditorGUILayout.ObjectField("UMAMaterial	 ", slotMaterial, typeof(UMAMaterial), false) as UMAMaterial;
            slotFolder   = EditorGUILayout.ObjectField("Slot Destination Folder", slotFolder, typeof(UnityEngine.Object), false) as UnityEngine.Object;
            EnforceFolder(ref slotFolder);
            //
            // For now, we will disable this option.
            // It doesn't work in most cases.
            // RootBone = EditorGUILayout.TextField("Root Bone (ex:'Global')", RootBone);
            //
            slotName            = EditorGUILayout.TextField("Slot Name", slotName);
            binarySerialization = EditorGUILayout.Toggle(new GUIContent("Binary Serialization", "Forces the created Mesh object to be serialized as binary. Recommended for large meshes and blendshapes."), binarySerialization);

            GUILayout.BeginHorizontal(EditorStyles.toolbarButton);
            GUILayout.Space(10);
            showTags = EditorGUILayout.Foldout(showTags, "Tags");
            GUILayout.EndHorizontal();
            if (showTags)
            {
                GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.875f, 1f));
                // Draw the button area
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Add Tag", GUILayout.Width(80)))
                {
                    Tags.Add("");
                    Repaint();
                }

                GUILayout.Label(Tags.Count + " Tags defined");
                GUILayout.EndHorizontal();

                if (Tags.Count == 0)
                {
                    GUILayout.Label("No tags defined", EditorStyles.helpBox);
                }
                else
                {
                    int del = -1;

                    for (int i = 0; i < Tags.Count; i++)
                    {
                        GUILayout.BeginHorizontal();
                        Tags[i] = GUILayout.TextField(Tags[i]);
                        if (GUILayout.Button("\u0078", EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                        {
                            del = i;
                        }
                        GUILayout.EndHorizontal();
                    }
                    if (del >= 0)
                    {
                        Tags.RemoveAt(del);
                        Repaint();
                    }
                }
                // Draw the tags (or "No tags defined");
                GUIHelper.EndVerticalPadded(10);
            }

            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            EditorGUILayout.BeginHorizontal();
            createOverlay = EditorGUILayout.Toggle("Create Overlay", createOverlay);
            EditorGUILayout.LabelField(slotName + "_Overlay");
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            createRecipe = EditorGUILayout.Toggle("Create Wardrobe Recipe ", createRecipe);
            EditorGUILayout.LabelField(slotName + "_Recipe");
            EditorGUILayout.EndHorizontal();
            addToGlobalLibrary = EditorGUILayout.Toggle("Add To Global Library", addToGlobalLibrary);

            if (GUILayout.Button("Verify Slot"))
            {
                if (slotMesh == null)
                {
                    errmsg = "Slot is null.";
                }
                else
                {
                    Vector2[] uv = slotMesh.sharedMesh.uv;
                    foreach (Vector2 v in uv)
                    {
                        if (v.x > 1.0f || v.x < 0.0f || v.y > 1.0f || v.y < 0.0f)
                        {
                            errmsg = "UV Coordinates are out of range and will likely have issues with atlassed materials. Textures should not be tiled unless using non-atlassed materials.";
                            break;
                        }
                    }
                    if (string.IsNullOrEmpty(errmsg))
                    {
                        errmsg = "No errors found";
                    }
                }
            }

            if (!string.IsNullOrEmpty(errmsg))
            {
                EditorGUILayout.HelpBox(errmsg, MessageType.Warning);
            }

            if (GUILayout.Button("Create Slot"))
            {
                Debug.Log("Processing...");
                SlotDataAsset sd = CreateSlot();
                if (sd != null)
                {
                    Debug.Log("Success.");
                    string AssetPath = AssetDatabase.GetAssetPath(sd.GetInstanceID());
                    if (addToGlobalLibrary)
                    {
                        UMAAssetIndexer.Instance.EvilAddAsset(typeof(SlotDataAsset), sd);
                    }
                    OverlayDataAsset od = null;
                    if (createOverlay)
                    {
                        od = CreateOverlay(AssetPath.Replace(sd.name, sd.slotName + "_Overlay"), sd);
                    }
                    if (createRecipe)
                    {
                        CreateRecipe(AssetPath.Replace(sd.name, sd.slotName + "_Recipe"), sd, od);
                    }
                }
            }


            if (slotMesh != null)
            {
                if (slotMesh.localBounds.size.x > 10.0f || slotMesh.localBounds.size.y > 10.0f || slotMesh.localBounds.size.z > 10.0f)
                {
                    EditorGUILayout.HelpBox("This slot's size is very large. It's import scale may be incorrect!", MessageType.Warning);
                }

                if (slotMesh.localBounds.size.x < 0.01f || slotMesh.localBounds.size.y < 0.01f || slotMesh.localBounds.size.z < 0.01f)
                {
                    EditorGUILayout.HelpBox("This slot's size is very small. It's import scale may be incorrect!", MessageType.Warning);
                }

                if (slotName == null || slotName == "")
                {
                    slotName = slotMesh.name;
                }
                if (RootBone == null || RootBone == "")
                {
                    RootBone = "Global";
                }
            }

            GUILayout.Label("", EditorStyles.boldLabel);
            Rect dropArea = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true));

            GUI.Box(dropArea, "Drag meshes here");
            GUILayout.Label("Automatic Drag and Drop processing", EditorStyles.boldLabel);
            relativeFolder = EditorGUILayout.ObjectField("Relative Folder", relativeFolder, typeof(UnityEngine.Object), false) as UnityEngine.Object;
            EnforceFolder(ref relativeFolder);

            DropAreaGUI(dropArea);
        }
Ejemplo n.º 22
0
 private void AddOverlayData(OverlayDataAsset overlayElement)
 {
     m_OverlayDataCount.intValue++;
     SetOverlayData(m_OverlayDataCount.intValue - 1, overlayElement);
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Add an overlay asset to the library.
 /// </summary>
 /// <param name="overlay">Overlay.</param>
 public abstract void AddOverlayAsset(OverlayDataAsset overlay);
Ejemplo n.º 24
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;
        }
Ejemplo n.º 25
0
 private void CreateRecipe(string path, SlotDataAsset sd, OverlayDataAsset od)
 {
     UMAEditorUtilities.CreateRecipe(path, sd, od, sd.name, addToGlobalLibrary);
 }