代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FoodMaker : MonoBehaviour
{
private int Left = -310, Right = 610, Up = 330, Down = -330;
public GameObject Food;
private Transform FoodHolder;
void Start()
{
MakeFood();
FoodHolder = GameObject.Find("FoodHolder").transform;
}
void Update()
{
}
private void MakeFood()
{
int Index = Random.Range(0, 255);
GameObject NewFood = Instantiate(Food);
NewFood.transform.SetParent(FoodHolder, false);
//NowFood.GetComponent<>().color
//NewFood.transform.localPosition = new Vector3(Random.Range(Left, Right), Random.Range(Down, Up), 0);
}
}