/* * public GameObject LoadPrefab(string path) * { * return Resources.Load<GameObject>(path); * } */ public void Bind(string src) { this.src = src; var scriptConfig = ScriptConfig.Default; scriptConfig.PrewarmTypes = new Type[] { typeof(Collider), typeof(Transform), typeof(Vector3), typeof(Vector2), typeof(Vector4), typeof(GameObject) }; runner = CScript.CreateRunner(src, scriptConfig); RuntimeScript.runner = runner; instance = runner.Override( GetBindableClass(), this); BuildFlags(); if (overrideFields != null) { foreach (var f in overrideFields) { instance.SetPropertyOrField(f.Key, HybInstance.Object(f.Value)); } overrideFields = null; } if (flags.hasOnBind) { instance.Invoke("OnBind"); } }
void Update() { if (flags.hasUpdate) { instance.Invoke(nameof(Update)); } }