Ejemplo n.º 1
0
        /// <summary>
        /// Fills in a UMA recipe with random partial fragments from the sections.
        /// </summary>
        /// <param name="umaRecipe">UMA recipe.</param>
        /// <param name="context">Context.</param>
        public void FillUMARecipe(UMAData.UMARecipe umaRecipe, UMAContextBase context)
        {
            if (raceData == null)
            {
                Debug.LogWarning("Race Data must be set!");
                return;
            }
            umaRecipe.SetRace(raceData);

            int sectionCount = (recipeSections == null) ? 0 : recipeSections.Length;

            for (int i = 0; i < sectionCount; i++)
            {
                RecipeSection section = recipeSections[i];
                if ((section.recipes == null) || (section.recipes.Length == 0))
                {
                    continue;
                }

                switch (section.selectionRule)
                {
                case SelectionType.IncludeNone:
                    break;

                case SelectionType.IncludeAll:
                    for (int j = 0; j < section.recipes.Length; j++)
                    {
                        IncludeRecipe(section.recipes[j], umaRecipe, context, false);
                    }
                    break;

                case SelectionType.IncludeSome:
                    float chance = 1f / (float)(section.recipes.Length + 1);
                    for (int j = 0; j < section.recipes.Length; j++)
                    {
                        if (Random.value < chance)
                        {
                            IncludeRecipe(section.recipes[j], umaRecipe, context, false);
                        }
                    }
                    break;

                case SelectionType.IncludeOne:
                default:
                    int index = Random.Range(0, section.recipes.Length);
                    IncludeRecipe(section.recipes[index], umaRecipe, context, false);
                    break;
                }
            }

            for (int i = 0; i < additionalRecipes.Length; i++)
            {
                IncludeRecipe(additionalRecipes[i], umaRecipe, context, true);
            }
        }
Ejemplo n.º 2
0
    UMAData.UMARecipe CreateMaleRecipe()
    {
        var recipe = new UMAData.UMARecipe();

        recipe.slotDataList = new SlotData[numberOfSlots];
        recipe.AddDna(umaDna);
        recipe.AddDna(umaTutorialDna);

        recipe.SetRace(raceLibrary.GetRace("HumanMale"));

        SlotData eyes = slotLibrary.InstantiateSlot("MaleEyes");

        eyes.AddOverlay(overlayLibrary.InstantiateOverlay("EyeOverlay"));
        recipe.slotDataList[0] = eyes;

        SlotData mouth = slotLibrary.InstantiateSlot("MaleInnerMouth");

        mouth.AddOverlay(overlayLibrary.InstantiateOverlay("InnerMouth"));
        recipe.slotDataList[1] = mouth;

        recipe.slotDataList[2] = slotLibrary.InstantiateSlot("MaleFace", new List <OverlayData> {
            overlayLibrary.InstantiateOverlay("MaleHead02"),
            overlayLibrary.InstantiateOverlay("MaleEyebrow01", Color.black)
        });;

        SlotData torso = slotLibrary.InstantiateSlot("MaleTorso", new List <OverlayData> {
            overlayLibrary.InstantiateOverlay("MaleBody02"),
            overlayLibrary.InstantiateOverlay("MaleUnderwear01")
        });

        recipe.slotDataList[3] = torso;

        recipe.slotDataList[4] = slotLibrary.InstantiateSlot("MaleHands", torso.GetOverlayList());
        recipe.slotDataList[5] = slotLibrary.InstantiateSlot("MaleLegs", torso.GetOverlayList());
        recipe.slotDataList[6] = slotLibrary.InstantiateSlot("MaleFeet", torso.GetOverlayList());

        return(recipe);
    }
Ejemplo n.º 3
0
        public bool OnGUI(ref bool _dnaDirty, ref bool _textureDirty, ref bool _meshDirty)
        {
            bool changed = false;

            // Have to be able to assign a race on a new recipe.
            RaceData newRace = (RaceData)EditorGUILayout.ObjectField("RaceData", _recipe.raceData, typeof(RaceData), false);

            if (_recipe.raceData == null)
            {
                GUIHelper.BeginVerticalPadded(10, new Color(0.55f, 0.25f, 0.25f));
                GUILayout.Label("Warning: No race data is set!");
                GUIHelper.EndVerticalPadded(10);
            }


            if (_recipe.raceData != newRace)
            {
                _recipe.SetRace(newRace);
                changed = true;
            }

            if (GUILayout.Button("Remove Nulls"))
            {
                var newList = new List <SlotData>(_recipe.slotDataList.Length);
                foreach (var slotData in _recipe.slotDataList)
                {
                    if (slotData != null)
                    {
                        newList.Add(slotData);
                    }
                }
                _recipe.slotDataList = newList.ToArray();
                changed       |= true;
                _dnaDirty     |= true;
                _textureDirty |= true;
                _meshDirty    |= true;
            }

            if (_sharedColorsEditor.OnGUI(_recipe))
            {
                changed       = true;
                _textureDirty = true;
            }

            var added = (SlotDataAsset)EditorGUILayout.ObjectField("Add Slot", null, typeof(SlotDataAsset), false);

            if (added != null)
            {
                var slot = new SlotData(added);
                _recipe.MergeSlot(slot, false);
                changed       |= true;
                _dnaDirty     |= true;
                _textureDirty |= true;
                _meshDirty    |= true;
            }

            for (int i = 0; i < _slotEditors.Count; i++)
            {
                var editor = _slotEditors[i];

                if (editor == null)
                {
                    GUILayout.Label("Empty Slot");
                    continue;
                }

                changed |= editor.OnGUI(ref _dnaDirty, ref _textureDirty, ref _meshDirty);

                if (editor.Delete)
                {
                    _dnaDirty     = true;
                    _textureDirty = true;
                    _meshDirty    = true;

                    _slotEditors.RemoveAt(i);
                    _recipe.SetSlot(editor.idx, null);
                    i--;
                    changed = true;
                }
            }

            return(changed);
        }
Ejemplo n.º 4
0
    UMAData.UMARecipe CreateMaleRecipe()
    {
        var recipe = new UMAData.UMARecipe();
        recipe.slotDataList = new SlotData[numberOfSlots];
        recipe.AddDna(umaDna);
        recipe.AddDna(umaTutorialDna);

        recipe.SetRace(raceLibrary.GetRace("HumanMale"));

        SlotData eyes = slotLibrary.InstantiateSlot("MaleEyes");
        eyes.AddOverlay(overlayLibrary.InstantiateOverlay("EyeOverlay"));
        recipe.slotDataList[0] = eyes;

        SlotData mouth = slotLibrary.InstantiateSlot("MaleInnerMouth");
        mouth.AddOverlay(overlayLibrary.InstantiateOverlay("InnerMouth"));
        recipe.slotDataList[1] = mouth;

        recipe.slotDataList[2] = slotLibrary.InstantiateSlot("MaleFace", new List<OverlayData> {
            overlayLibrary.InstantiateOverlay("MaleHead02"),
            overlayLibrary.InstantiateOverlay("MaleEyebrow01", Color.black)
        });;

        SlotData torso = slotLibrary.InstantiateSlot("MaleTorso", new List<OverlayData> {
            overlayLibrary.InstantiateOverlay("MaleBody02"),
            overlayLibrary.InstantiateOverlay("MaleUnderwear01")
        });
        recipe.slotDataList[3] = torso;

        recipe.slotDataList[4] = slotLibrary.InstantiateSlot("MaleHands", torso.GetOverlayList());
        recipe.slotDataList[5] = slotLibrary.InstantiateSlot("MaleLegs", torso.GetOverlayList());
        recipe.slotDataList[6] = slotLibrary.InstantiateSlot("MaleFeet", torso.GetOverlayList());

        return recipe;
    }
Ejemplo n.º 5
0
    void GenerateOneUMA()
    {
        var umaRecipe = new UMAData.UMARecipe();
        int randomResult = Random.Range(0, 2);
        //		randomResult = 0;

        if(randomResult == 0)
        {
            umaRecipe.SetRace(raceLibrary.GetRace("HumanMale"));
        }else{
            umaRecipe.SetRace(raceLibrary.GetRace("HumanFemale"));
        }

        tempUMA = (Instantiate(umaRecipe.raceData.racePrefab ,Vector3.zero,Quaternion.identity) as GameObject).transform;

        umaData = tempUMA.gameObject.GetComponentInChildren<UMAData>();
        umaData.umaRecipe = umaRecipe;
        umaData.useLegacyCombiner = useLegacyCombiner;
        SetUMAData();
        GenerateUMAShapes();

        DefineSlots();
        umaData.myRenderer.enabled = false;

        if(zeroPoint){
            tempUMA.transform.position = new Vector3(zeroPoint.position.x,zeroPoint.position.y,zeroPoint.position.z);
        }else{
            tempUMA.transform.position = new Vector3(0,0,0);
        }

        tempUMA.parent = transform;
        UMADynamicAvatar umaDynamicAvatar = umaData.gameObject.AddComponent("UMADynamicAvatar") as UMADynamicAvatar;
        umaDynamicAvatar.Initialize();

        umaData.gameObject.AddComponent("UMASaveTool");
    }