返回的类会影响T本事内容吗??
官网查的:
Object GetComponent (
PropertyDescriptor propertyDescriptor
)
B类中的a.i会改变A中的类的i的值,可是这个 GetComponent 不是一个地址形式,为什么会改变呢??
using UnityEngine;
using System.Collections;
public class B : MonoBehaviour {
A a;
A a1=new A();
// Use this for initialization
void Start () {
a = GetComponent<A>();
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.A))
{
a1.i = 4;
}
}
using UnityEngine;
using System.Collections;
public class A : MonoBehaviour {
public int i;
// Use this for initialization
void Start () {
i = 3;
}
// Update is called once per frame
void Update () {
if (i == 4)
print("i=4 \n");
}
}