public static AnimationParameterInfoMessage getSyncAnimationMessage(string fieldName, object fieldValue) { AnimationParameterInfoMessage message = new AnimationParameterInfoMessage(); if (fieldValue.GetType() == typeof(int)) { message = new AnimationParameterInfoIntMessage(); ((AnimationParameterInfoIntMessage)message).value = (int)fieldValue; message.syncedValueType = AnimationParameterInfoMessage.syncType.INT; } else if (fieldValue.GetType() == typeof(float)) { message = new AnimationParameterInfoFloatMessage(); ((AnimationParameterInfoFloatMessage)message).value = (float)fieldValue; message.syncedValueType = AnimationParameterInfoMessage.syncType.FLOAT; } else if (fieldValue.GetType() == typeof(bool)) { message = new AnimationParameterInfoBoolMessage(); ((AnimationParameterInfoBoolMessage)message).value = (bool)fieldValue; message.syncedValueType = AnimationParameterInfoMessage.syncType.BOOL; } else { QTDebugger.instance.debugWarning(QTDebugger.debugType.NETWORK, "Unknown animator parameter type -> " + fieldName + " of " + fieldValue.GetType().Name); return(null); } message.fieldName = fieldName; return(message); }
public static void applySyncAnimationMessageToAnimator(Animator animator, AnimationParameterInfoMessage message) { switch (message.syncedValueType) { case AnimationParameterInfoMessage.syncType.INT: { AnimationParameterInfoIntMessage syncMessageDetailed = (AnimationParameterInfoIntMessage)message; animator.SetInteger(syncMessageDetailed.fieldName, syncMessageDetailed.value); break; } case AnimationParameterInfoMessage.syncType.FLOAT: { AnimationParameterInfoFloatMessage syncMessageDetailed = (AnimationParameterInfoFloatMessage)message; animator.SetFloat(syncMessageDetailed.fieldName, syncMessageDetailed.value); break; } case AnimationParameterInfoMessage.syncType.BOOL: { AnimationParameterInfoBoolMessage syncMessageDetailed = (AnimationParameterInfoBoolMessage)message; animator.SetBool(syncMessageDetailed.fieldName, syncMessageDetailed.value); break; } } }