using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DrawPath : MonoBehaviour {
public List<Vector3> mMapList = new List<Vector3>();//I lost ()
// Use this for initialization
void Start () {
mMapList.Add(Vector3.zero);
//mMapList.Add(new Vector3(10, 0, 0));
mMapList.Add(new Vector3(10, 0, 10));
mMapList.Add(new Vector3(5, 0, 2));
}
// Update is called once per frame
void Update () {
}
private void OnDrawGizmos()
{
Gizmos.color = Color.green;
if (mMapList.Count > 0)
{
Gizmos.DrawCube(mMapList[0], new Vector3(0.98f, 0.98f, 0.98f));//0.98f for blank . No using Vector3.one
}
Gizmos.color = Color.red;
int _x, _z;
for(int i=1; i < mMapList.Count; i++)
{
_x = (int)mMapList[i - 1].x;
_z = (int)mMapList[i - 1].z;//mml is ok to type out by short cut :)
while (_x > mMapList[i].x)//only using "while" the logic can run and can circulate . using "if" are you sucker,zyn?
{
_x--;
Gizmos.DrawCube(new Vector3(_x, 0, _z), new Vector3(0.98f, 0.98f, 0.98f));
}
while (_x < mMapList[i].x)
{
_x++;
Gizmos.DrawCube(new Vector3(_x, 0, _z), new Vector3(0.98f, 0.98f, 0.98f));
}
while (_z > mMapList[i].z)
{
_z--;
Gizmos.DrawCube(new Vector3(_x, 0, _z), new Vector3(0.98f, 0.98f, 0.98f));
}
while (_z < mMapList[i].z)
{
_z++;//--change to++ : logic bug
Gizmos.DrawCube(new Vector3(_x, 0, _z), new Vector3(0.98f, 0.98f, 0.98f));
}
//Gizmos.DrawCube(mMapList[i], Vector3.one);
}
//Gizmos.DrawCube(Vector3.zero/*以它的左下角为圆心*/, Vector3.one/*它的宽度大小*/);
//Gizmos.DrawCube(new Vector3(1,0,1), Vector3.one);
//Gizmos.DrawCube(new Vector3(2, 0, 2), Vector3.one);
//Gizmos.DrawCube(new Vector3(3, 0, 3), Vector3.one);
//Gizmos.DrawCube(new Vector3(4, 0, 4), Vector3.one);
Gizmos.color = Color.yellow;
if (mMapList.Count > 0)
{
Gizmos.DrawCube(mMapList[mMapList.Count-1], new Vector3(0.98f, 0.98f, 0.98f));//0.98f for blank . No using Vector3.one
}
}
}
using System.Collections.Generic;
using UnityEngine;
public class DrawPath : MonoBehaviour {
public List<Vector3> mMapList = new List<Vector3>();//I lost ()
// Use this for initialization
void Start () {
mMapList.Add(Vector3.zero);
//mMapList.Add(new Vector3(10, 0, 0));
mMapList.Add(new Vector3(10, 0, 10));
mMapList.Add(new Vector3(5, 0, 2));
}
// Update is called once per frame
void Update () {
}
private void OnDrawGizmos()
{
Gizmos.color = Color.green;
if (mMapList.Count > 0)
{
Gizmos.DrawCube(mMapList[0], new Vector3(0.98f, 0.98f, 0.98f));//0.98f for blank . No using Vector3.one
}
Gizmos.color = Color.red;
int _x, _z;
for(int i=1; i < mMapList.Count; i++)
{
_x = (int)mMapList[i - 1].x;
_z = (int)mMapList[i - 1].z;//mml is ok to type out by short cut :)
while (_x > mMapList[i].x)//only using "while" the logic can run and can circulate . using "if" are you sucker,zyn?
{
_x--;
Gizmos.DrawCube(new Vector3(_x, 0, _z), new Vector3(0.98f, 0.98f, 0.98f));
}
while (_x < mMapList[i].x)
{
_x++;
Gizmos.DrawCube(new Vector3(_x, 0, _z), new Vector3(0.98f, 0.98f, 0.98f));
}
while (_z > mMapList[i].z)
{
_z--;
Gizmos.DrawCube(new Vector3(_x, 0, _z), new Vector3(0.98f, 0.98f, 0.98f));
}
while (_z < mMapList[i].z)
{
_z++;//--change to++ : logic bug
Gizmos.DrawCube(new Vector3(_x, 0, _z), new Vector3(0.98f, 0.98f, 0.98f));
}
//Gizmos.DrawCube(mMapList[i], Vector3.one);
}
//Gizmos.DrawCube(Vector3.zero/*以它的左下角为圆心*/, Vector3.one/*它的宽度大小*/);
//Gizmos.DrawCube(new Vector3(1,0,1), Vector3.one);
//Gizmos.DrawCube(new Vector3(2, 0, 2), Vector3.one);
//Gizmos.DrawCube(new Vector3(3, 0, 3), Vector3.one);
//Gizmos.DrawCube(new Vector3(4, 0, 4), Vector3.one);
Gizmos.color = Color.yellow;
if (mMapList.Count > 0)
{
Gizmos.DrawCube(mMapList[mMapList.Count-1], new Vector3(0.98f, 0.98f, 0.98f));//0.98f for blank . No using Vector3.one
}
}
}