/// <summary> /// Start the tweening operation. /// </summary> static public BCTweenRotation Begin(GameObject go, float duration, Quaternion rot) { BCTweenRotation comp = BCUITweener.Begin <BCTweenRotation>(go, duration); comp.from = comp.value.eulerAngles; comp.to = rot.eulerAngles; if (duration <= 0f) { comp.Sample(1f, true); comp.enabled = false; } return(comp); }
//call me before play public void JudgeTween() { if (randMaker == null || tweener == null) { return; } Vector3 fromfinal = from; Vector3 tofinal = to; float durationFinal = duration; float delayfinal = delay; //-------------First handle the situation of Current mode------------- if (tweener is BCTweenRotation) { BCTweenRotation tween = tweener as BCTweenRotation; Vector3 realvalue = tween.value.eulerAngles; if (from_rule[0] == TweenFromRule.Current) { fromfinal.x = realvalue.x; } if (from_rule[1] == TweenFromRule.Current) { fromfinal.y = realvalue.y; } if (from_rule[2] == TweenFromRule.Current) { fromfinal.z = realvalue.z; } } else if (tweener is BCTweenScale) { BCTweenScale tween = tweener as BCTweenScale; if (from_rule[0] == TweenFromRule.Current) { fromfinal.x = tween.value.x; } if (from_rule[1] == TweenFromRule.Current) { fromfinal.y = tween.value.y; } if (from_rule[2] == TweenFromRule.Current) { fromfinal.z = tween.value.z; } } else if (tweener is BCTweenPosition) { BCTweenPosition tween = tweener as BCTweenPosition; if (from_rule[0] == TweenFromRule.Current) { fromfinal.x = tween.value.x; } if (from_rule[1] == TweenFromRule.Current) { fromfinal.y = tween.value.y; } if (from_rule[2] == TweenFromRule.Current) { fromfinal.z = tween.value.z; } } //----------then handle other---------------------- if (from_rule[0] == TweenFromRule.RandValue) { fromfinal.x = randMaker.GetRand(ruleTagFrom[0]); } if (from_rule[1] == TweenFromRule.RandValue) { fromfinal.y = randMaker.GetRand(ruleTagFrom[1]); } if (from_rule[2] == TweenFromRule.RandValue) { fromfinal.z = randMaker.GetRand(ruleTagFrom[2]); } if (to_rule[0] == TweenToRule.RandValue) { tofinal.x = randMaker.GetRand(ruleTagTo[0]); } if (to_rule[1] == TweenToRule.RandValue) { tofinal.y = randMaker.GetRand(ruleTagTo[1]); } if (to_rule[2] == TweenToRule.RandValue) { tofinal.z = randMaker.GetRand(ruleTagTo[2]); } if (to_rule[0] == TweenToRule.FromPlusRand) { tofinal.x = fromfinal.x + randMaker.GetRand(ruleTagTo[0]); } if (to_rule[1] == TweenToRule.FromPlusRand) { tofinal.y = fromfinal.y + randMaker.GetRand(ruleTagTo[1]); } if (to_rule[2] == TweenToRule.FromPlusRand) { tofinal.z = fromfinal.z + randMaker.GetRand(ruleTagTo[2]); } if (to_rule[0] == TweenToRule.FromPlusFormula) { tofinal.x = randMaker.CalculateForm(ruleTagTo[0], fromfinal.x); } if (to_rule[1] == TweenToRule.FromPlusFormula) { tofinal.y = randMaker.CalculateForm(ruleTagTo[1], fromfinal.y); } if (to_rule[2] == TweenToRule.FromPlusFormula) { tofinal.z = randMaker.CalculateForm(ruleTagTo[2], fromfinal.z); } //-------------------------------------------------- if (tweener is BCTweenRotation) { BCTweenRotation tween = tweener as BCTweenRotation; tween.from = fromfinal; tween.to = tofinal; } else if (tweener is BCTweenScale) { BCTweenScale tween = tweener as BCTweenScale; tween.from = fromfinal; tween.to = tofinal; } else if (tweener is BCTweenPosition) { BCTweenPosition tween = tweener as BCTweenPosition; tween.from = fromfinal; tween.to = tofinal; } if (durationRule == TweenTimeRule.RandValue) { durationFinal = randMaker.GetRand(ruleTagDuration); } if (delayRule == TweenTimeRule.RandValue) { delayfinal = randMaker.GetRand(ruleTagDelay); } tweener.delay = delayfinal; tweener.duration = durationFinal; }
public override void OnInspectorGUI() { GUILayout.Space(6f); BCEditorTools.SetLabelWidth(120f); BCTweenRotation tw = target as BCTweenRotation; GUI.changed = false; Vector3 from = EditorGUILayout.Vector3Field("From", tw.from); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Set local From")) { from = tw.mTrans.localEulerAngles; GUI.changed = true; } if (GUILayout.Button("Reset By local From")) { tw.mTrans.localEulerAngles = from; } EditorGUILayout.EndHorizontal(); Vector3 to = EditorGUILayout.Vector3Field("To", tw.to); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Set local To")) { to = tw.mTrans.localEulerAngles; GUI.changed = true; } if (GUILayout.Button("Reset By local To")) { tw.mTrans.localEulerAngles = to; } EditorGUILayout.EndHorizontal(); bool fromIsCurrent = EditorGUILayout.Toggle("From Is Current", tw.fromIsCurrent); bool RelativeRotate = false; if (fromIsCurrent) { RelativeRotate = EditorGUILayout.Toggle("->Relative Rotate", tw.RelativeRotate); } tw.mTrans = EditorGUILayout.ObjectField("Transform", tw.mTrans, typeof(Transform)) as Transform; bool Line_2D_to_3D = EditorGUILayout.Toggle("Line 2D to 3D", tw.Line_2D_to_3D); if (Line_2D_to_3D) { tw.leftLine = EditorGUILayout.ObjectField("Left Line", tw.leftLine, typeof(Transform)) as Transform; tw.rightLine = EditorGUILayout.ObjectField("Left Line", tw.rightLine, typeof(Transform)) as Transform; } if (GUI.changed) { BCEditorTools.RegisterUndo("Tween Change", tw); tw.from = from; tw.to = to; tw.fromIsCurrent = fromIsCurrent; tw.RelativeRotate = RelativeRotate; tw.Line_2D_to_3D = Line_2D_to_3D; BCEditorTools.SetDirty(tw); } DrawCommonProperties(); }