一、单例模式 脚本A: 在需要被调用的类里这样写: using System.Collections; using System.Collections.Generic; using UnityEngine; public class UIControl : MonoBehaviour { public static UIControl UIController; private void Awake() { UIController = this; } public void switchBag() { } } 脚本B: 在其他类里调用: using System.Collections; using System.Collections.Generic; using UnityEngine; public class GameControl : MonoBehaviour { void myFunc(){ UIControl.UIController.switchBag(); } } 如果出现无法识别上下文的提示,检查一下以下问题:...
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile