public static List <AnimParam> GetAvatarFaceParamaters(List <SkinnedMesh> skinnedMeshList) { var animParamList = new List <AnimParam>(); for (int skinnedMeshIndex = 0; skinnedMeshIndex < skinnedMeshList.Count; skinnedMeshIndex++) { IFaceEmotionSkinnedMesh skinnedMesh = skinnedMeshList[skinnedMeshIndex]; if (skinnedMesh.BlendShapeCount <= 0) { continue; } var mesh = skinnedMesh.Mesh; var renderer = skinnedMesh.Renderer; for (int blendShapeIndex = 0; blendShapeIndex < mesh.blendShapeCount; blendShapeIndex++) { var blendShapeName = mesh.GetBlendShapeName(blendShapeIndex); var weight = renderer.GetBlendShapeWeight(blendShapeIndex); var animParam = new AnimParam("", blendShapeName, weight); animParamList.Add(animParam); } } return(animParamList); }
public void OnAnimDisable() { Debug.Log("Saving Animator state: " + anim.parameters.Length); for (int i = 0; i < anim.parameters.Length; i++) { AnimatorControllerParameter p = anim.parameters[i]; AnimParam ap = new AnimParam(anim, p.name, p.type); parms.Add(ap); } }
static void GetParams(Animator anim) { sAnim = anim; sList.Clear(); if (anim != null) { foreach (var t in anim.parameters) { sList.Add(AnimParam.ReferenceTo(t)); } } GetNames(); }
public void ApplyLerp(AnimParam right, float factor, AnimatorControllerParameter param, Animator anim) { if (param.type == AnimatorControllerParameterType.Float) { float leftFloat = BitConverter.ToSingle(BitConverter.GetBytes(this.value), 0); float rightFloat = BitConverter.ToSingle(BitConverter.GetBytes(right.value), 0); anim.SetFloat(param.name, Mathf.Lerp(leftFloat, rightFloat, factor)); } else { this.Apply(param, anim); } }
public static List <AnimParam> GetAnimationParamaters(AnimationClip clip) { var bindings = AnimationUtility.GetCurveBindings(clip); var animParamList = new List <AnimParam>(); foreach (var binding in bindings) { if ((binding.propertyName).Split('.')[0] != "blendShape") { continue; } var curve = AnimationUtility.GetEditorCurve(clip, binding); var animParam = new AnimParam(binding.path, binding.propertyName, curve[0].value); animParamList.Add(animParam); } return(animParamList); }
private static bool ValidateObjectRef(ref AnimParam animParam, FrozenObjRef frozenRef) { if (animParam.obj != null) { // NOTE: Vanilla also checked that the handle was valid, but we no longer do this // since handles never are "really" invalid... // This check however could be replaced with a check whether the object still belongs to the // currently loaded map or not. return(true); } if (!GameSystems.MapObject.Unfreeze(frozenRef, out var obj)) { Logger.Error("Failed to recover object reference in anim goal"); animParam.obj = null; return(false); } animParam.obj = obj; return(true); }
// Value should only be null if you're setting a trigger public bool QueryAnimator(AnimParam param, string key, object value = null) { Animator animator = GetComponent <Animator>(); if (animator == null) { return(false); } else { try { switch (param) { case AnimParam.Bool: animator.SetBool(key, (bool)value); return(true); case AnimParam.Float: animator.SetFloat(key, (float)value); return(true); case AnimParam.Int: animator.SetInteger(key, (int)value); return(true); case AnimParam.Trigger: animator.SetTrigger(key); return(true); default: return(false); } } catch { return(false); } } }
public AnimParam GetAnimParam(AnimGoalProperty property) { var result = new AnimParam(); switch (property) { case AnimGoalProperty.SELF_OBJ_PRECISE_LOC: result.location = self.obj.GetLocationFull(); break; case AnimGoalProperty.TARGET_OBJ_PRECISE_LOC: if (target.obj.type.IsEquipment()) { var parentObj = GameSystems.Item.GetParent(target.obj); if (parentObj != null) { result.location = parentObj.GetLocationFull(); break; } } result.location = target.obj.GetLocationFull(); break; case AnimGoalProperty.NULL_HANDLE: result.obj = null; break; case AnimGoalProperty.TARGET_LOC_PRECISE: if (targetTile.location.location.locx != 0 || targetTile.location.location.locy != 0) { result.location = targetTile.location; } else { if (target.obj != null) { targetTile.location = target.obj.GetLocationFull(); } result.location = targetTile.location; } break; case AnimGoalProperty.SELF_OBJ: result.obj = self.obj; break; case AnimGoalProperty.TARGET_OBJ: result.obj = target.obj; break; case AnimGoalProperty.BLOCK_OBJ: result.obj = block.obj; break; case AnimGoalProperty.SCRATCH_OBJ: result.obj = scratch.obj; break; case AnimGoalProperty.PARENT_OBJ: result.obj = parent.obj; break; case AnimGoalProperty.TARGET_TILE: result.location = targetTile.location; break; case AnimGoalProperty.RANGE_DATA: result.location = range.location; break; case AnimGoalProperty.ANIM_ID: result.number = animId.number; break; case AnimGoalProperty.ANIM_ID_PREV: result.number = animIdPrevious.number; break; case AnimGoalProperty.ANIM_DATA: result.number = animData.number; break; case AnimGoalProperty.SPELL_DATA: result.number = spellData.number; break; case AnimGoalProperty.SKILL_DATA: result.number = skillData.number; break; case AnimGoalProperty.FLAGS_DATA: result.number = flagsData.number; break; case AnimGoalProperty.SCRATCH_VAL1: result.number = scratchVal1.number; break; case AnimGoalProperty.SCRATCH_VAL2: result = scratchVal2; break; case AnimGoalProperty.SCRATCH_VAL3: result.number = scratchVal3.number; break; case AnimGoalProperty.SCRATCH_VAL4: result.number = scratchVal4.number; break; case AnimGoalProperty.SCRATCH_VAL5: result.number = scratchVal5.number; break; case AnimGoalProperty.SCRATCH_VAL6: result.number = scratchVal6.number; break; case AnimGoalProperty.SOUND_HANDLE: result.number = soundHandle.number; break; default: throw new ArgumentOutOfRangeException("Unknown data type: " + property); } return(result); }