Hide
DrawWireDisc

Like Unity's DrawWireDisc, this attributes allows you to draw a disc in the scene.

The field can be a GameObject, a Component, a Vector2(2D game), a Vector3 (3D game), or a number.

You can specify which parent you want the circle be, the rotate/offset/facing of the circle, and color of course.

Parameters:

  • float radius = 1f: radis of the disk. If the target field is a number, use the field's value instead
  • string radiusCallback = null: use a callback or a field value as the radius. If the target field is a number, use the field's value instead
  • string space = "this": the containing space of the disc. this means using the current target, null means using the world space, otherwise means using a callback or a field value
  • float norX = 0f, float norY = 0f, float norZ = 1f: Vector3 direction for the normal (facing) of the disc. It's facing forward by default
  • string norCallback = null: use a callback or a field value as the normal direction, the value must be a Vector3
  • float posXOffset = 0f, float posYOffset = 0f, float posZOffset = 0f: Vector3 position offset for the disc related to the space
  • string posOffsetCallback = null: use a callback or a field value as the position offset. The value must be a Vector3
  • float rotX = 0f, float rotY = 0f, float rotZ = 0f: rotation of the disc related to space
  • string rotCallback = null: use a callback or a field value as the rotation. The value must be a Quaternion
  • EColor eColor = EColor.White: color
  • float alpha = 1f: the alpha of the color. Not works with color.
  • string color = null: the color of the line. If it starts with #, use html hex color, otherwise use as a callback. This overrides the eColor.
using SaintsField; // Draw a circle for my character [DrawWireDisc(radis: 0.2f, EColor.Yellow)] public MyCharacter character2D; // Draw a circle on the ground for my character (disc facing upward) // the hight from center to the ground is 0.5f [DrawWireDisc(norY: 1, norZ: 0, posYOffset: -0.5f)] public MyCharacter character3D; // Make a struct to let it follow [Serializable] public struct PlayerWeapon { [PositionHandle(Space.Self)] [DrawWireDisc] public Vector3 firePointOffset; // your other fields }

A simple example to show debugging a player's alert/idle range:

[GetComponent] [DrawWireDisc(norY: 1, norZ: 0, posYOffset: -1f, color: nameof(curColor), radiusCallback: nameof(curRadius))] [DrawLabel(EColor.Brown, "
quot;
+ nameof(curStatus))] public Transform player; [Range(1f, 1.5f)] public float initRadius; [Range(1f, 1.5f)] public float alertRadius; [AdvancedDropdown] public Color initColor; [AdvancedDropdown] public Color alertColor; public Transform enemy; [InputAxis] public string horizontalAxis; [InputAxis] public string verticalAxis; [ShowInInspector] private Color curColor; [ShowInInspector] private float curRadius = 0.5f; [ShowInInspector] private string curStatus = "Idle"; private void Awake() { curColor = initColor; curRadius = initRadius; } public void Update() { Vector3 playerPos = player.position; Vector3 enemyPos = enemy.position; float distance = Vector3.Distance(playerPos, enemyPos); float nowRadius = distance < alertRadius ? alertRadius : initRadius; Color nowColor = distance < alertRadius ? alertColor : initColor; curStatus = distance < alertRadius ? "Alert" : "Idle"; curRadius = Mathf.Lerp(curRadius, nowRadius, Time.deltaTime * 10); curColor = Color.Lerp(curColor, nowColor, Time.deltaTime * 10); float horizontal = Input.GetAxis(horizontalAxis); float vertical = Input.GetAxis(verticalAxis); Vector3 move = new Vector3(horizontal, 0, vertical); player.Translate(move * Time.deltaTime * 3); }