private void OnDrawGizmos() { if (Astronomy.SunLight == null) { return; } if (!Application.isPlaying) { Astronomy.SunLight.transform.localRotation = Astronomy.Rotation(); } Gizmos.color = Color.blue; Gizmos.DrawLine(Astronomy.SunLight.transform.position + (Astronomy.SunLight.transform.forward * Astronomy.Radius * 0.75f), Astronomy.SunLight.transform.position + (Astronomy.SunLight.transform.forward * Astronomy.Radius)); //Gizmos.DrawLine( Sun.transform.position - ( Sun.transform.forward * Radius * 0.75f ), Sun.transform.position - ( Sun.transform.forward * Radius ) ); CustomGizmos.Circle(Astronomy.SunLight.transform.position, Astronomy.SunLight.transform.up, Astronomy.Radius); CustomGizmos.Arrow(Astronomy.SunLight.transform.position + (Astronomy.SunLight.transform.forward * Astronomy.Radius * 0.75f), Astronomy.SunLight.transform.forward * -2, 10); CustomGizmos.HandlesColor(Gizmos.color); CustomGizmos.Arrow(0, Astronomy.SunLight.transform.position - (Astronomy.SunLight.transform.forward * Astronomy.Radius), Astronomy.SunLight.transform.rotation, 50); if (m_PathPositions.Count > 1000) { m_PathPositions.RemoveAt(0); } Vector3 _prior_pos = Vector3.zero; foreach (Vector3 _pos in m_PathPositions) { if (_prior_pos != Vector3.zero) { Gizmos.DrawLine(_prior_pos, _pos); } _prior_pos = _pos; } }
public void DrawMoveGizmos() { #if UNITY_EDITOR if (m_Owner == null || m_creature_control.Creature.Move.CurrentTarget == null) { return; } TargetObject _target = m_creature_control.Creature.Move.CurrentTarget; Vector3 _move_position = m_creature_control.Creature.Move.MovePosition; Vector3 _target_move_position = _target.TargetMovePosition; float _move_stop_distance = m_creature_control.Creature.Move.CurrentMove.MoveStopDistance; float _move_lateral_variance = m_creature_control.Creature.Move.CurrentMove.MoveLateralVariance; Vector3 _owner_pos = m_Owner.transform.position; _owner_pos.y = GetLevel(); _move_position.y = GetLevel(); _target_move_position.y = GetLevel(); CustomGizmos.OffsetPath(_owner_pos, 2, _move_position, _move_stop_distance); // PATH FROM CREATURE TO NEXT MOVE POSITION CustomGizmos.Circle(_move_position, _move_stop_distance, 5, false); // STOP DISTANCE RANGE if (m_creature_control.Creature.Move.CurrentMove.Type != MoveType.ESCAPE) { CustomGizmos.OffsetPath(_move_position, _move_stop_distance, _target_move_position, _target.TargetStopDistance); // PATH NEXT MOVE POSITION TO TARGET MOVE POSITION } if (_move_lateral_variance > 0) { float _max_range = _move_stop_distance + _move_lateral_variance; CustomGizmos.ZickZackCircle(_move_position, _move_lateral_variance, "", false); // RANDOM RANGE CustomGizmos.Circle(_move_position, _max_range, 5, true); // MAX MOVE RANGE } #endif }
private void DrawRegisterGizmos() { ICECreatureRegister _register = ICECreatureRegister.Instance; if (_register == null) { return; } if (!_register.UseDebug) { return; } Gizmos.color = new Color(Color.blue.r, Color.blue.g, Color.blue.b, 0.75f); Vector3 _s = new Vector3(0.5f, 0.15f, 0.5f); Gizmos.DrawCube(transform.position + (Vector3.up * 0.25f), _s); Gizmos.DrawCube(transform.position + (Vector3.up * 0.50f), _s); Gizmos.DrawCube(transform.position + (Vector3.up * 0.75f), _s); Gizmos.color = new Color(Color.blue.r, Color.blue.g, Color.blue.b, 1f); CustomGizmos.Text("CREATURE REGISTER", transform.position, Gizmos.color, 14, FontStyle.Bold); foreach (ReferenceGroupObject _group in _register.ReferenceGroupObjects) { if (_group.ReferenceGameObject == null) { continue; } if (_register.RegisterDebug.ShowReferenceGizmos && !_group.Status.isPrefab) { Gizmos.color = new Color(_register.RegisterDebug.ColorReferences.r, _register.RegisterDebug.ColorReferences.g, _register.RegisterDebug.ColorReferences.b, 0.25f); Vector3 _pos = _group.ReferenceGameObject.transform.position; float _size = Mathf.Clamp(_group.ReferenceGameObject.transform.lossyScale.magnitude, 0.25f, 1) * 0.25f; Gizmos.DrawSphere(_pos, _size); _pos.y += 2; if (_register.RegisterDebug.ShowReferenceGizmosText) { Gizmos.color = new Color(_register.RegisterDebug.ColorReferences.r, _register.RegisterDebug.ColorReferences.g, _register.RegisterDebug.ColorReferences.b, 1f); CustomGizmos.Text(_group.ReferenceGameObject.name + " (SCENE REFERENCE)", _pos, Gizmos.color, 12, FontStyle.Italic); } } if (_register.RegisterDebug.ShowCloneGizmos) { foreach (GameObject _item in _group.ActiveObjects) { if (_group.ReferenceGameObject == _item) { continue; } Gizmos.color = new Color(_register.RegisterDebug.ColorClones.r, _register.RegisterDebug.ColorClones.g, _register.RegisterDebug.ColorClones.b, 0.25f); Vector3 _pos = _item.transform.position; float _size = Mathf.Clamp(_item.transform.lossyScale.magnitude, 0.25f, 1) * 0.25f; Gizmos.DrawSphere(_pos, _size); if (_register.RegisterDebug.ShowCloneGizmosText) { _pos.y += 2; Gizmos.color = new Color(_register.RegisterDebug.ColorClones.r, _register.RegisterDebug.ColorClones.g, _register.RegisterDebug.ColorClones.b, 1f); CustomGizmos.Text(_item.name + " (CLONE)", _pos, Gizmos.color, 12, FontStyle.Italic); } } } if (_register.RegisterDebug.ShowSpawnPointGizmos && _group.PoolManagementEnabled) { foreach (SpawnPointObject _point in _group.ValidSpawnPoints) { if (_point.SpawnPointGameObject == null) { continue; } GameObject[] _objects = _point.GetAllSpawnPointGameObjects(); foreach (GameObject _object in _objects) { Gizmos.color = new Color(_register.RegisterDebug.ColorSpawnPoints.r, _register.RegisterDebug.ColorSpawnPoints.g, _register.RegisterDebug.ColorSpawnPoints.b, 0.25f); Vector3 _pos = _object.transform.position; float _size = Mathf.Clamp(_object.transform.lossyScale.magnitude, 0.25f, 1) * 0.25f; Gizmos.DrawSphere(_pos, _size); if (_point.UseRandomRect) { CustomGizmos.Box(_object.transform, _point.RandomRect, new Vector3(0, _point.RandomRect.y * 0.5f, 0)); } else { CustomGizmos.Circle(_pos, _point.SpawningRangeMin, CustomGizmos.GetBestDegrees(_point.SpawningRangeMin, 360), false); CustomGizmos.BeamCircle(_pos, _point.SpawningRangeMax, CustomGizmos.GetBestDegrees(_point.SpawningRangeMax, 360), false, _point.SpawningRangeMax - _point.SpawningRangeMin, "", false, true); } if (_register.RegisterDebug.ShowSpawnPointGizmosText) { _pos.z += _point.SpawningRangeMax; _pos.y += 4; Gizmos.color = new Color(_register.RegisterDebug.ColorSpawnPoints.r, _register.RegisterDebug.ColorSpawnPoints.g, _register.RegisterDebug.ColorSpawnPoints.b, 1f); CustomGizmos.Text(_point.SpawnPointGameObject.name + " (SP)", _pos, Gizmos.color, 12, FontStyle.Italic); } } } } } }
private void DrawBehaviourModeRuleGizmos(TargetObject _target, BehaviourModeRuleObject _rule) { #if UNITY_EDITOR if (_target == null || _target.IsValid == false || _rule == null) { return; } Vector3 _owner_position = m_Owner.transform.position; Vector3 _target_pos = _target.TargetPosition; Vector3 _target_move_position = _target.TargetMovePosition; float _target_stop_distance = _target.TargetStopDistance; float _target_selection_range = _target.Selectors.SelectionRange; //float _target_selection_angle = _target.Selectors.SelectionAngle; DrawOwnerGizmos(); if (Application.isPlaying) { DrawPathGizmos(); DrawMoveGizmos(); } float _level = GetLevel(); _owner_position.y = _level; _target_pos.y = _level; _target_move_position.y = _level; if (_rule.Move.Type == MoveType.DEFAULT) { } else if (_rule.Move.Type == MoveType.AVOID) { MoveContainer _move = _rule.Move; //float _radius = _target_selection_range + 0.25f;// _move.Avoid.MaxAvoidDistance;//( _target_selection_range / 2 ) + 0.25f; //float _angle = _move.Avoid.MaxDirectionAngle; Gizmos.color = MoveAvoidColor; UnityEditor.Handles.color = Gizmos.color; //DrawDirectionAngle( m_Owner.transform, _radius, _angle ); //DrawDirectionAngle( _target.TargetGameObject.transform, _radius, _angle ); Vector3 _right = Vector3.Cross(_target.TargetGameObject.transform.up, _target.TargetGameObject.transform.forward); Vector3 _avoid_pos_right = _target_pos + (_right * _move.Avoid.AvoidDistance); Vector3 _avoid_pos_left = _target_pos + (_right * -_move.Avoid.AvoidDistance); CustomGizmos.OffsetPath(_target_pos, 0, _avoid_pos_right, _move.MoveStopDistance); CustomGizmos.DottedCircle(_avoid_pos_right, _move.MoveStopDistance, 5, 2); CustomGizmos.OffsetPath(_target_pos, 0, _avoid_pos_left, _move.MoveStopDistance); CustomGizmos.DottedCircle(_avoid_pos_left, _move.MoveStopDistance, 5, 2); if (Application.isPlaying) { /* * Gizmos.color = Color.blue; * Gizmos.DrawLine( _target_pos, CreatureControl.Creature.Move.AvoidMovePosition ); * Gizmos.color = Color.red; * Gizmos.DrawLine( _target_pos, CreatureControl.Creature.Move.MovePosition ); */ } } else if (_rule.Move.Type == MoveType.ESCAPE) { MoveContainer _move = _rule.Move; float _inner_radius = (_target_selection_range / 2) + 0.25f; float _outer_radius = _inner_radius + _rule.Move.MoveSegmentLength; float _outer_radius_max = _inner_radius + _rule.Move.MoveSegmentLengthMax; float _outer_radius_min = _inner_radius + _rule.Move.MoveSegmentLengthMin; float _inner_angle = 0; float _outer_angle = _inner_angle + _move.Escape.RandomEscapeAngle; Gizmos.color = MoveEscapeColor; Vector3 _left_inner_pos = Tools.GetDirectionPosition(_target.TargetGameObject.transform, -_inner_angle, _inner_radius); Vector3 _right_inner_pos = Tools.GetDirectionPosition(_target.TargetGameObject.transform, _inner_angle, _inner_radius); Vector3 _left_outer_pos = Tools.GetDirectionPosition(_target.TargetGameObject.transform, -_outer_angle, _outer_radius); Vector3 _right_outer_pos = Tools.GetDirectionPosition(_target.TargetGameObject.transform, _outer_angle, _outer_radius); _target_pos.y = _level; _left_inner_pos.y = _level; _right_inner_pos.y = _level; _left_outer_pos.y = _level; _right_outer_pos.y = _level; Gizmos.DrawLine(_target_pos, _left_inner_pos); Gizmos.DrawLine(_target_pos, _right_inner_pos); Gizmos.DrawLine(_left_inner_pos, _left_outer_pos); Gizmos.DrawLine(_right_inner_pos, _right_outer_pos); CustomGizmos.Arc(_target.TargetGameObject.transform, _inner_radius, 1, -_inner_angle, _inner_angle, _level, false); CustomGizmos.Arc(_target.TargetGameObject.transform, _outer_radius, 1, -_outer_angle, _outer_angle, _level, false); CustomGizmos.Arc(_target.TargetGameObject.transform, _outer_radius_min, 1, -_outer_angle, _outer_angle, _level, true); CustomGizmos.Arc(_target.TargetGameObject.transform, _outer_radius_max, 1, -_outer_angle, _outer_angle, _level, true); // DENGER ZONE BEGIN _inner_radius += 0.25f; float _degree = CustomGizmos.GetBestDegrees(_inner_radius, _inner_angle); CustomGizmos.ArrowArc(_target.TargetGameObject.transform, _inner_radius, _degree, -_inner_angle, _inner_angle, _level); Transform _target_transform = _target.TargetGameObject.transform; Vector3 _center = _target_transform.position; Vector3 _center_pos = Tools.GetDirectionPosition(_target_transform, 0, _inner_radius + (_inner_radius / 10)); Vector3 _left_pos = Tools.GetDirectionPosition(_target_transform, -_inner_angle, _inner_radius); Vector3 _right_pos = Tools.GetDirectionPosition(_target_transform, _inner_angle, _inner_radius); _center.y = _level; _center_pos.y = _level; _left_pos.y = _level; _right_pos.y = _level; Gizmos.DrawLine(_center, _center_pos); Gizmos.DrawLine(_center, _left_pos); Gizmos.DrawLine(_center, _right_pos); } else if (_rule.Move.Type == MoveType.ORBIT) { MoveContainer _move = _rule.Move; float _degrees = CreatureControl.Creature.Move.OrbitDegrees; float _radius = _move.Orbit.Radius; if (Application.isPlaying) { _move = CreatureControl.Creature.Move.CurrentMove; _radius = CreatureControl.Creature.Move.OrbitRadius; } Gizmos.color = MoveOrbitColor; CustomGizmos.Orbit(m_Owner.transform.position, _target_move_position, _radius, _degrees, _move.Orbit.RadiusShift, _move.Orbit.MinDistance, _move.Orbit.MaxDistance, _level); } else if (_rule.Move.Type == MoveType.DETOUR) { Vector3 _detour_pos = _rule.Move.Detour.Position; _detour_pos.y = _level; Gizmos.color = MoveDetourColor; CustomGizmos.OffsetPath(_detour_pos, _rule.Move.MoveStopDistance, _target_move_position, _target_stop_distance); CustomGizmos.Circle(_detour_pos, _rule.Move.MoveStopDistance, 5, false); // STOP DISTANCE RANGE //DrawMoveGizmos( Vector3 _initial_position, Vector3 _move_position, float _stop_distance, float _random_range, Vector3 _target_position, float _target_stop_distance ) } #endif }