Exemplo n.º 1
0
        private void Start()
        {
            if (PluginConfig.Instance.ScreenFillBlack)
            {
                _renderTexture         = new RenderTexture(Screen.width, Screen.height, 24);
                _screenCameraBehaviour = this.gameObject.AddComponent <ScreenCameraBehaviour>();
                _screenCameraBehaviour.SetCameraInfo(new Vector2(0, 0), new Vector2(Screen.width, Screen.height), -2000);
                _screenCameraBehaviour.SetRenderTexture(_renderTexture);
            }

            ShaderLoad();
            _cameraMovePointer = this.gameObject.AddComponent <CameraMoverPointer>();
            CameraUtilities.AddNewCamera(Plugin.MainCamera);
            MultiplayerSessionInit = false;

            externalSender = new GameObject("ExternalSender").AddComponent <ExternalSender>();
            externalSender.transform.SetParent(transform);

            if (CustomUtils.IsModInstalled("VMCAvatar"))
            {
                existsVMCAvatar = true;
            }
            _webCamTexture = new WebCamTexture();
            webCamDevices  = WebCamTexture.devices;
        }
Exemplo n.º 2
0
        internal virtual void CreateScreenRenderTexture()
        {
            HMMainThreadDispatcher.instance.Enqueue(delegate
            {
                var replace = false;
                if (_camRenderTexture == null)
                {
                    _camRenderTexture = new RenderTexture(1, 1, 24);
                    replace           = true;
                }
                else
                {
                    if (Config.fitToCanvas != _prevFitToCanvas || Config.antiAliasing != _prevAA || Config.screenPosX != _prevScreenPosX || Config.screenPosY != _prevScreenPosY || Config.renderScale != _prevRenderScale || Config.screenHeight != _prevScreenHeight || Config.screenWidth != _prevScreenWidth || Config.layer != _prevLayer)
                    {
                        replace = true;

                        _cam.targetTexture = null;
                        _screenCamera.SetRenderTexture(null);
                        _screenCamera.SetCameraInfo(new Vector2(0, 0), new Vector2(0, 0), -1000);

                        _camRenderTexture.Release();
                    }
                }

                if (!replace)
                {
                    //Logger.Log("Don't need to replace");
                    return;
                }

                if (Config.fitToCanvas)
                {
                    Config.screenPosX   = 0;
                    Config.screenPosY   = 0;
                    Config.screenWidth  = Screen.width;
                    Config.screenHeight = Screen.height;
                }

                _lastRenderUpdate = DateTime.Now;
                //GetScaledScreenResolution(Config.renderScale, out var scaledWidth, out var scaledHeight);
                _camRenderTexture.width  = Mathf.Clamp(Mathf.RoundToInt(Config.screenWidth * Config.renderScale), 1, int.MaxValue);
                _camRenderTexture.height = Mathf.Clamp(Mathf.RoundToInt(Config.screenHeight * Config.renderScale), 1, int.MaxValue);

                _camRenderTexture.useDynamicScale = false;
                _camRenderTexture.antiAliasing    = Config.antiAliasing;
                _camRenderTexture.Create();

                _cam.targetTexture = _camRenderTexture;
                _previewMaterial.SetTexture("_MainTex", _camRenderTexture);
                _screenCamera.SetRenderTexture(_camRenderTexture);
                _screenCamera.SetCameraInfo(Config.ScreenPosition, Config.ScreenSize, Config.layer);

                _prevFitToCanvas  = Config.fitToCanvas;
                _prevAA           = Config.antiAliasing;
                _prevRenderScale  = Config.renderScale;
                _prevScreenHeight = Config.screenHeight;
                _prevScreenWidth  = Config.screenWidth;
                _prevLayer        = Config.layer;
                _prevScreenPosX   = Config.screenPosX;
                _prevScreenPosY   = Config.screenPosY;
            });
        }