Ejemplo n.º 1
0
        // private Thread _updateThread;
        //
        // private Stopwatch _updateWatch;
        //
        // private long _updateInterval; //cache it

        public void RegisterUpdater(ClientGameObjectUpdater upd)
        {
            if (_updaters == null)
            {
                _updaters = new List <ClientGameObjectUpdater>();
            }

            lock (_updaters)
            {
                _updaters.Add(upd);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Агент обьекта: спавн префаба
        /// </summary>
        async Task SpawnPrefab()
        {
            if (_bundleId == Guid.Empty)//не бандл
            {
                //Переходим в поток Unity
                await new WaitForEndOfFrame();

                GameObject prot = Resources.Load <GameObject>(_prefab);


                obj = GameObject.Instantiate(prot);



                _updater = obj.AddComponent <ClientGameObjectUpdater>();
                _updater.SetParent(this);
                // Создание Behaviours object - находимся в потоке Unity
                AddBehaviourComponents(obj);
            }
            else
            {
                await new WaitForEndOfFrame(); //Переходим в поток Unity

                GameObject prot = await RootComponents.Instance.AssetLoader.GetWebAssetAsync <GameObject>(_prefab, _bundleId);



                obj = GameObject.Instantiate(prot);



                _updater = obj.AddComponent <ClientGameObjectUpdater>();
                _updater.SetParent(this);
                // Создание Behaviours object - находимся в потоке Unity
                // await AddBehaviourComponents(obj);
                AddBehaviourComponents(obj);
            }
        }