protected override void OnReceive(MultiValue values) { if (isPositionSync) { syncStartPos_ = transform.position; syncEndPos_ = values.Pop().value.AsVector3(); if (isFirst_) transform.position = syncEndPos_; } if (isRotationSync) { syncStartRot_ = transform.rotation; syncEndRot_ = values.Pop().value.AsQuaternion(); if (isFirst_) transform.rotation = syncEndRot_; } if (isScaleSync) { syncStartScale_ = transform.localScale; syncEndScale_ = values.Pop().value.AsVector3(); if (isFirst_) transform.localScale = syncEndScale_; } syncStartTime_ = Time.time; syncEndTime_ = syncStartTime_ + sendCycle; if (isFirst_) isFirst_ = false; }
public static MultiValue AsMultiValue(this string value) { var mValue = new MultiValue(); var values = new List<MultiValue.Value>(); foreach (var val in value.Split(MultiValue.Delimiter, System.StringSplitOptions.None)) { values.Add(val.AsValue()); } mValue.values = values; return mValue; }
protected override void OnSend() { var values = new MultiValue(); if (isPositionSync) values.Push(transform.position); if (isRotationSync) values.Push(transform.rotation); if (isScaleSync) values.Push(transform.localScale); Send(values); }
public static MultiValue AsMultiValue(this string value) { var mValue = new MultiValue(); var values = new List <MultiValue.Value>(); foreach (var val in value.Split(MultiValue.Delimiter, System.StringSplitOptions.None)) { values.Add(val.AsValue()); } mValue.values = values; return(mValue); }
protected override void OnReceive(MultiValue data) { while (data.values.Count > 0) { var name = data.Pop().value; var param = data.Pop(); switch (param.type) { case "bool": animator.SetBool(name, param.value.AsBool()); break; case "int": animator.SetInteger(name, param.value.AsInt()); break; case "float": animator.SetFloat(name, param.value.AsFloat()); break; } } }
protected override void OnSend() { var data = new MultiValue(); foreach (var param in animator.parameters) { data.Push(param.name); switch (param.type) { case AnimatorControllerParameterType.Bool: data.Push(animator.GetBool(param.name)); break; case AnimatorControllerParameterType.Int: data.Push(animator.GetInteger(param.name)); break; case AnimatorControllerParameterType.Float: data.Push(animator.GetFloat(param.name)); break; } } Send(data); }
protected virtual void OnReceive(MultiValue value) { Debug.Log("receive multi value: " + value.AsString()); }
protected void Send(MultiValue value) { Send(value.AsString(), "multi"); }
public static string AsString(this MultiValue value) { return(string.Join( MultiValue.DelimiterString, value.values.Select(val => val.AsString()).ToArray())); }