Exemple #1
0
    /*
     * 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");
        }
    }
Exemple #2
0
 void Update()
 {
     if (flags.hasUpdate)
     {
         instance.Invoke(nameof(Update));
     }
 }