Exemple #1
0
    public static void AddComponent(GameObject obj, ScriptTable table)
    {
        if (obj == null)
        {
            return;
        }
        ScriptComponent com = obj.AddComponent <ScriptComponent>();

        com.Initialize(Launch.Script, table);
    }
Exemple #2
0
        /// <summary>
        ///   Add the provided script to the script system.
        /// </summary>
        /// <param name="script">The script to add.</param>
        public void Add(ScriptComponent script)
        {
            script.Initialize(Services);
            registeredScripts.Add(script);

            // Register script for Start() and possibly async Execute()
            scriptsToStart.Add(script);

            // If it's a synchronous script, add it to the list as well
            if (script is SyncScript syncScript)
            {
                syncScript.UpdateSchedulerNode                    = Scheduler.Create(syncScript.Update, syncScript.Priority | UpdateBit);
                syncScript.UpdateSchedulerNode.Value.Token        = syncScript;
                syncScript.UpdateSchedulerNode.Value.ProfilingKey = syncScript.ProfilingKey;
                syncScripts.Add(syncScript);
            }
        }