{
Private List
Private Stack
Private GameObject Box;
private GameObject Bullet;
Private GameObject nowBox;
Private float fireTime nowTime;
//Use this for initialization
Void the Start ()
{
//Boxlist=new List
FreeGameobject=new Stack
FireTime=1 f;
NowTime=0 f;
Box=Resources. The Load (" Wooden Box ") as GameObject.
Bullet=Resources. The Load (" Bullet ") as GameObject.
for(int i=0; i <10; I++)
{
For (int j=0; J & lt; 5; J++)
{
If (FreeGameobject. Count & lt;=0)
{
NowBox=Instantiate (Box);
}
The else
{
NowBox=FreeGameobject. Pop ();
}
NowBox. The transform. The position +=new Vector3 (- I, j, 0);
//Boxlist. Add (nowBox);
}
}
}
//Update is called once per frame
Void the Update ()
{
}
}
If you don't add the nowBox list is normal, interface shows the 50 cases, but if adding nowBox list will not display, but the list is the 50 cases
CodePudding user response:
Private GameObject nowBox should be on the for (int I=0; i <10; Defined within i++) cycleCodePudding user response:
I ran your code, didn't you said problems, problems may occur in the rest of your logic,CodePudding user response:
Has also had the same problem, today I checked the information, should feel in private ListBecause the UNITY of public object serialization, single not private object serialization,
In front of it plus [HideInInspector] [SerializedField] to go,
CodePudding user response:
I hope it can help youhttp://blog.csdn.net/wang371372/article/details/27209767