public UMABonePose CreatePoseAsset(string assetFolder = "", string assetName = "")
        {
            if (assetFolder == "")
            {
                assetFolder = AssetDatabase.GetAssetPath(selectedConverter);
                assetFolder = assetFolder.Substring(0, assetFolder.LastIndexOf('/'));
            }
            if (assetName == "")
            {
                assetName = selectedConverter.name + "StartingPose";
                var uniquePath = AssetDatabase.GenerateUniqueAssetPath(assetFolder + "/" + assetName + ".asset");
                assetName = uniquePath.Replace(assetFolder + "/", "").Replace(".asset", "");
            }

            if (!System.IO.Directory.Exists(assetFolder))
            {
                System.IO.Directory.CreateDirectory(assetFolder);
            }

            UMABonePose asset = ScriptableObject.CreateInstance <UMABonePose>();

            AssetDatabase.CreateAsset(asset, assetFolder + "/" + assetName + ".asset");
            AssetDatabase.SaveAssets();
            return(asset);
        }
 public BonePoseDNAConverter(UMABonePose poseToApply, float startingPoseWeight = 0f, List <DNAEvaluator> modifyingDnas = null)
 {
     this._poseToApply        = poseToApply;
     this._startingPoseWeight = startingPoseWeight;
     if (modifyingDnas != null)
     {
         this._modifyingDNA = new DNAEvaluatorList(modifyingDnas);
     }
 }
Exemplo n.º 3
0
        private void CreatePoseSet(string fileName)
        {
            SlotDataAsset sda = CustomAssetUtility.CreateAsset <SlotDataAsset>("", false, fileName + "_Slot", false);

            sda.slotName = sda.name;
            sda.nameHash = UMAUtils.StringToHash(sda.slotName);

            DynamicDNAConverterController ddcc = UMA.CustomAssetUtility.CreateAsset <DynamicDNAConverterController>("", false, fileName + "_Controller", false);

            sda.slotDNA = ddcc;


            DynamicUMADnaAsset duda = UMA.CustomAssetUtility.CreateAsset <DynamicUMADnaAsset>("", false, fileName + "_DNAAsset", false);

            ddcc.DNAAsset = duda;

            UMABonePose bp = UMA.CustomAssetUtility.CreateAsset <UMABonePose>("", true, fileName + "_Pose", false);
            BonePoseDNAConverterPlugin bpdcp = (BonePoseDNAConverterPlugin)ddcc.AddPlugin(typeof(BonePoseDNAConverterPlugin));

            bpdcp.poseDNAConverters.Add(new BonePoseDNAConverterPlugin.BonePoseDNAConverter());
            bpdcp.poseDNAConverters[0].poseToApply        = bp;
            bpdcp.poseDNAConverters[0].startingPoseWeight = 1.0f;


            EditorUtility.SetDirty(sda);
            EditorUtility.SetDirty(ddcc);
            EditorUtility.SetDirty(duda);
            EditorUtility.SetDirty(bp);
            EditorUtility.SetDirty(bpdcp);
            if (addToLibrary)
            {
                UMAAssetIndexer.Instance.EvilAddAsset(typeof(SlotDataAsset), sda);
                UMAAssetIndexer.Instance.EvilAddAsset(typeof(DynamicUMADnaAsset), duda);
                EditorUtility.SetDirty(UMAAssetIndexer.Instance);
            }

            if (createWardrobeRecipe)
            {
                string            path = CustomAssetUtility.GetAssetPathAndName <UMAWardrobeRecipe>(fileName, false);
                UMAWardrobeRecipe uwr  = UMAEditorUtilities.CreateRecipe(path, sda, null, fileName, addToLibrary);
                uwr.compatibleRaces = new List <string>();
                uwr.wardrobeSlot    = "Physique";
                uwr.compatibleRaces.Add(raceNames[selectedRace]);
                EditorUtility.SetDirty(uwr);
            }

            AssetDatabase.SaveAssets();
        }
    public void SetValues()
    {
        if (expressionSet == null)
        {
            return;
        }
        if (skeleton == null)
        {
            return;
        }
        if (!initialized)
        {
            return;
        }

        float[] values = Values;


        MecanimJoint mecanimMask = MecanimJoint.None;

        if (!overrideMecanimNeck)
        {
            mecanimMask |= MecanimJoint.Neck;
        }
        if (!overrideMecanimHead)
        {
            mecanimMask |= MecanimJoint.Head;
        }
        if (!overrideMecanimJaw)
        {
            mecanimMask |= MecanimJoint.Jaw;
        }
        if (!overrideMecanimEyes)
        {
            mecanimMask |= MecanimJoint.Eye;
        }
        if (overrideMecanimJaw)
        {
            skeleton.Restore(jawHash);
        }

        for (int i = 0; i < values.Length; i++)
        {
            if ((MecanimAlternate[i] & mecanimMask) != MecanimJoint.None)
            {
                continue;
            }

            float weight = values[i];

            UMABonePose pose = null;
            if (weight > 0)
            {
                pose = expressionSet.posePairs[i].primary;
            }
            else
            {
                weight = -weight;
                pose   = expressionSet.posePairs[i].inverse;
            }
            if (pose == null)
            {
                continue;
            }

            //Debug.Log("SETTING VALUES: "+pose.name);
            pose.ApplyPose(skeleton, weight);
        }
    }
 public BonePoseDNAConverter(BonePoseDNAConverter other)
 {
     this._poseToApply       = other._poseToApply;
     this.startingPoseWeight = other._startingPoseWeight;
     this._modifyingDNA      = new DNAEvaluatorList(other._modifyingDNA);
 }