void OnDrawGizmosSelected ()
	{
		Gizmos.color = Color.red;

		Gizmos.DrawSphere (transform.position, 1f);

        // paint all
	    var p = this.transform.parent.GetComponent<ConvexBounds>();
	    if (p != null)
	    {
	        ConvexBounds.DrawGizmos(p);
	    }
	}
Example #2
0
//		protected override void OnAwake ()
//		{
//			// base.OnAwake ();
//
//			//if (bounds == null) {
//			//	bounds = GameObject.Find("@PeopleBounds").GetComponent<ConvexBounds>();
//			//	if (bounds == null || bounds.Bounds == null || bounds.Bounds.Length == 0) {
//			//		Debug.LogError("Random walk bounds were not initiated");
//			//	}
//			//}
//
//		 //   if (convexBounds.value == null)
//		 //   {
//		 //       currentBounds = bounds;
//		 //   }
//		 //   else
//		 //   {
//		 //       currentBounds = convexBounds.value.GetComponent<ConvexBounds>();
//		 //   }
//		 //   currentBounds = convexBounds.value.GetComponent<ConvexBounds>();
//		}

        protected override void OnExecute()
        {
            currentBounds = convexBounds.value;
            if (currentBounds == null)
            {
                Debug.LogError("Bounds not initialised!");
            }

            try
            {
                position.value = this.currentBounds.RandomPosition();
                EndAction(true);
            }
            catch (System.Exception ex)
            {
                Debug.LogError("Error creating random position: " + ex.Message);
                EndAction(false);
            }
        }
Example #3
0
    public static void DrawGizmos(ConvexBounds bounds)
    {
        bounds.CalculateCenter();
        Gizmos.color = new Color(1, 0, 0);

        if (bounds.Bounds.Length > 1)
        {
            for (var i = 1; i < bounds.Bounds.Length; i++)
            {
                if (bounds.Bounds[i] == null)
                {
                    return;
                }
                Gizmos.DrawLine(bounds.Bounds[i - 1].position, bounds.Bounds[i].position);
            }
            Gizmos.DrawLine(bounds.Bounds[0].position, bounds.Bounds[bounds.Bounds.Length - 1].position);
        }

        Gizmos.color = Color.green;
        Gizmos.DrawWireCube(bounds.Center, Vector3.one * 0.5f);

        Gizmos.DrawLine(
            new Vector3(bounds.BottomLeft.x, 31, bounds.BottomLeft.y),
            new Vector3(bounds.BottomLeft.x + (bounds.TopRight.x - bounds.BottomLeft.x), 31, bounds.BottomLeft.y));

        Gizmos.DrawLine(
            new Vector3(bounds.BottomLeft.x, 31, bounds.BottomLeft.y),
            new Vector3(bounds.BottomLeft.x, 31, bounds.BottomLeft.y + (bounds.TopRight.y - bounds.BottomLeft.y)));

        Gizmos.DrawLine(
            new Vector3(bounds.TopRight.x, 31, bounds.TopRight.y),
            new Vector3(bounds.TopRight.x - (bounds.TopRight.x - bounds.BottomLeft.x), 31, bounds.TopRight.y));


        Gizmos.DrawLine(
            new Vector3(bounds.TopRight.x, 31, bounds.TopRight.y),
            new Vector3(bounds.TopRight.x, 31, bounds.TopRight.y - (bounds.TopRight.y - bounds.BottomLeft.y)));
    }