예제 #1
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);
    }
예제 #2
0
        void CharacterBegun(UMAData umaData)
        {
            if (!RenderersEnabled)
            {
                return;
            }
            //If mesh is not dirty then we haven't changed slots.
            if (!umaData.isMeshDirty)
            {
                return;
            }

            SlotData[] slots = umaData.umaRecipe.slotDataList;
            slotsToAdd.Clear();

            foreach (RendererElement element in RendererElements)
            {
                if (element.rendererAssets == null || element.rendererAssets.Count <= 0)
                {
                    continue;
                }

                wardrobeSlotAssets.Clear();

                //First, lets collect a list of the slotDataAssets that are present in the wardrobe recipes of the wardrobe slots we've specified
                foreach (string wardrobeSlot in element.wardrobeSlots)
                {
                    UMATextRecipe recipe = avatar.GetWardrobeItem(wardrobeSlot);
                    if (recipe != null)
                    {
                        recipe.Load(umaRecipe, context);

                        if (umaRecipe.slotDataList != null)
                        {
                            for (int i = 0; i < umaRecipe.slotDataList.Length; i++)
                            {
                                SlotData slotData = umaRecipe.slotDataList[i];
                                if (slotData != null && slotData.asset != null)
                                {
                                    wardrobeSlotAssets.Add(slotData.asset);
                                }
                            }
                        }
                    }
                }

                //Next, check each slot for if they are in the list of specified slots or exist in one of the wardrobe recipes of the wardrobe slot we specified.
                foreach (SlotData slot in slots)
                {
                    // if (element.slotAssets.Contains(slot.asset) || wardrobeSlotAssets.Contains(slot.asset))
                    if (HasSlot(element.slotAssets, slot.slotName) || HasSlot(wardrobeSlotAssets, slot.slotName))
                    {
                        //We check for at least one rendererAsset at the top level for loop.
                        //Set our existing slot to the first renderer in our renderer list.
                        slot.rendererAsset = element.rendererAssets[0];

                        //If we have more renderers then make a copy of the SlotData and set that copy's rendererAsset to this item's renderer.
                        //Add the newly created slots to a running list to combine back with the entire slot list at the end.
                        for (int i = 1; i < element.rendererAssets.Count; i++)
                        {
                            SlotData addSlot = slot.Copy();
                            addSlot.rendererAsset = element.rendererAssets[i];
                            slotsToAdd.Add(addSlot);
                        }
                    }
                }
            }

            //If we have added Slots, then add the first slots to the list and set the recipe's slots to the new combined list.
            if (slotsToAdd.Count > 0)
            {
                slotsToAdd.AddRange(slots);
                umaData.umaRecipe.SetSlots(slotsToAdd.ToArray());
                slotsToAdd.Clear();
            }

            wardrobeSlotAssets.Clear();
        }