Beispiel #1
0
        private void Start()
        {
            initializePoolWhenPlayerItemPrefabIsLoaded = false;
            profileDataList    = new List <ProfileData>();
            membershipDataList = new List <MembershipData>();
            pooledScrollRect   = GetComponentInChildren <VerticalGridPooledScrollRect>();
            addPooledScrollRectObservers();
            playerAvatarRenderer = GetComponent <AvatarImageComponent>();
            AvatarImageComponent avatarImageComponent = playerAvatarRenderer;

            avatarImageComponent.OnImageReady = (Action <DataEntityHandle, Texture2D>)Delegate.Combine(avatarImageComponent.OnImageReady, new Action <DataEntityHandle, Texture2D>(onImageReady));
            initPlayersList();
            dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.ComponentAddedEvent <ProfileData> >(onProfileDataAdded);
            dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.ComponentAddedEvent <MembershipData> >(onMembershipDataAdded);
            PromptManager promptManager = Service.Get <PromptManager>();

            promptManager.PromptCreated = (Action <GameObject>)Delegate.Combine(promptManager.PromptCreated, new Action <GameObject>(onPromptCreated));
            List <string> playerSwids = getPlayerSwids();

            if (playerSwids.Count > 0)
            {
                Service.Get <INetworkServicesManager>().PlayerStateService.GetOnlinePlayersBySwids(playerSwids);
            }
            else
            {
                onlineStatusReceived = true;
            }
            Content.LoadAsync(onPlayerItemPrefabLoaded, PlayerItemContentKey);
            start();
            isInitialized = true;
        }
Beispiel #2
0
        private void OnDestroy()
        {
            if (playerAvatarRenderer != null)
            {
                AvatarImageComponent avatarImageComponent = playerAvatarRenderer;
                avatarImageComponent.OnImageReady = (Action <DataEntityHandle, Texture2D>)Delegate.Remove(avatarImageComponent.OnImageReady, new Action <DataEntityHandle, Texture2D>(onImageReady));
            }
            if (dataEntityCollection != null)
            {
                dataEntityCollection.EventDispatcher.RemoveListener <DataEntityEvents.ComponentAddedEvent <ProfileData> >(onProfileDataAdded);
            }
            if (profileDataList != null)
            {
                for (int i = 0; i < profileDataList.Count; i++)
                {
                    profileDataList[i].ProfileDataUpdated -= onProfileDataUpdated;
                }
            }
            if (membershipDataList != null)
            {
                for (int i = 0; i < membershipDataList.Count; i++)
                {
                    membershipDataList[i].MembershipDataUpdated -= onMembershipDataUpdated;
                }
            }
            removePooledScrollRectObservers();
            PromptManager promptManager = Service.Get <PromptManager>();

            promptManager.PromptCreated = (Action <GameObject>)Delegate.Remove(promptManager.PromptCreated, new Action <GameObject>(onPromptCreated));
            onDestroy();
        }