Ejemplo n.º 1
0
        public void Setup(List <Texture2D> textureList, string videoURL, float?animatedTextureSpeed, ModelComponentType modelComponentType, ModelProperties modelProperties, ModelSharedProperties modelSharedProperties)
        {
            //Debug.Log("videosetup " + gameObject.transform.parent.name + " imagecount " + textureList.Count + " " + videoURL + " " + (videoPlayer == null));

            this.modelProperties       = modelProperties;
            this.modelComponentType    = modelComponentType;
            this.imageList             = null;
            this.modelSharedProperties = modelSharedProperties;
            this.dummyNode             = gameObject.transform.parent.transform.parent.gameObject;

            string layer = LayerMask.LayerToName(gameObject.layer);

            if (layer.StartsWith("Arcade"))
            {
                layerMask   = LayerMask.GetMask("Arcade/ArcadeModels", "Arcade/GameModels", "Arcade/PropModels");
                thisCamera  = ArcadeManager.arcadeCameras[ArcadeType.FpsArcade];
                arcadeLayer = true;
            }
            else
            {
                layerMask   = LayerMask.GetMask("Menu/ArcadeModels", "Menu/GameModels", "Menu/PropModels");
                thisCamera  = ArcadeManager.arcadeCameras[ArcadeType.CylMenu];
                arcadeLayer = false;
            }

            if (ArcadeManager.arcadeConfiguration.arcadeType == ArcadeType.FpsArcade.ToString() || ArcadeManager.arcadeConfiguration.arcadeType == ArcadeType.FpsMenu.ToString())
            {
                isCylArcade = false;
                maxDistance = 5f;
            }
            else
            {
                isCylArcade = true;
                maxDistance = 10000f;
            }

            // Setup image, nescessary for magic pixels and to get an unique material instance.
            Texture2D tex = null;

            if (textureList.Count > 0)
            {
                tex = textureList[0];
            }
            ModelImageSetup modelImageSetup = GetComponent <ModelImageSetup>();

            if (modelImageSetup == null)
            {
                modelImageSetup = gameObject.AddComponent <ModelImageSetup>();
            }
            modelImageSetup.Setup(tex, modelSharedProperties.renderSettings, modelProperties, modelComponentType);

            if (videoURL != null && videoPlayer == null)
            {
                videoPlayer = gameObject.GetComponent <UnityEngine.Video.VideoPlayer>();
            }
            if (animatedTextureSpeed != null)
            {
                waitTime = animatedTextureSpeed.Value;
            }
            videoEnabled = (ModelVideoEnabled)System.Enum.Parse(typeof(ModelVideoEnabled), modelSharedProperties.videoOnModelEnabled);
            if (videoURL == null)
            {
                videoEnabled = ModelVideoEnabled.Never;
            }
            else
            {
                if (videoPlayer != null && videoEnabled != ModelVideoEnabled.Never)
                {
                    videoPlayer.SetDirectAudioMute(0, true);
                    videoPlayer.enabled = true;
                    videoPlayer.url     = videoURL;
                }
            }
            if (textureList.Count > 0)
            {
                imageList = textureList;
                if (renderer != null)
                {
                    renderer.material.mainTexture = textureList[0];
                }
            }
            else
            {
                if (renderer != null && transform.parent.CompareTag("gamemodel") && modelComponentType == ModelComponentType.Screen)
                {
                    renderer.material.mainTexture = Texture2D.blackTexture;
                }
            }
            if (renderer != null && (textureList.Count > 0 || videoEnabled != ModelVideoEnabled.Never))
            {
                SetupVideoPlayer();
            }
        }