Example #1
0
        void CalcPositonsAndDrawBoxes()
        {
            foreach (var mesh_filter_object in this._mesh_filter_objects)
            {
                if (mesh_filter_object.gameObject.tag == "Target")
                {
                    GameObject liner;
                    if (!this._lines.ContainsKey(mesh_filter_object.gameObject))
                    {
                        liner = Instantiate(this._line_object, this._line_object.transform);
                        this._lines.Add(mesh_filter_object.gameObject, liner);
                    }
                    else
                    {
                        print("found Target");
                        liner = this._lines[mesh_filter_object.gameObject];
                    }

                    var bounds = mesh_filter_object.mesh.bounds;

                    //Bounds bounds;
                    //BoxCollider bc = GetComponent<BoxCollider>();
                    //if (bc != null)
                    //    bounds = bc.bounds;
                    //else
                    //return;

                    var v3Center  = bounds.center;
                    var v3Extents = bounds.extents;

                    var corners = NeodroidUtilities.ExtractCorners(v3Center, v3Extents, mesh_filter_object.transform);

                    liner.GetComponent <LineRenderer>().SetPosition(0, corners[4]);
                    liner.GetComponent <LineRenderer>().SetPosition(1, corners[5]);

                    NeodroidUtilities.DrawBox(
                        corners[0],
                        corners[1],
                        corners[2],
                        corners[3],
                        corners[4],
                        corners[5],
                        corners[6],
                        corners[7],
                        this.color);
                }
            }
        }
Example #2
0
        void Update()
        {
            if (this._draw_bounds)
            {
                var corners = NeodroidUtilities.ExtractCorners(
                    this.ActorBounds.center,
                    this.ActorBounds.extents,
                    this.transform);

                NeodroidUtilities.DrawBox(
                    corners[0],
                    corners[1],
                    corners[2],
                    corners[3],
                    corners[4],
                    corners[5],
                    corners[6],
                    corners[7],
                    Color.gray);
            }
        }