繁体   English   中英

如何从另一个脚本中获取此信息?

[英]How do I get this information from another script?

如何在我的 rigTransform 脚本中创建一个执行此操作的 if 语句?:(如果 PickupAndDrop 脚本pickup void Weapon1Layer.enabled = false)

//this script is called RigTransform:
{
    PickupAndDrop GET;
    public RigTransform rigTransform;
    // Start is called before the first frame update
    void Start()
    {
        rigTransform.enabled = false;
    }

    // Update is called once per frame
    void Update()
    {
       if(GET.PickUp().weapon1Layer.enabled = false)
        { 

        }
        
    }
}

//this script is called PickupAndDrop:

public void PickUp()
    {
        weapon1Layer.enabled = false;
        weapon1Layer.weight = 1f;
        currentWeapon = wp;
        currentWeapon.transform.position = equipPosition.position;
        currentWeapon.transform.parent = equipPosition;
        currentWeapon.transform.localEulerAngles = new Vector3(0f, 180f, 0);
        currentWeapon.GetComponent<Rigidbody>().isKinematic = true;
    }

更改 RigTransform 脚本,使其显示为:

    // Update is called once per frame
    void Update()
    {
       if(!GET.weapon1Layer.enabled)
        { 

        }
        
    }

您还应该公开PickupAndDrop GET变量,以便您可以自己设置引用或编写某种 Function 以编程方式执行此操作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM