public void CheckSemantics(IDslModel existingConcepts) { if (!ParameterType.Contains('.')) { throw new DslSyntaxException(this, "ParameterType must be full type name, including Module name for a data structure, or C# namespace for other parameter types."); } }
public override float Sample(float absolutFactor, bool isDone) { var position = useLocal ? Target.localPosition : Target.position; if (ParameterType.Contains(Type.X)) { var axisAbsolutFactor = tweenCurves[0].Evaluate(absolutFactor); position.x = from.x * (1f - axisAbsolutFactor) + to.x * axisAbsolutFactor; } if (ParameterType.Contains(Type.Y)) { var axisAbsolutFactor = tweenCurves[1].Evaluate(absolutFactor); position.y = from.y * (1f - axisAbsolutFactor) + to.y * axisAbsolutFactor; } if (ParameterType.Contains(Type.Z)) { var axisAbsolutFactor = tweenCurves[2].Evaluate(absolutFactor); position.z = from.z * (1f - axisAbsolutFactor) + to.z * axisAbsolutFactor; } if (useLocal) { Target.localPosition = position; } else { Target.position = position; } return(absolutFactor); }
public override void DrawInspector() { base.DrawInspector(); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Target", 100f); target = EditorTools.DrawObjectField(target, true); }); if (ParameterType.Contains(SupportTypes)) { EditorTools.DrawInLine(() => { EditorTools.DrawLabel("From", 50f); if (ParameterType.Contains(Type.Width)) { EditorTools.DrawLabel(char.ConvertFromUtf32(0x2194), 15f); from.x = EditorGUILayout.FloatField(from.x); } if (ParameterType.Contains(Type.Height)) { EditorTools.DrawLabel(char.ConvertFromUtf32(0x2195), 10f); from.y = EditorGUILayout.FloatField(from.y); } EditorTools.DrawButton("Apply", () => Sample(0f, true), EditorStyles.miniButton, Color.green, 40f); }); EditorTools.DrawInLine(() => { if (tweenCurves.IsNull()) { tweenCurves = new [] { new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)) }; } EditorTools.DrawLabel("Curve", 50f); if (ParameterType.Contains(Type.Width)) { EditorTools.DrawLabel(char.ConvertFromUtf32(0x2194), 15f); tweenCurves[0] = EditorGUILayout.CurveField(tweenCurves[0]); } if (ParameterType.Contains(Type.Height)) { EditorTools.DrawLabel(char.ConvertFromUtf32(0x2195), 10f); tweenCurves[1] = EditorGUILayout.CurveField(tweenCurves[1]); } }); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("To", 50f); if (ParameterType.Contains(Type.Width)) { EditorTools.DrawLabel(char.ConvertFromUtf32(0x2194), 15f); to.x = EditorGUILayout.FloatField(to.x); } if (ParameterType.Contains(Type.Height)) { EditorTools.DrawLabel(char.ConvertFromUtf32(0x2195), 10f); to.y = EditorGUILayout.FloatField(to.y); } EditorTools.DrawButton("Apply", () => Sample(1f, true), EditorStyles.miniButton, Color.green, 40f); }); } }
public override float Sample(float absolutFactor, bool isDone) { if (ParameterType.Contains(Type.Height)) { absolutFactor = tweenCurves[0].Evaluate(absolutFactor); Target.fontSize = Mathf.RoundToInt(from * (1f - absolutFactor) + to * absolutFactor); } return(absolutFactor); }
public override float Sample(float absolutFactor, bool isDone) { absolutFactor = tweenCurves.First().Evaluate(absolutFactor); if (!Target.IsNull() && ParameterType.Contains(Type.Alpha)) { Target.alpha = Mathf.Lerp(from, to, absolutFactor); } return(absolutFactor); }
public override float Sample(float absolutFactor, bool isDone) { absolutFactor = tweenCurves.First().Evaluate(absolutFactor); if (ParameterType.Contains(Type.Active)) { Target.SetActive((absolutFactor > 0f) ? to : from); } return(absolutFactor); }
public override float Sample(float absolutFactor, bool isDone) { if (ParameterType.Contains(Type.Forward)) { absolutFactor = tweenCurves[0].Evaluate(absolutFactor); WheelFrictions.LerpForwardFriction(Target, from, to, absolutFactor); } if (ParameterType.Contains(Type.Sideways)) { absolutFactor = tweenCurves[1].Evaluate(absolutFactor); WheelFrictions.LerpSidewaysFriction(Target, from, to, absolutFactor); } return(absolutFactor); }
public override float Sample(float absolutFactor, bool isDone) { if (ParameterType.Contains(Type.Width)) { absolutFactor = tweenCurves[0].Evaluate(absolutFactor); Target.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.RoundToInt(from.x * (1f - absolutFactor) + to.x * absolutFactor)); } if (ParameterType.Contains(Type.Height)) { absolutFactor = tweenCurves[1].Evaluate(absolutFactor); Target.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.RoundToInt(from.y * (1f - absolutFactor) + to.y * absolutFactor)); } return(absolutFactor); }
public override float Sample(float absolutFactor, bool isDone) { absolutFactor = tweenCurves.First().Evaluate(absolutFactor); if (ParameterType.Contains(Type.Color)) { var color = Color.Lerp(from, to, absolutFactor); color.a = Target.color.a; Target.color = color; } if (ParameterType.Contains(Type.Alpha)) { var color = Target.color; color.a = Mathf.Lerp(from.a, to.a, absolutFactor); Target.color = color; } return(absolutFactor); }
public override void DrawInspector() { base.DrawInspector(); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Target", 100f); target = EditorTools.DrawObjectField(target, true); }); if (ParameterType.Contains(SupportTypes)) { EditorTools.DrawInLine(() => { EditorTools.DrawLabel("From", 50f); if (ParameterType.Contains(Type.Color)) { from = EditorGUILayout.ColorField(from); } if (ParameterType.Contains(Type.Alpha)) { from.a = EditorGUILayout.Slider(from.a, 0f, 1f, GUILayout.MinWidth(80f)); } EditorTools.DrawButton("Apply", () => Sample(0f, true), EditorStyles.miniButton, Color.green, 40f); }); EditorTools.DrawInLine(() => { if (tweenCurves.IsNull()) { tweenCurves = new [] { new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)) }; } EditorTools.DrawLabel("Curve", 50f); tweenCurves[0] = EditorGUILayout.CurveField(tweenCurves[0]); }); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("To", 50f); if (ParameterType.Contains(Type.Color)) { to = EditorGUILayout.ColorField(to); } if (ParameterType.Contains(Type.Alpha)) { to.a = EditorGUILayout.Slider(to.a, 0f, 1f, GUILayout.MinWidth(80f)); } EditorTools.DrawButton("Apply", () => Sample(1f, true), EditorStyles.miniButton, Color.green, 40f); }); } }
public override float Sample(float absolutFactor, bool isDone) { var scale = Target.localScale; if (ParameterType.Contains(Type.X)) { var axisAbsolutFactor = tweenCurves[0].Evaluate(absolutFactor); scale.x = from.x * (1f - axisAbsolutFactor) + to.x * axisAbsolutFactor; } if (ParameterType.Contains(Type.Y)) { var axisAbsolutFactor = tweenCurves[1].Evaluate(absolutFactor); scale.y = from.y * (1f - axisAbsolutFactor) + to.y * axisAbsolutFactor; } if (ParameterType.Contains(Type.Z)) { var axisAbsolutFactor = tweenCurves[2].Evaluate(absolutFactor); scale.z = from.z * (1f - axisAbsolutFactor) + to.z * axisAbsolutFactor; } Target.localScale = scale; return(absolutFactor); }
public override void DrawInspector() { base.DrawInspector(); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Target", 100f); target = EditorTools.DrawObjectField(target, true); }); if (ParameterType.Contains(SupportTypes)) { var rowCount = 5; var rowHeightAtPixel = EditorGUIUtility.singleLineHeight * 1.25f; var spacingBetweenRowAtPixel = EditorGUIUtility.standardVerticalSpacing; var gridCount = 0; if (ParameterType.Contains(Type.Forward)) { gridCount++; } if (ParameterType.Contains(Type.Sideways)) { gridCount++; } var position = EditorGUILayout.GetControlRect(true, rowHeightAtPixel); var labelRect = new Rect(position) { width = 40f }; EditorGUI.LabelField(labelRect, "From"); position.x += labelRect.width; position.width -= labelRect.width; position.height = rowHeightAtPixel * rowCount; GUI.Box(position, string.Empty); var headerWidth = from.DrawHeader(position, rowHeightAtPixel); position.x += headerWidth; position.width -= headerWidth; position.width = position.width / gridCount; if (ParameterType.Contains(Type.Forward)) { from.Forward.DrawGrid(char.ConvertFromUtf32(0x2195) + " Forward", position, rowHeightAtPixel); position.x += position.width; } if (ParameterType.Contains(Type.Sideways)) { from.Sideways.DrawGrid(char.ConvertFromUtf32(0x2194) + " Sideways", position, rowHeightAtPixel); } GUILayout.Space(position.height - rowHeightAtPixel); EditorTools.DrawInLine(() => { if (tweenCurves.IsNull()) { tweenCurves = new [] { new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)) }; } EditorTools.DrawLabel("Curve", labelRect.width + headerWidth); if (ParameterType.Contains(Type.Forward)) { EditorTools.DrawLabel(char.ConvertFromUtf32(0x2195), 15f); tweenCurves[0] = EditorGUILayout.CurveField(tweenCurves[0]); } if (ParameterType.Contains(Type.Sideways)) { EditorTools.DrawLabel(char.ConvertFromUtf32(0x2194), 15f); tweenCurves[1] = EditorGUILayout.CurveField(tweenCurves[1]); } }); position = EditorGUILayout.GetControlRect(true, rowHeightAtPixel); labelRect = new Rect(position) { width = 40f }; EditorGUI.LabelField(labelRect, "To"); position.x += labelRect.width; position.width -= labelRect.width; position.height = rowHeightAtPixel * rowCount; GUI.Box(position, string.Empty); headerWidth = from.DrawHeader(position, rowHeightAtPixel); position.x += headerWidth; position.width -= headerWidth; position.width = position.width / gridCount; if (ParameterType.Contains(Type.Forward)) { from.Forward.DrawGrid(char.ConvertFromUtf32(0x2195) + " Forward", position, rowHeightAtPixel); position.x += position.width; } if (ParameterType.Contains(Type.Sideways)) { from.Sideways.DrawGrid(char.ConvertFromUtf32(0x2194) + " Sideways", position, rowHeightAtPixel); } GUILayout.Space(position.height - rowHeightAtPixel); } }
public override void DrawInspector() { base.DrawInspector(); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Target", 100f); target = EditorTools.DrawObjectField(target, true); }); if (ParameterType.Contains(SupportTypes ^ BaseType)) { EditorTools.DrawInLine(() => { EditorTools.DrawLabel("From", 50f); if (ParameterType.Contains(Type.X)) { EditorTools.DrawLabel("X", 12.5f); from.x = EditorGUILayout.FloatField(from.x, GUILayout.MinWidth(30f)); } if (ParameterType.Contains(Type.Y)) { EditorTools.DrawLabel("Y", 12.5f); from.y = EditorGUILayout.FloatField(from.y, GUILayout.MinWidth(30f)); } if (ParameterType.Contains(Type.Z)) { EditorTools.DrawLabel("Z", 12.5f); from.z = EditorGUILayout.FloatField(from.z, GUILayout.MinWidth(30f)); } EditorTools.DrawButton("Apply", () => Sample(0f, true), EditorStyles.miniButton, Color.green, 40f); }); EditorTools.DrawInLine(() => { if (tweenCurves.IsNull()) { tweenCurves = new [] { new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)) }; } EditorTools.DrawLabel("Curve", 50f); if (ParameterType.Contains(Type.X)) { EditorTools.DrawLabel("X", 12.5f); tweenCurves[0] = EditorGUILayout.CurveField(tweenCurves[0], GUILayout.MinWidth(45f)); } if (ParameterType.Contains(Type.Y)) { EditorTools.DrawLabel("Y", 12.5f); tweenCurves[1] = EditorGUILayout.CurveField(tweenCurves[1], GUILayout.MinWidth(45f)); } if (ParameterType.Contains(Type.Z)) { EditorTools.DrawLabel("Z", 12.5f); tweenCurves[2] = EditorGUILayout.CurveField(tweenCurves[2], GUILayout.MinWidth(45f)); } }); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("To", 50f); if (ParameterType.Contains(Type.X)) { EditorTools.DrawLabel("X", 12.5f); to.x = EditorGUILayout.FloatField(to.x, GUILayout.MinWidth(30f)); } if (ParameterType.Contains(Type.Y)) { EditorTools.DrawLabel("Y", 12.5f); to.y = EditorGUILayout.FloatField(to.y, GUILayout.MinWidth(30f)); } if (ParameterType.Contains(Type.Z)) { EditorTools.DrawLabel("Z", 12.5f); to.z = EditorGUILayout.FloatField(to.z, GUILayout.MinWidth(30f)); } EditorTools.DrawButton("Apply", () => Sample(1f, true), EditorStyles.miniButton, Color.green, 40f); }); } }
public override float Sample(float absolutFactor, bool isDone) { if (!to.IsNull()) { if (from != null) { if (ParameterType.Contains(Type.Position)) { var position = from.position; var positionAbsolutFactor = tweenCurves[0].Evaluate(absolutFactor); position.x = from.position.x * (1f - positionAbsolutFactor) + to.position.x * positionAbsolutFactor; positionAbsolutFactor = tweenCurves[1].Evaluate(absolutFactor); position.y = from.position.y * (1f - positionAbsolutFactor) + to.position.y * positionAbsolutFactor; positionAbsolutFactor = tweenCurves[2].Evaluate(absolutFactor); position.z = from.position.z * (1f - positionAbsolutFactor) + to.position.z * positionAbsolutFactor; Target.position = position; } if (ParameterType.Contains(Type.Rotation)) { var rotationAbsolutFactor = tweenCurves[3].Evaluate(absolutFactor); Target.rotation = Quaternion.Slerp(from.rotation, to.rotation, rotationAbsolutFactor); } if (ParameterType.Contains(Type.Scale)) { var scale = from.localScale; var scaleAbsolutFactor = tweenCurves[4].Evaluate(absolutFactor); scale.x = from.localScale.x * (1f - scaleAbsolutFactor) + to.localScale.x * scaleAbsolutFactor; scaleAbsolutFactor = tweenCurves[5].Evaluate(absolutFactor); scale.y = from.localScale.y * (1f - scaleAbsolutFactor) + to.localScale.y * scaleAbsolutFactor; scaleAbsolutFactor = tweenCurves[6].Evaluate(absolutFactor); scale.z = from.localScale.z * (1f - scaleAbsolutFactor) + to.localScale.z * scaleAbsolutFactor; Target.localScale = scale; } } else { if (ParameterType.Contains(Type.Position)) { var position = FromCurrent.position; var positionAbsolutFactor = tweenCurves[0].Evaluate(absolutFactor); position.x = FromCurrent.position.x * (1f - positionAbsolutFactor) + to.position.x * positionAbsolutFactor; positionAbsolutFactor = tweenCurves[1].Evaluate(absolutFactor); position.y = FromCurrent.position.y * (1f - positionAbsolutFactor) + to.position.y * positionAbsolutFactor; positionAbsolutFactor = tweenCurves[2].Evaluate(absolutFactor); position.z = FromCurrent.position.z * (1f - positionAbsolutFactor) + to.position.z * positionAbsolutFactor; Target.position = position; } if (ParameterType.Contains(Type.Rotation)) { var rotationAbsolutFactor = tweenCurves[3].Evaluate(absolutFactor); Target.rotation = Quaternion.Slerp(FromCurrent.rotation, to.rotation, rotationAbsolutFactor); } if (ParameterType.Contains(Type.Scale)) { var scale = FromCurrent.scale; var scaleAbsolutFactor = tweenCurves[4].Evaluate(absolutFactor); scale.x = FromCurrent.scale.x * (1f - scaleAbsolutFactor) + to.localScale.x * scaleAbsolutFactor; scaleAbsolutFactor = tweenCurves[5].Evaluate(absolutFactor); scale.y = FromCurrent.scale.y * (1f - scaleAbsolutFactor) + to.localScale.y * scaleAbsolutFactor; scaleAbsolutFactor = tweenCurves[6].Evaluate(absolutFactor); scale.z = FromCurrent.scale.z * (1f - scaleAbsolutFactor) + to.localScale.z * scaleAbsolutFactor; Target.localScale = scale; } } } if (isDone) { ResetFromCurrent(); } return(absolutFactor); }
public override void DrawInspector() { base.DrawInspector(); EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Target", 100f); target = EditorTools.DrawObjectField(target, true); }); if (ParameterType.Contains(SupportTypes)) { EditorTools.DrawInLine(() => { EditorTools.DrawLabel("From", 50f); from = EditorTools.DrawObjectField(from, true); EditorTools.DrawButton("Apply", () => Sample(0f, true), EditorStyles.miniButton, Color.green, 40f); }); if (tweenCurves.IsNull()) { tweenCurves = new [] { new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)), new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)) }; } if (ParameterType.Contains(Type.Position)) { EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Curve P", 50f); EditorTools.DrawLabel("X", 12.5f); tweenCurves[0] = EditorGUILayout.CurveField(tweenCurves[0], GUILayout.MinWidth(45f)); EditorTools.DrawLabel("Y", 12.5f); tweenCurves[1] = EditorGUILayout.CurveField(tweenCurves[1], GUILayout.MinWidth(45f)); EditorTools.DrawLabel("Z", 12.5f); tweenCurves[2] = EditorGUILayout.CurveField(tweenCurves[2], GUILayout.MinWidth(45f)); }); } if (ParameterType.Contains(Type.Rotation)) { EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Curve R", 50f); tweenCurves[3] = EditorGUILayout.CurveField(tweenCurves[3]); }); } if (ParameterType.Contains(Type.Scale)) { EditorTools.DrawInLine(() => { EditorTools.DrawLabel("Curve S", 50f); EditorTools.DrawLabel("X", 12.5f); tweenCurves[4] = EditorGUILayout.CurveField(tweenCurves[4], GUILayout.MinWidth(45f)); EditorTools.DrawLabel("Y", 12.5f); tweenCurves[5] = EditorGUILayout.CurveField(tweenCurves[5], GUILayout.MinWidth(45f)); EditorTools.DrawLabel("Z", 12.5f); tweenCurves[6] = EditorGUILayout.CurveField(tweenCurves[6], GUILayout.MinWidth(45f)); }); } EditorTools.DrawInLine(() => { EditorTools.DrawLabel("To", 50f); to = EditorTools.DrawObjectField(to, true); EditorTools.DrawButton("Apply", () => Sample(1f, true), EditorStyles.miniButton, Color.green, 40f); }); } }