- 最后登录
- 2016-8-29
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 23585
- 纳金币
- 20645
- 精华
- 62
|
- 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
|
|