Inheritance: SingletonComponent, IUpdatable
Example #1
0
        void Start()
        {
            connectionAdapter = (ConnectionAdapter)FindObjectOfType(typeof(ConnectionAdapter));

            if (connectionAdapter == null)
            {
                Debug.LogError("SocketIOAdapter: No object of type ConnectionAdapter was found in the scene.");
            }

            socketSim = SocketIOEditorSimulator.Instance;

            if (socketSim == null)
            {
                Debug.LogError("SocketIOAdapter: No SocketIOEditorSimulator.Instance was found in the scene.");
            }

            netUpdateHandler = NetworkUpdateHandler.Instance;

            if (netUpdateHandler == null)
            {
                Debug.LogError("SocketIOAdapter: No netUpdateHandler was found in the scene.");
            }

            SetName();
        }
        public void Start()
        {
            var instMgr = GameObject.Find(InstantiationManagerName);

            if (!instMgr)
            {
                throw new System.Exception($"You must have a GameObject named {InstantiationManagerName} in your scene.");
            }
            _ClientSpawnManager = instMgr.GetComponent <ClientSpawnManager>();

            if (!_ClientSpawnManager)
            {
                throw new System.Exception($"{InstantiationManagerName} must have a ClientSpawnManager component.");
            }

            var netMgr = GameObject.Find(NetworkManagerName);

            if (!netMgr)
            {
                throw new System.Exception($"You must have a GameObject named {NetworkManagerName} in your scene.");
            }
            _NetworkUpdateHandler = netMgr.GetComponent <NetworkUpdateHandler>();

            if (!_NetworkUpdateHandler)
            {
                throw new System.Exception($"{NetworkManagerName} must have a NetworkUpdateHandler component.");
            }
        }
        public void Send()
        {
            var message = JsonUtility.ToJson(this);

#if UNITY_WEBGL && !UNITY_EDITOR
            NetworkUpdateHandler.BrowserEmitMessage(message);
#else
            //TODO(Brandon): find a way to use SocketIOEditorSimulator from here
#endif
        }
        void Start()
        {
            entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

            netUpdateHandler = NetworkUpdateHandler.Instance;

            if (netUpdateHandler == null)
            {
                throw new System.Exception("NetworkUpdateHandler instance not found.");
            }
        }
Example #5
0
        IEnumerator Start()
        {
            netUpdateHandler = NetworkUpdateHandler.Instance;

            if (netUpdateHandler == null)
            {
                throw new System.Exception("NetworkUpdateHandler instance not found.");
            }

            //WebGLMemoryStats.LogMoreStats("MainClientUpdater Start BEFORE");
            entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

            //if we are missing our avatarentitygroup in editor try to get it from our game object
            if (!mainClientAvatarEntityGroup)
            {
                mainClientAvatarEntityGroup = GetComponent <AvatarEntityGroup>();
            }

            if (!mainClientAvatarEntityGroup)
            {
                Debug.LogError("No mainclientAvatarEntityGroup found in  MainClientUpdater.cs to use to send updates to network", gameObject);
            }

            //cashe our avatar transform references
            (headEntityTransform, leftHandEntityTransform, rightHandEntityTransform) = (mainClientAvatarEntityGroup.avatarComponent_Head.transform, mainClientAvatarEntityGroup.avatarComponent_hand_L.transform, mainClientAvatarEntityGroup.avatarComponent_hand_R.transform);

            //get references to AnimControllers to send anim state info
            (leftHandAnimator, rightHandAnimator) = (leftHandEntityTransform.GetComponent <Animator>(), rightHandEntityTransform.GetComponent <Animator>());

            if (!rightHandAnimator || !leftHandAnimator)
            {
                Debug.LogError("We are missing our Animator Controller from our hands in MainClientUpdater");
            }

            //WebGLMemoryStats.LogMoreStats("MainClientUpdater Start IN_MIDDLE");

            //Wait for the avatar to finish loading to allow us to continue and start sending updates
            yield return(new WaitUntil(() =>
            {
                return GameStateManager.Instance.isAvatarLoadingFinished;
            }));

            //Register our OnUpdate funcion to start sending updates
            GameStateManager.Instance.RegisterUpdatableObject(this);

            //Grab current position of hands to detect if they have moved to avoid rendering them when they havent;
            leftHandOriginalLocalPosition = mainClientAvatarEntityGroup.avatarComponent_hand_L.transform.localPosition;

            rightHandOriginalLocalPosition = mainClientAvatarEntityGroup.avatarComponent_hand_R.transform.localPosition;
        }
Example #6
0
        public void Start()
        {
            if (socketIODisplay == null)
            {
                Debug.LogError("socketIODisplay Text component was not assigned in ConnectionAdapter");
            }

            NetworkUpdateHandler netHandler = NetworkUpdateHandler.Instance;

            KomodoEventManager.StartListening("connection.leaveAndRejoin", () =>
            {
                SocketIOAdapter.Instance.LeaveAndRejoin();
            });

            KomodoEventManager.StartListening("connection.closeConnectionAndRejoin", () =>
            {
                SocketIOAdapter.Instance.CloseConnectionAndRejoin();
            });
        }