码迷,mamicode.com
首页 > 其他好文 > 详细

untiy中操作obj

时间:2018-03-31 13:15:55      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:unit   nsf   start   object   elf   mon   pac   time   transform   

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class sh : MonoBehaviour {
    public GameObject cube1;
    public GameObject cube2;
    public GameObject cube3;

    // Use this for initialization
    void Start () {            
            Debug.Log ("hello world");        
        //第一种拖过来,第二种程序绑定
        cube1 = GameObject.Find("Cube1");  
        cube2 = GameObject.Find("Cube2");  
        cube3 = GameObject.Find("Cube3"); 

    }
    
    // Update is called once per frame
    void Update () {
        //旋转
        //this.transform.Rotate (Vector3.up*1,Space.Self);
        //this.transform.Translate (-Vector3.left * 0.2f, Space.World);
        /*this.transform.localScale = 
            new Vector3(1,
                        1 + Mathf.Sin(Time.time), 
                        1 + Mathf.Sin(Time.time));  */
        cube1.transform.Translate(Vector3.up*0.1f, Space.World);  
        cube2.transform.Rotate(Vector3.up*1,Space.Self);  
        cube3.transform.localScale = new Vector3(1 + Mathf.Sin(Time.time), 1 + Mathf.Sin(Time.time), 1 + Mathf.Sin(Time.time));
    }

}

 

untiy中操作obj

标签:unit   nsf   start   object   elf   mon   pac   time   transform   

原文地址:https://www.cnblogs.com/fengdaren/p/8681656.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!