Unity - A计划(一年有效期) 扫二维码继续学习 二维码时效为半小时

(61评价)
价格: 2208.00元
贪吃蛇(Food无法设置parent)
lichunhui发起了问答2018-07-03
1
回复
464
浏览

代码

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);
    }
}

 

所有回复
发表回复
你还没有登录,请先 登录或 注册!