纳金网
标题:
Unity3d教你如何同场景不同物体传值
[打印本页]
作者:
王者再临
时间:
2014-10-31 15:23
标题:
Unity3d教你如何同场景不同物体传值
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour {
//Unity3d:www.unitymanual.com
public int allScore=100;
// Update is called once per frame
void Update () {
allScore = 100;
}
}
复制代码
这个脚本放在cube上,我想调用这个allScore。
using UnityEngine;
using System.Collections;
public class text : MonoBehaviour {
public GameObject Obj1;
// Use this for initialization
void Start () {
Obj1 = GameObject.Find("Cube");
Score script=Obj1.GetComponent<Score>();
Debug.Log(script.allScore);
}
// Update is called once per frame
void Update () {
}
}
复制代码
就可以打印出allScore了。
* 版权声明:转载时请以超链接形式标明文章原始出处和作者信息
* 本文链接:http://www.unitymanual.com/7183.html
作者:
HIDEOKOJIMA
时间:
2014-10-31 17:42
Thanks for sharing this one !
作者:
cclove
时间:
2014-10-31 17:45
哈哈,高级。不同场景间怎么传值呢。。。
欢迎光临 纳金网 (http://go.narkii.com/club/)
Powered by Discuz! X2.5