Example #1
0
	public static void SetCamera (CameraClearFlags clearFlags, bool useOrtho) {
		if (Camera.main == null) {
			LogError("Vector.SetCamera: no camera tagged \"Main Camera\" found");
			return;
		}
		SetCamera (Camera.main, clearFlags, useOrtho);
	}
Example #2
0
	public static void SetCamera (Camera thisCamera, CameraClearFlags clearFlags, bool useOrtho) {
		if (!cam) {
			cam = new GameObject("VectorCam", typeof(Camera)).camera;
			DontDestroyOnLoad(cam);
		}
		cam.depth = thisCamera.depth+1;
		cam.clearFlags = clearFlags;
		cam.orthographic = useOrtho;
		useOrthoCam = useOrtho;
		if (useOrtho) {
			cam.orthographicSize = Screen.height/2;
			cam.farClipPlane = 101.1f;
			cam.nearClipPlane = .9f;
		}
		else {
			cam.fieldOfView = 90.0f;
			cam.farClipPlane = Screen.height/2 + .0101f;
			cam.nearClipPlane = Screen.height/2 - .0001f;
		}
		cam.transform.position = new Vector3(Screen.width/2 - .5f, Screen.height/2 - .5f, 0.0f);
		cam.transform.eulerAngles = Vector3.zero;
		cam.cullingMask = 1 << vectorLayer;
		cam.backgroundColor = thisCamera.backgroundColor;
		
		thisCamera.cullingMask = thisCamera.cullingMask & (-1 ^ (1 << vectorLayer));
		camTransform = thisCamera.transform;
		cam3D = thisCamera;
		oldPosition = camTransform.position + Vector3.one;
		oldRotation = camTransform.eulerAngles + Vector3.one;
	}
Example #3
0
 // Use this for initialization
 void Start()
 {
     missing = false;
     clearFlag = Camera.main.clearFlags;
     cullingMask = Camera.main.cullingMask;
     clearColor = Camera.main.backgroundColor;
 }
Example #4
0
    // Use this for initialization
    void Start()
    {
        vxe = VoxelExtractionPointCloud.Instance;
        biome = BiomeScript.Instance;
        defaultFlag = leftcam.clearFlags;
        defaultLightIntensity = light.intensity;
        fourpts = new Vector3[2];

        if(cubeswitch != null)
        {
            initPts();
        }
    }
			internal SavedCamera(Camera source)
			{
				this.near = source.nearClipPlane;
				this.far = source.farClipPlane;
				this.pixelRect = source.pixelRect;
				this.pos = source.transform.position;
				this.rot = source.transform.rotation;
				this.clearFlags = source.clearFlags;
				this.cullingMask = source.cullingMask;
				this.fov = source.fieldOfView;
				this.orthographicSize = source.orthographicSize;
				this.isOrtho = source.orthographic;
			}
        public static ClearFlag GetCameraClearFlag(Camera camera)
        {
            if (camera == null)
            {
                throw new ArgumentNullException("camera");
            }

            CameraClearFlags cameraClearFlags = camera.clearFlags;

#if UNITY_EDITOR
            // We need public API to tell if FrameDebugger is active and enabled. In that case
            // we want to force a clear to see properly the drawcall stepping.
            // For now, to fix FrameDebugger in Editor, we force a clear.
            cameraClearFlags = CameraClearFlags.SolidColor;
#endif

            // LWRP doesn't support CameraClearFlags.DepthOnly and CameraClearFlags.Nothing.
            // CameraClearFlags.DepthOnly has the same effect of CameraClearFlags.SolidColor
            // CameraClearFlags.Nothing clears Depth on PC/Desktop and in mobile it clears both
            // depth and color.
            // CameraClearFlags.Skybox clears depth only.

            // Implementation details:
            // Camera clear flags are used to initialize the attachments on the first render pass.
            // ClearFlag is used together with Tile Load action to figure out how to clear the camera render target.
            // In Tile Based GPUs ClearFlag.Depth + RenderBufferLoadAction.DontCare becomes DontCare load action.
            // While ClearFlag.All + RenderBufferLoadAction.DontCare become Clear load action.
            // In mobile we force ClearFlag.All as DontCare doesn't have noticeable perf. difference from Clear
            // and this avoid tile clearing issue when not rendering all pixels in some GPUs.
            // In desktop/consoles there's actually performance difference between DontCare and Clear.

            // RenderBufferLoadAction.DontCare in PC/Desktop behaves as not clearing screen
            // RenderBufferLoadAction.DontCare in Vulkan/Metal behaves as DontCare load action
            // RenderBufferLoadAction.DontCare in GLES behaves as glInvalidateBuffer

            // Always clear on first render pass in mobile as it's same perf of DontCare and avoid tile clearing issues.
            if (Application.isMobilePlatform)
            {
                return(ClearFlag.All);
            }

            if ((cameraClearFlags == CameraClearFlags.Skybox && RenderSettings.skybox != null) ||
                cameraClearFlags == CameraClearFlags.Nothing)
            {
                return(ClearFlag.Depth);
            }

            return(ClearFlag.All);
        }
Example #7
0
        /// <summary>
        /// Set up the list of cameras to render for this scene and the initial position
        /// corresponding to the origin in the real world device coordinate system.
        /// </summary>
        public void SetupScene()
        {
            // capture the UI camera
            GameObject kspUiCameraGameObject = GameObject.Find("UIMainCamera");

            if (kspUiCameraGameObject != null)
            {
                KspUiCamera = kspUiCameraGameObject.GetComponent <Camera>();
            }
            if (KspUiCamera == null)
            {
                Utils.LogError("Could not find UIMainCamera component!");
            }
            else
            {
                KspUiCameraBackgroundColor = KspUiCamera.backgroundColor;
                KspUiCameraClearFlags      = KspUiCamera.clearFlags;
            }

            // set up game-scene-specific cameras
            switch (HighLogic.LoadedScene)
            {
            case GameScenes.MAINMENU:
                SetupMainMenuScene();
                break;

            case GameScenes.FLIGHT:
                if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA)
                {
                    SetupFlightIvaScene();
                }
                else if (FlightGlobals.ActiveVessel.isEVA)
                {
                    SetupFlightEvaScene();
                }
                break;

            case GameScenes.EDITOR:
                SetupEditorScene();
                break;

            default:
                throw new Exception("Cannot setup VR scene, current scene \"" +
                                    HighLogic.LoadedScene + "\" is invalid.");
            }

            CurrentPosition = InitialPosition;
            CurrentRotation = InitialRotation;
        }
Example #8
0
        // Use this for initialization
        void Awake()
        {
            // ウィンドウが準備できたタイミングで初期値を設定できるよう保存しておく
            isInitiallyTopmost   = _isTopmost;
            isInitiallyMaximized = _isMaximized;
            isInitiallyMinimized = _isMinimized;

            Input.simulateMouseWithTouches = false;

            if (!currentCamera)
            {
                // メインカメラを探す
                currentCamera = Camera.main;

                // もしメインカメラが見つからなければ、Findで探す
                if (!currentCamera)
                {
                    currentCamera = FindObjectOfType <Camera>();
                }
            }

            // カメラの元の背景を記憶
            if (currentCamera)
            {
                originalCameraClearFlags = currentCamera.clearFlags;
                originalCameraBackground = currentCamera.backgroundColor;
            }

            // マウス下描画色抽出用テクスチャを準備
            colorPickerTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false);

#if (UNITY_WIN || UNITY_STANDALONE_WIN)
            // ウィンドウ制御用のインスタンス作成
            uniWin = new UniWinApi();

            // 透過方式の指定
            uniWin.TransparentType = transparentType;

            // 自分のウィンドウを取得
            FindMyWindow();
#endif
#if UNITY_EDITOR
            // エディタのウィンドウ配置が変化した際の呼び出し
            EditorApplicationUtility.windowsReordered += () => {
                this.isWindowChecked = false;   // ウィンドウが不確かであるとする
                //Debug.Log("Editor windows reordered");
            };
#endif
        }
Example #9
0
        public void GetSetup(Camera camera)
        {
            position = camera.transform.position;
            rotation = camera.transform.rotation;

            targetTexture = camera.targetTexture;

            backgroundColor  = camera.backgroundColor;
            orthographic     = camera.orthographic;
            orthographicSize = camera.orthographicSize;
            nearClipPlane    = camera.nearClipPlane;
            farClipPlane     = camera.farClipPlane;
            aspect           = camera.aspect;
            clearFlags       = camera.clearFlags;
        }
Example #10
0
    // Use this for initialization
    void Awake()
    {
        // カメラの元の背景を記憶
        this.originalCameraClearFlags = Camera.main.clearFlags;
        this.originalCameraBackground = Camera.main.backgroundColor;

        // 描画色抽出用テクスチャ
        this.colorPickerTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false);

        // ウィンドウ制御用のインスタンス作成
        uniWin = new UniWinApi();

        // 名前からウィンドウを取得
        FindMyWindow();
    }
Example #11
0
    void Setup()
    {
        context.SetupCameraProperties(camera);
        CameraClearFlags flags = camera.clearFlags;

        buffer.ClearRenderTarget(
            flags <= CameraClearFlags.Depth,
            flags == CameraClearFlags.Color,
            flags == CameraClearFlags.Color ?
            camera.backgroundColor.linear : Color.clear
            );
        //BeginSample 与 EndSample成对使用,为了在FrameDebugger中有层级显示
        buffer.BeginSample(SampleName);
        ExecuteBuffer();
    }
Example #12
0
    public static void Follow(Camera src, Camera dst)
    {
        int              cullingMask   = dst.cullingMask;
        float            backupDepth   = dst.depth;
        RenderTexture    backupTexture = dst.targetTexture;
        Color            backupColor   = dst.backgroundColor;
        CameraClearFlags clearFlags    = dst.clearFlags;

        dst.CopyFrom(src);
        dst.cullingMask     = cullingMask;
        dst.clearFlags      = clearFlags;
        dst.targetTexture   = backupTexture;
        dst.depth           = backupDepth;
        dst.backgroundColor = backupColor;
    }
Example #13
0
        BackgroundType GetBackgroundType(CameraClearFlags clearFlags)
        {
            switch (clearFlags)
            {
            case CameraClearFlags.Skybox:
                return(BackgroundType.Skybox);

            case CameraClearFlags.Nothing:
                return(BackgroundType.DontCare);

            // DepthOnly is not supported by design in LWRP. We upgrade it to SolidColor
            default:
                return(BackgroundType.SolidColor);
            }
        }
Example #14
0
    void Render(ScriptableRenderContext rc, Camera camera)
    {
        // Get camera culling parameters
        ScriptableCullingParameters cullingParameters;

        if (!CullResults.GetCullingParameters(camera, out cullingParameters))
        {
            return;
        }

        // perform culling, CullResults stores information on what is visible
        CullResults.Cull(ref cullingParameters, rc, ref cull);

        // Setup camera properties
        rc.SetupCameraProperties(camera);

        CameraClearFlags clearFlags = camera.clearFlags;

        cameraBuffer.ClearRenderTarget(
            (clearFlags & CameraClearFlags.Depth) != 0,
            (clearFlags & CameraClearFlags.Color) != 0,
            camera.backgroundColor
            );

        // Execute command buffer
        rc.ExecuteCommandBuffer(cameraBuffer);

        // release it!
        cameraBuffer.Clear();

        // DRAW!!!!
        var drawSettings   = new DrawRendererSettings(camera, new ShaderPassName("SRPDefaultUnlit"));
        var filterSettings = new FilterRenderersSettings(true);

        // First draw opaque objects
        drawSettings.sorting.flags      = SortFlags.CommonOpaque;
        filterSettings.renderQueueRange = RenderQueueRange.opaque;
        rc.DrawRenderers(cull.visibleRenderers, ref drawSettings, filterSettings);

        rc.DrawSkybox(camera);

        // draw transparent objects after skybox is drawn!
        drawSettings.sorting.flags      = SortFlags.CommonTransparent;
        filterSettings.renderQueueRange = RenderQueueRange.transparent;
        rc.DrawRenderers(cull.visibleRenderers, ref drawSettings, filterSettings);

        rc.Submit();
    }
Example #15
0
        protected override void ReadFromImpl(object obj)
        {
            base.ReadFromImpl(obj);
            Camera uo = (Camera)obj;

            nearClipPlane          = uo.nearClipPlane;
            farClipPlane           = uo.farClipPlane;
            fieldOfView            = uo.fieldOfView;
            renderingPath          = uo.renderingPath;
            allowHDR               = uo.allowHDR;
            allowMSAA              = uo.allowMSAA;
            allowDynamicResolution = uo.allowDynamicResolution;
            forceIntoRenderTexture = uo.forceIntoRenderTexture;
            orthographicSize       = uo.orthographicSize;
            orthographic           = uo.orthographic;
            opaqueSortMode         = uo.opaqueSortMode;
            transparencySortMode   = uo.transparencySortMode;
            transparencySortAxis   = uo.transparencySortAxis;
            depth                         = uo.depth;
            aspect                        = uo.aspect;
            cullingMask                   = uo.cullingMask;
            eventMask                     = uo.eventMask;
            layerCullSpherical            = uo.layerCullSpherical;
            cameraType                    = uo.cameraType;
            layerCullDistances            = uo.layerCullDistances;
            useOcclusionCulling           = uo.useOcclusionCulling;
            cullingMatrix                 = uo.cullingMatrix;
            backgroundColor               = uo.backgroundColor;
            clearFlags                    = uo.clearFlags;
            depthTextureMode              = uo.depthTextureMode;
            clearStencilAfterLightingPass = uo.clearStencilAfterLightingPass;
            usePhysicalProperties         = uo.usePhysicalProperties;
            sensorSize                    = uo.sensorSize;
            lensShift                     = uo.lensShift;
            focalLength                   = uo.focalLength;
            rect                        = uo.rect;
            pixelRect                   = uo.pixelRect;
            targetTexture               = ToID(uo.targetTexture);
            targetDisplay               = uo.targetDisplay;
            worldToCameraMatrix         = uo.worldToCameraMatrix;
            projectionMatrix            = uo.projectionMatrix;
            nonJitteredProjectionMatrix = uo.nonJitteredProjectionMatrix;
            useJitteredProjectionMatrixForTransparentRendering = uo.useJitteredProjectionMatrixForTransparentRendering;
            scene             = uo.scene;
            stereoSeparation  = uo.stereoSeparation;
            stereoConvergence = uo.stereoConvergence;
            stereoTargetEye   = uo.stereoTargetEye;
        }
Example #16
0
    void Setup()
    {
        //SetupCameraProperties(camera)摄像机的位置和方向以及透视等信息的传递
        //Setup camera specific global shader variables.
        context.SetupCameraProperties(camera);
        //上下文会延迟实际的渲染,直到我们提交它为止
        CameraClearFlags flags = camera.clearFlags;

        buffer.ClearRenderTarget(
            flags <= CameraClearFlags.Depth,                                              //深度
            flags == CameraClearFlags.Color,                                              //颜色
            flags == CameraClearFlags.Color ? camera.backgroundColor.linear : Color.clear //用于清除的颜色
            );
        buffer.BeginSample(SampleName);
        ExecuteBuffer();
    }
Example #17
0
    private void SetUp(ref RenderingSetting renderingSetting, ref ShadowSetting shadowSetting)
    {
        _cmdBuf.BeginSample(_cmdBuf.name);
        ExecuteCommandBuffer();
        _lightMgr.SetUp(ref _context, ref _cullResults, ref shadowSetting);
        _cmdBuf.EndSample(_cmdBuf.name);

        _context.SetupCameraProperties(_camera);
        SetUpIntermediateRT(ref renderingSetting);

        CameraClearFlags clearFlags = _camera.clearFlags;

        _cmdBuf.ClearRenderTarget(clearFlags <= CameraClearFlags.Depth, clearFlags <= CameraClearFlags.Color, clearFlags <= CameraClearFlags.Color ? _camera.backgroundColor.linear : Color.clear);
        _cmdBuf.BeginSample(_cmdBuf.name);
        ExecuteCommandBuffer();
    }
Example #18
0
        void Setup()
        {
            // mul unity_MatrixVP
            this.context.SetupCameraProperties(camera);
            // Clear RT by camera parameters.
            CameraClearFlags clearFlags = camera.clearFlags;

            cameraBuffer.ClearRenderTarget(
                clearFlags <= CameraClearFlags.Depth,  // 除了Flags.Nothing以外都會需要清除Depth
                clearFlags == CameraClearFlags.Color,  // 只有Flags.Color需要清除,因為其他的情形要不就DepthOnly, Nothing要不然就Skybox(之後會直接蓋掉)
                clearFlags == CameraClearFlags.Color ? // 有清Color才需要給background color.
                camera.backgroundColor.linear : Color.clear
                );

            BeginSampleBuffer(cameraBuffer); // 執行Clear + BeginSample
        }
Example #19
0
        public static ClearFlag GetCameraClearFlag(Camera camera)
        {
            ClearFlag        clearFlag        = ClearFlag.None;
            CameraClearFlags cameraClearFlags = camera.clearFlags;

            if (cameraClearFlags != CameraClearFlags.Nothing)
            {
                clearFlag |= ClearFlag.Depth;
                if (cameraClearFlags == CameraClearFlags.Color || cameraClearFlags == CameraClearFlags.Skybox)
                {
                    clearFlag |= ClearFlag.Color;
                }
            }

            return(clearFlag);
        }
Example #20
0
    /// <summary>
    /// 设置相机属性和矩阵
    /// </summary>
    private void Setup()
    {
        _context.SetupCameraProperties(_camera);
        //得到相机的clear flags
        CameraClearFlags flags = _camera.clearFlags;

        //设置相机清除状态
        _buffer.ClearRenderTarget(
            flags <= CameraClearFlags.Depth,
            flags == CameraClearFlags.Color,
            flags == CameraClearFlags.Color ? _camera.backgroundColor.linear : Color.clear);
        ////清空上一帧的FrameBuffer
        //_buffer.ClearRenderTarget(true, true, Color.clear);
        _buffer.BeginSample(SampleName);
        ExcuteBuffer();
    }
Example #21
0
    void Setup()
    {
        context.SetupCameraProperties(camera);
        CameraClearFlags flags = camera.clearFlags;

        buffer.ClearRenderTarget(
            flags <= CameraClearFlags.Depth,
            flags == CameraClearFlags.Color,
            flags == CameraClearFlags.Color ?
            camera.backgroundColor.linear : Color.clear
            );
        buffer.BeginSample(SampleName);
        //buffer.ClearRenderTarget(true, true, Color.clear);
        ExecuteBuffer();
        //context.SetupCameraProperties(camera);
    }
Example #22
0
 void Start()
 {
     Setup(eyeSide);
     SetupUpdate();
     if (eyecamera != null)
     {
         #region BoundarySystem
         // record
         eyeCameraOriginCullingMask     = eyecamera.cullingMask;
         eyeCameraOriginClearFlag       = eyecamera.clearFlags;
         eyeCameraOriginBackgroundColor = eyecamera.backgroundColor;
         applicationOriginFrameRate     = Application.targetFrameRate;
         boundaryFrameRate = BoundarySystem.UPvr_GetFrameRateLimit();
         #endregion
     }
 }
Example #23
0
    void Setup()
    {
        context.SetupCameraProperties(camera);
        CameraClearFlags flags = camera.clearFlags;

        //ClearRenderTarget requires at least three arguments.
        //The first two indicate whether the depth and color data should be cleared
        // The third argument is the color used to clearing
        buffer.ClearRenderTarget(
            flags <= CameraClearFlags.Depth,
            flags == CameraClearFlags.Color,
            flags == CameraClearFlags.Color ?
            camera.backgroundColor.linear : Color.clear);
        buffer.BeginSample(SampleName);//inject profiler samples, which will show up both in the profiler and the frame debugger
        ExecuteBuffer();
    }
 public WebCamImpl(Camera arCamera, Camera backgroundCamera, int renderTextureLayer, string webcamDeviceName, bool flipHorizontally)
 {
     if (QCARRuntimeUtilities.IsPlayMode())
     {
         this.mRenderTextureLayer       = renderTextureLayer;
         this.mARCamera                 = arCamera;
         this.mOriginalCameraClearFlags = this.mARCamera.clearFlags;
         this.mARCamera.clearFlags      = CameraClearFlags.Depth;
         this.mBackgroundCameraInstance = backgroundCamera;
         this.mBgRenderingTexBehaviour  = this.mBackgroundCameraInstance.GetComponentInChildren <BGRenderingAbstractBehaviour>();
         if (this.mBgRenderingTexBehaviour == null)
         {
             Debug.LogError("Instanciated Prefab does not contain VideoTextureBehaviour!");
         }
         else
         {
             this.mOriginalCameraCullMask = this.mARCamera.cullingMask;
             this.mARCamera.cullingMask  &= ~(((int)1) << this.mBgRenderingTexBehaviour.gameObject.layer);
             this.mARCamera.cullingMask  &= ~(((int)1) << this.mRenderTextureLayer);
             WebCamProfile profile = new WebCamProfile();
             if (QCARRuntimeUtilities.IsQCAREnabled() && (WebCamTexture.devices.Length > 0))
             {
                 bool flag = false;
                 foreach (WebCamDevice device in WebCamTexture.devices)
                 {
                     if (device.name.Equals(webcamDeviceName))
                     {
                         flag = true;
                     }
                 }
                 if (!flag)
                 {
                     webcamDeviceName = WebCamTexture.devices[0].name;
                 }
                 this.mWebCamProfile = profile.GetProfile(webcamDeviceName);
                 this.mWebCamTexture = new WebCamTexAdaptorImpl(webcamDeviceName, this.mWebCamProfile.RequestedFPS, this.mWebCamProfile.RequestedTextureSize);
             }
             else
             {
                 this.mWebCamProfile = profile.Default;
                 this.mWebCamTexture = new NullWebCamTexAdaptor(this.mWebCamProfile.RequestedFPS, this.mWebCamProfile.RequestedTextureSize);
             }
             this.mBgRenderingTexBehaviour.SetFlipHorizontally(flipHorizontally);
             this.mFlipHorizontally = flipHorizontally;
         }
     }
 }
        private void BeginForwardRendering(ref ScriptableRenderContext context, FrameRenderingConfiguration renderingConfig, CameraContext cameraContext)
        {
            RenderTargetIdentifier colorRT = BuiltinRenderTextureType.CameraTarget;
            RenderTargetIdentifier depthRT = BuiltinRenderTextureType.None;

            StereoRendering.Start(ref context, renderingConfig, cameraContext.Camera);

            CommandBuffer cmd = CommandBufferPool.Get("SetCameraRenderTarget");
            bool          intermediateTexture = LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.IntermediateTexture);

            if (intermediateTexture)
            {
                if (!cameraContext.IsOffscreenCamera)
                {
                    colorRT = m_TextureUtil.CurrCameraColorRT;
                }

                if (m_TextureUtil.RequireDepthTexture)
                {
                    depthRT = m_DepthRT;
                }
            }

            ClearFlag        clearFlag        = ClearFlag.None;
            CameraClearFlags cameraClearFlags = cameraContext.Camera.clearFlags;

            if (cameraClearFlags != CameraClearFlags.Nothing)
            {
                clearFlag |= ClearFlag.Depth;
                if (cameraClearFlags == CameraClearFlags.Color || cameraClearFlags == CameraClearFlags.Skybox)
                {
                    clearFlag |= ClearFlag.Color;
                }
            }

            m_TextureUtil.SetRenderTarget(cmd, colorRT, depthRT, cameraContext.Camera.backgroundColor, clearFlag);

            // If rendering to an intermediate RT we resolve viewport on blit due to offset not being supported
            // while rendering to a RT.
            if (!intermediateTexture && !LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.DefaultViewport))
            {
                cmd.SetViewport(cameraContext.Camera.pixelRect);
            }

            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }
Example #26
0
    void Setup()
    {
        context.SetupCameraProperties(camera);
        CameraClearFlags flags = camera.clearFlags;

        // Do I really need this? Seems like I could save some performance by not using it
        buffer.ClearRenderTarget(
            flags <= CameraClearFlags.Depth,
            flags == CameraClearFlags.Color,
            flags == CameraClearFlags.Color ?
            camera.backgroundColor.linear
        :
            Color.clear
            );
        buffer.BeginSample(SampleName);
        ExecuteBuffer();
    }
    private void OnEnable()
    {
        if (!_awakeCalled)
        {
            Awake();                     //Safeguard for https://issuetracker.unity3d.com/issues/awake-and-start-not-called-before-update-when-assembly-is-reloaded-for-executeineditmode-scripts
        }
        if (!_resetCalled)
        {
            Reset();
        }

        _originalCameraClearFlags = _ownCamera.clearFlags;
        _ownCamera.clearFlags     = CameraClearFlags.Color;

        SetDirty();
        _ownCamera.AddCommandBuffer(CameraEvent.AfterImageEffectsOpaque, _commandBuffer);
    }
 public void CopyFrom(Camera camera)
 {
     this.clearFlags = camera.clearFlags;
     this.backgroundColor = camera.backgroundColor;
     this.cullingMask = camera.cullingMask;
     this.orthographic = camera.orthographic;
     this.orthographicSize = camera.orthographicSize;
     this.fieldOfView = camera.fieldOfView;
     this.nearClipPlane = camera.nearClipPlane;
     this.farClipPlane = camera.farClipPlane;
     this.rect = camera.rect;
     this.depth = camera.depth;
     this.renderingPath = camera.renderingPath;
     this.targetTexture = camera.targetTexture;
     this.useOcclusionCulling = camera.useOcclusionCulling;
     this.hdr = camera.hdr;
 }
Example #29
0
    void ClearMirrorTexture(Camera Cam)
    {
        CameraClearFlags oldClearFlags      = Cam.clearFlags;
        Color            oldBackgroundColor = Cam.backgroundColor;
        Rect             oldRect            = Cam.rect;
        int oldCullingMask = Cam.cullingMask;

        Cam.clearFlags      = CameraClearFlags.SolidColor;
        Cam.backgroundColor = new Color(1.0f, 1.0f, 1.0f, 1.0f);
        Cam.rect            = new Rect(0.0f, 0.0f, 1.0f, 1.0f);
        Cam.cullingMask     = 0;
        Cam.Render();
        Cam.clearFlags      = oldClearFlags;
        Cam.backgroundColor = oldBackgroundColor;
        Cam.rect            = oldRect;
        Cam.cullingMask     = oldCullingMask;
    }
Example #30
0
        private void RenderSingleCamera(ScriptableRenderContext pRenderContext, Camera pCamera)
        {
            if (pCamera.cameraType != CameraType.Game || pCamera.isActiveAndEnabled)
            {
                pRenderContext.SetupCameraProperties(pCamera, mIsStere);
#if UNITY_EDITOR
                string tag = pCamera.name;
#else
                string tag = k_RenderCameraTag;
#endif
                CommandBuffer cmd = CommandBufferPool.Get(tag);
                using (new ProfilingSample(cmd, tag))
                {
                    cmd.SetRenderTarget(BuiltinRenderTextureType.CameraTarget);
                    CameraClearFlags vclearFlag = pCamera.clearFlags;
                    cmd.ClearRenderTarget(
                        (vclearFlag & CameraClearFlags.Depth) != 0,
                        (vclearFlag & CameraClearFlags.Color) != 0,
                        pCamera.backgroundColor);
                    pRenderContext.ExecuteCommandBuffer(cmd);
                    cmd.Clear();

#if UNITY_EDITOR
                    // Emit scene view UI
                    if (pCamera.cameraType == CameraType.SceneView)
                    {
                        ScriptableRenderContext.EmitWorldGeometryForSceneView(pCamera);
                    }
#endif
                    if (!pCamera.TryGetCullingParameters(out var vCullParameters))
                    {
                        return;
                    }
                    vCullParameters.isOrthographic = false;
                    outCull = pRenderContext.Cull(ref vCullParameters);
                    int length = outCull.visibleLights.Length;

                    DrawOpaque(pRenderContext, pCamera);
                    DrawSkyBox(pRenderContext, pCamera);
                    DrawTransfer(pRenderContext, pCamera);
                }
                pRenderContext.ExecuteCommandBuffer(cmd);
                CommandBufferPool.Release(cmd);
                pRenderContext.Submit();
            }
        }
    void Start()
    {
        Setup(eyeSide);
        if (eyecamera != null)
        {
            eyecamera.enabled = !Pvr_UnitySDKManager.SDK.Monoscopic;

            #region BoundarySystem
            // record
            eyeCameraOriginCullingMask     = eyecamera.cullingMask;
            eyeCameraOriginClearFlag       = eyecamera.clearFlags;
            eyeCameraOriginBackgroundColor = eyecamera.backgroundColor;
            applicationOriginFrameRate     = Application.targetFrameRate;
            boundaryFrameRate = Pvr_UnitySDKAPI.BoundarySystem.UPvr_GetFrameRateLimit();
            #endregion
        }
    }
 public void CopyFrom(Camera camera)
 {
     this.clearFlags          = camera.clearFlags;
     this.backgroundColor     = camera.backgroundColor;
     this.cullingMask         = camera.cullingMask;
     this.orthographic        = camera.orthographic;
     this.orthographicSize    = camera.orthographicSize;
     this.fieldOfView         = camera.fieldOfView;
     this.nearClipPlane       = camera.nearClipPlane;
     this.farClipPlane        = camera.farClipPlane;
     this.rect                = camera.rect;
     this.depth               = camera.depth;
     this.renderingPath       = camera.renderingPath;
     this.targetTexture       = camera.targetTexture;
     this.useOcclusionCulling = camera.useOcclusionCulling;
     this.hdr = camera.hdr;
 }
Example #33
0
    void Render(ScriptableRenderContext context, Camera camera)
    {
        ScriptableCullingParameters cullingParameters;

        if (!camera.TryGetCullingParameters(out cullingParameters))
        {
            return;
        }

        BeginCameraRendering(context, camera);
#if UNITY_EDITOR
        if (camera.cameraType == CameraType.SceneView)
        {
            ScriptableRenderContext.EmitWorldGeometryForSceneView(camera);
        }
#endif
        context.SetupCameraProperties(camera);
        commandBuffer.BeginSample("Render Camera commandBuffer");
        CameraClearFlags clearFlags = camera.clearFlags;
        commandBuffer.ClearRenderTarget((clearFlags & CameraClearFlags.Depth) != 0,
                                        (clearFlags & CameraClearFlags.Color) != 0, camera.backgroundColor);
        context.ExecuteCommandBuffer(commandBuffer);
        commandBuffer.Clear();

        cullingResults = context.Cull(ref cullingParameters);
        SortingSettings sortingSettings = new SortingSettings(camera);
        sortingSettings.criteria = SortingCriteria.CommonOpaque;
        DrawingSettings   drawingSettings   = new DrawingSettings(new ShaderTagId("SRPDefaultUnlit"), sortingSettings);
        FilteringSettings filteringSettings = FilteringSettings.defaultValue;
        filteringSettings.renderQueueRange = RenderQueueRange.opaque;
        context.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings);
        context.DrawSkybox(camera);

        sortingSettings.criteria           = SortingCriteria.CommonTransparent;
        filteringSettings.renderQueueRange = RenderQueueRange.transparent;
        context.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings);

        DrawDefaultPipeline(context, camera);

        commandBuffer.EndSample("Render Camera commandBuffer");
        context.ExecuteCommandBuffer(commandBuffer);
        commandBuffer.Clear();

        EndCameraRendering(context, camera);
    }
Example #34
0
    void Setup()
    {
        context.SetupCameraProperties(camera);
        //清除渲染目标
        //buffer.ClearRenderTarget(true, true, Color.clear);
        CameraClearFlags flags = camera.clearFlags;

        buffer.ClearRenderTarget(
            flags <= CameraClearFlags.Depth,
            flags == CameraClearFlags.Color,
            flags == CameraClearFlags.Color ?
            camera.backgroundColor.linear : Color.clear
            );

        //buffer.BeginSample/buffer.EndSample 来注入我们的分析代码,这样在FrameDebuger中我们就能看到我们想分析渲染代码
        buffer.BeginSample(bufferName);
        ExecuteBuffer();
    }
Example #35
0
    /**设置相机的clearFlags**/
    public static void SetCameraClearFlags(GameObject go, CameraClearFlags srcFlags, CameraClearFlags destFlags)
    {
        UICamera[] allUIcam    = go.GetComponentsInChildren <UICamera>(true);
        int        uiCamLength = allUIcam.Length;

        for (int i = 0; i < uiCamLength; ++i)
        {
            UICamera uicam = allUIcam[i];
            if (uicam != null)
            {
                Camera cam = uicam.gameObject.GetComponent <Camera>();
                if (cam != null && cam.clearFlags == srcFlags)
                {
                    cam.clearFlags = destFlags;
                }
            }
        }
    }
        private void EnableARBackgroundRendering()
        {
            if (BackgroundMaterial == null || m_Camera == null)
            {
                return;
            }

            m_CameraClearFlags  = m_Camera.clearFlags;
            m_Camera.clearFlags = CameraClearFlags.Depth;

            m_CommandBuffer = new CommandBuffer();

            m_CommandBuffer.Blit(BackgroundMaterial.mainTexture,
                                 BuiltinRenderTextureType.CameraTarget, BackgroundMaterial);

            m_Camera.AddCommandBuffer(CameraEvent.BeforeForwardOpaque, m_CommandBuffer);
            m_Camera.AddCommandBuffer(CameraEvent.BeforeGBuffer, m_CommandBuffer);
        }
 /// <summary>
 /// Creates a GameObject with an OffscreenBuffer and required Camera with the specified properties.
 /// </summary>
 public static OffscreenBuffer Create(int width, int height, int depth,
                                      RenderTextureFormat format, DepthTextureMode depthMode,
                                      LayerMask layerMask, CameraClearFlags clearFlags,
                                      Color clearColor, Shader replacementShader,
                                      string replacementTag) {
   GameObject tmp = new GameObject("Offscreen Buffer Camera");
   // we want to do some setup before we activate so things adhere to Monobehaviour execution order.
   tmp.SetActive(false);
   tmp.AddComponent<Camera>();
   OffscreenBuffer c = tmp.AddComponent<OffscreenBuffer>();
   c.width = width;
   c.height = height;
   c.depth = depth;
   c.format = format;
   c.cullingMask = layerMask.value;
   c.clearFlags = clearFlags;
   c.clearColor = clearColor;
   if (replacementShader != null) {
     c.replacementShader = replacementShader;
     c.replacementTag = replacementTag;
   }
   tmp.SetActive(true);
   return c;
 }
Example #38
0
    // Starts up the QCAR extension with the properties that were set in the
    // Unity inspector.
    void Start()
    {
        // First we check if QCAR initialized correctly.
        if (QCAR.CheckInitializationError() != QCAR.InitError.INIT_SUCCESS)
        {
            mIsInitialized = false;
            return;
        }

        // Initialize the trackers if they haven't already been initialized.
        if (TrackerManager.Instance.GetTracker(Tracker.Type.MARKER_TRACKER) == null)
        {
            TrackerManager.Instance.InitTracker(Tracker.Type.MARKER_TRACKER);
        }

        if (TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER) == null)
        {
            TrackerManager.Instance.InitTracker(Tracker.Type.IMAGE_TRACKER);
        }

        // Cache the camera start values
        mCachedDrawVideoBackground = QCARManager.Instance.DrawVideoBackground;
        mCachedCameraClearFlags = this.camera.clearFlags;
        mCachedCameraBackgroundColor = this.camera.backgroundColor;

        // Reset the camera clear flags and create a simple material
        ResetCameraClearFlags();
        mClearMaterial = new Material(Shader.Find("Diffuse"));

        // Set QCAR hints from the Inspector options
        QCAR.SetHint(QCAR.QCARHint.HINT_MAX_SIMULTANEOUS_IMAGE_TARGETS,
                            MaxSimultaneousImageTargets);
        QCAR.SetHint(QCAR.QCARHint.HINT_IMAGE_TARGET_MULTI_FRAME_ENABLED,
                            MultiFrameEnabled ? 1 : 0);

        // Set the Unity version for internal use
        QCAR.SetUnityVersion();

        // Find markers in the scene and register them with QCAR
        MarkerBehaviour[] markerBehaviours = (MarkerBehaviour[])
            UnityEngine.Object.FindObjectsOfType(typeof(MarkerBehaviour));
        MarkerTracker markerTracker = (MarkerTracker)TrackerManager.Instance.GetTracker(Tracker.Type.MARKER_TRACKER);
        if (markerTracker != null)
        {
            markerTracker.AddMarkers(markerBehaviours);
        }

        // Start the camera and tracker
        StartQCAR();

        // Initialize the QCARManager
        QCARManager.Instance.WorldCenterMode = mWorldCenterMode;
        QCARManager.Instance.WorldCenter = mWorldCenter;
        QCARManager.Instance.ARCamera = camera;
        QCARManager.Instance.Init();

        // Initialize local variables
        mIsInitialized = true;
        mHasStartedOnce = true;
    }
Example #39
0
	public static Camera SetCamera (Camera thisCamera, CameraClearFlags clearFlags, bool useOrtho) {
		if (!cam) {
			cam = new GameObject("VectorCam", typeof(Camera)).camera;
			MonoBehaviour.DontDestroyOnLoad(cam);
		}
		cam.depth = thisCamera.depth+1;
		cam.clearFlags = clearFlags;
		cam.orthographic = useOrtho;
		useOrthoCam = useOrtho;
		if (useOrtho) {
			cam.orthographicSize = screenHeight/2;
			cam.farClipPlane = 101.1f;
			cam.nearClipPlane = .9f;
		}
		else {
			cam.fieldOfView = 90.0f;
			cam.farClipPlane = screenHeight/2 + .0101f;
			cam.nearClipPlane = screenHeight/2 - .0001f;
		}
		cam.transform.position = new Vector3(screenWidth/2 - .5f, screenHeight/2 - .5f, 0.0f);
		cam.transform.eulerAngles = Vector3.zero;
		cam.cullingMask = 1 << _vectorLayer;	// Turn on only the vector layer on the Vectrosity camera
		cam.backgroundColor = thisCamera.backgroundColor;
		cam.hdr = thisCamera.hdr;
		
		thisCamera.cullingMask &= ~(1 << _vectorLayer);	// Turn off the vector layer on the non-Vectrosity camera
		camTransform = thisCamera.transform;
		cam3D = thisCamera;
		oldPosition = camTransform.position + Vector3.one;
		oldRotation = camTransform.eulerAngles + Vector3.one;
		return cam;
	}
Example #40
0
	public static Camera SetCamera (Camera thisCamera, CameraClearFlags clearFlags) {
		return SetCamera (thisCamera, clearFlags, false);
	}
Example #41
0
	public static Camera SetCamera (CameraClearFlags clearFlags) {
		return SetCamera (clearFlags, false);
	}
        void Start()
        {
            dfUnity = DaggerfallUnity.Instance;

            // Try to find local player GPS if not set
            if (LocalPlayerGPS == null)
            {
                GameObject player = GameObject.FindGameObjectWithTag("Player");
                if (player)
                {
                    LocalPlayerGPS = player.GetComponent<PlayerGPS>();
                }
            }

            // Find main camera gameobject
            GameObject go = GameObject.FindGameObjectWithTag("MainCamera");
            if (go)
            {
                mainCamera = go.GetComponent<Camera>();
            }

            // Check main camera component
            if (!mainCamera)
            {
                DaggerfallUnity.LogMessage("DaggerfallSky could not find MainCamera object. Disabling sky.", true);
                gameObject.SetActive(false);
                return;
            }

            // Save starting clear flags
            initialClearFlags = mainCamera.clearFlags;

            // Get my camera
            myCamera = GetComponent<Camera>();
            if (!myCamera)
            {
                DaggerfallUnity.LogMessage("DaggerfallSky could not find local camera. Disabling sky.", true);
                gameObject.SetActive(false);
                return;
            }

            // My camera must not be on the same GameObject as MainCamera
            if (myCamera == mainCamera)
            {
                DaggerfallUnity.LogMessage("DaggerfallSky must not be attached to same GameObject as MainCamera. Disabling sky.", true);
                gameObject.SetActive(false);
                return;
            }

            // Setup cameras
            SetupCameras();
        }
Example #43
0
    // Starts up the QCAR extension with the properties that were set in the
    // Unity inspector.
    void Start()
    {
        // keeps the ARCamera object alive across scenes:
        if (KeepAliveBehaviour.Instance != null && KeepAliveBehaviour.Instance.KeepARCameraAlive)
            DontDestroyOnLoad(gameObject);

        Debug.Log("QCARWrapper.Start");
        // First we check if QCAR initialized correctly.
        if (QCARUnity.CheckInitializationError() != QCARUnity.InitError.INIT_SUCCESS)
        {
            mIsInitialized = false;
            return;
        }

        // Initialize the trackers if they haven't already been initialized.
        if (TrackerManager.Instance.GetTracker(Tracker.Type.MARKER_TRACKER) == null)
        {
            TrackerManager.Instance.InitTracker(Tracker.Type.MARKER_TRACKER);
        }

        if (TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER) == null)
        {
            TrackerManager.Instance.InitTracker(Tracker.Type.IMAGE_TRACKER);
        }

        // Cache the camera start values
        mCachedDrawVideoBackground = QCARManager.Instance.DrawVideoBackground;
        mCachedCameraClearFlags = this.camera.clearFlags;
        mCachedCameraBackgroundColor = this.camera.backgroundColor;

        // keep the device's screen turned on and bright.
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        // Reset the camera clear flags and create a simple material
        ResetCameraClearFlags();
        mClearMaterial = new Material(Shader.Find("Diffuse"));

        // Set QCAR hints from the Inspector options
        QCARUnity.SetHint(QCARUnity.QCARHint.HINT_MAX_SIMULTANEOUS_IMAGE_TARGETS,
                            MaxSimultaneousImageTargets);

        // Set the Unity version for internal use
        QCARUnityImpl.SetUnityVersion(Application.persistentDataPath, true);

        // register markers in QCAR:
        StateManagerImpl stateManager = (StateManagerImpl) TrackerManager.Instance.GetStateManager();
        stateManager.AssociateMarkerBehaviours();

        // Start the camera and tracker
        StartQCAR();

        // Initialize the QCARManager
        QCARManager.Instance.WorldCenterMode = mWorldCenterMode;
        QCARManager.Instance.WorldCenter = mWorldCenter;
        QCARManager.Instance.ARCamera = camera;
        QCARManager.Instance.Init();

        // Initialize local variables
        mIsInitialized = true;

        // Let the trackable event handlers know that QCAR has been initialized
        foreach (ITrackerEventHandler handler in mTrackerEventHandlers)
        {
            handler.OnInitialized();
        }

        mHasStartedOnce = true;
    }
Example #44
0
    static public void CreateCubemapWithPro(int resolution, TextureFormat textureFormat, bool useLinearSpace, bool useMipMaps, float mipMapBias, string outputPathCubemap, bool makePNG, string outputPathPNG, CameraClearFlags camClearFlags, Color camBGColor, float camFarClipPlane, int camCullingMask, bool smoothEdges, int smoothEdgeWidth)
    {
        CubemapNode[] nodes = FindObjectsOfType(typeof(CubemapNode)) as CubemapNode[];
        for (int a = 0; a < nodes.Length; a++)
        {
            // Make sure this Node is set to allow generation of either cubemaps or PNGs
            // Ignore the Allow parameter if we have no cubemap assigned yet at all
            if (nodes[a].allowCubemapGeneration || (!nodes[a].allowCubemapGeneration && nodes[a].cubemap == null))
            {
                // Create our Cubemap File that we will render into
                Cubemap cubemap = new Cubemap(resolution, textureFormat, useMipMaps);
                cubemap.mipMapBias = mipMapBias;
                string finalCubemapPath = outputPathCubemap + "/" + Application.loadedLevelName + "_" + nodes[a].name + ".cubemap";
				
                if (finalCubemapPath.Contains("//"))
                    finalCubemapPath = finalCubemapPath.Replace("//", "/");

                AssetDatabase.CreateAsset(cubemap, finalCubemapPath);

                // create and position temporary camera for rendering
                var go = new GameObject("CubemapCamera", typeof(Camera));
                go.transform.position = nodes[a].transform.position;
                go.transform.rotation = Quaternion.identity;

                // Camera setup
                var cam = go.GetComponent<Camera>();
                cam.clearFlags = camClearFlags;
                cam.backgroundColor = camBGColor;
                cam.farClipPlane = camFarClipPlane;
                cam.cullingMask = camCullingMask;

                // render into cubemap		
                cam.RenderToCubemap(cubemap);

#if !UNITY_2_6 && !UNITY_2_6_1 && !UNITY_3_0 && !UNITY_3_0_0 && !UNITY_3_1 && !UNITY_3_2 && !UNITY_3_3 && !UNITY_3_4 && !UNITY_3_5
                // Smooth Edges on Unity 4.0+
                if (smoothEdges)
                {
                    cubemap.SmoothEdges(smoothEdgeWidth);
                    cubemap.Apply();
                }
#endif

                // Use Linear Space?
                SerializedObject serializedCubemap = new SerializedObject(cubemap);
                CubemapHelpers.setLinear(ref serializedCubemap, useLinearSpace);

                // Destroy temp camera
                DestroyImmediate(go);

                // Extract PNG if Allowed
                if (makePNG && nodes[a].allowGeneratePNG)
                {
                    CubemapHelpers.CubemapToPNG(cubemap, outputPathPNG);
                }

                AssetDatabase.Refresh();
                Selection.activeObject = cubemap;
            }
        }

        Debug.Log("CUBEMAPS GENERATED!");
        EditorUtility.DisplayDialog("Cubemaps generated!", "You can now proceed assigning your cubemaps to your objects.", "Yay!");
    }
Example #45
0
	public static void SetCamera (CameraClearFlags clearFlags) {
		SetCamera (clearFlags, false);
	}
Example #46
0
		public void SetClearFlags(CameraClearFlags flag)
		{
			_camera.clearFlags = flag;
		}
  private void setCameraClearFlags(CameraClearFlags cameraClearFlags) {
    Camera left = getCameraObjectForEye(UnityEngine.VR.VRNode.LeftEye);
    Camera center = getCameraObjectForEye(UnityEngine.VR.VRNode.CenterEye);
    Camera right = getCameraObjectForEye(UnityEngine.VR.VRNode.RightEye);

    left.clearFlags = cameraClearFlags;
    center.clearFlags = cameraClearFlags;
    right.clearFlags = cameraClearFlags;

    EditorUtility.SetDirty(left);
    EditorUtility.SetDirty(center);
    EditorUtility.SetDirty(right);

  }
Example #48
0
	public static void SetCamera (Camera thisCamera, CameraClearFlags clearFlags) {
		SetCamera (thisCamera, clearFlags, false);
	}
    public void Enter(float fieldOfView)
    {
        FpsHud hud = FpsHud.Instance;

        if (!display && hud.PlayerCamera)
        {
            display = true;
            camera.enabled = true;
            camera.fieldOfView = fieldOfView;
            scopeOverlay.renderer.enabled = true;

            playerCameraCullingMask = hud.PlayerCamera.cullingMask;
            playerCameraClearFlags = hud.PlayerCamera.clearFlags;
            playerCameraBackgroundColor = hud.PlayerCamera.backgroundColor;

            hud.PlayerCamera.cullingMask = 0;
            hud.PlayerCamera.clearFlags = CameraClearFlags.SolidColor;
            hud.PlayerCamera.backgroundColor = Color.black;

            hud.ActiveCamera = camera;
        }
    }
Example #50
0
 void SaveCameraValues()
 {
     flags_storage = camera.clearFlags;
     culling_storage = camera.cullingMask;
     camera.clearFlags = CameraClearFlags.Nothing;
     camera.cullingMask = 0;
 }
Example #51
0
        public LOAmbient(EditorFacility facility, EditorLevel level, GameObject[] gameObjects, Camera camera, int layer)
        {
            mainCamera = camera;
            newLayer = layer;
            currentFacility = facility;

            originalCullingMask = camera.cullingMask;
            originalClearFlags = camera.clearFlags;
            originalAmbientLight = RenderSettings.ambientLight;
            originalSkybox = RenderSettings.skybox;
            originalLightmapData = LightmapSettings.lightmaps;
            originalAmbientMode = RenderSettings.ambientMode;

            // Create fake skybox
            skyCamera = new GameObject("NightSkyboxCamera", typeof(Camera));
            //            skyCamera.AddComponent<Camera>();
            skyCamera.GetComponent<Camera>().depth = mainCamera.depth - 1;
            skyCamera.GetComponent<Camera>().clearFlags = CameraClearFlags.Skybox;
            skyCamera.GetComponent<Camera>().cullingMask = 0;

            nightSkyboxMaterial = new Material(originalSkybox);

            // GalaxyTex_PositiveX should be viewed outside window
            // Debug.Log("LightsOut: Loading Night Sky Textures");
            foreach (Material material in Resources.FindObjectsOfTypeAll<Material>()) {
                Texture texture = material.mainTexture;
                if (texture) {
                    switch (material.name) {
                    case "ZP":
                        nightSkyboxMaterial.SetTexture("_FrontTex", material.mainTexture);
                        break;
                    case "ZN":
                        nightSkyboxMaterial.SetTexture("_BackTex", material.mainTexture);
                        break;
                    case "XP":
                        nightSkyboxMaterial.SetTexture("_LeftTex", material.mainTexture);
                        break;
                    case "XN":
                        nightSkyboxMaterial.SetTexture("_RightTex", material.mainTexture);
                        break;
                    case "YP":
                        nightSkyboxMaterial.SetTexture("_UpTex", material.mainTexture);
                        break;
                    case "YN":
                        nightSkyboxMaterial.SetTexture("_DownTex", material.mainTexture);
                        break;
                    default:
                        break;
                    }
                }
            }

            skyCamera.AddComponent<Skybox>();
            skyCamera.GetComponent<Skybox>().material = nightSkyboxMaterial;

            if (facility == EditorFacility.VAB) {
                switch (level) {
                case EditorLevel.Level1:
                    break;

                case EditorLevel.Level2:
                    break;

                case EditorLevel.Level3:
                    foreach (GameObject gameObject in gameObjects) {
                        ChangeLayersRecursively(gameObject, newLayer, "model_vab_interior_floor_cover_v20");
                    }
                    break;
                }
            }
            else if (facility == EditorFacility.SPH) {
                switch (level) {
                case EditorLevel.Level1:
                    break;

                case EditorLevel.Level2:
                    break;

                case EditorLevel.Level3:
                    foreach (GameObject gameObject in gameObjects) {
                        // These are all subsets of model_sph_interior_lights_v16
                        // Component_611_1 to 6 is window reflection
            //						ChangeLayersRecursively(gameObject, newLayer, "Component_611_1");
            //						ChangeLayersRecursively(gameObject, newLayer, "Component_611_2");
            //						ChangeLayersRecursively(gameObject, newLayer, "Component_611_3");
                        ChangeLayersRecursively(gameObject, newLayer, "Component_611_4");
                        ChangeLayersRecursively(gameObject, newLayer, "Component_611_5");
                        ChangeLayersRecursively(gameObject, newLayer, "Component_611_6");
                        ChangeLayersRecursively(gameObject, newLayer, "Component_749_1"); // Glow from Side Lights!
                        ChangeLayersRecursively(gameObject, newLayer, "Component_750_1"); // Lights!
                    }
                    break;
                }
            }
        }
Example #52
0
	public void StoreCameraClearFlag(){
		oldClearFlag = mainCamera.clearFlags;	
	}
Example #53
0
 public void Load(Camera c)
 {
     clearFlags = c.clearFlags;
     backgroundColor = c.backgroundColor;
     cullingMasks = c.cullingMask;
 }
Example #54
0
	void Menu_Generate()
    {
        GUI.color = CubemapHelpers.ColorBlue;
        GUILayout.Label("Cubemap Generation", EditorStyles.boldLabel);
        GUI.color = Color.white;
        GUILayout.Label("Configure your settings, then press the button to generate.", EditorStyles.miniBoldLabel);
        
        EditorGUILayout.BeginVertical(GUILayout.MaxWidth(horizontalWidth));
        {
            cm_makePNG = EditorGUILayout.Toggle("Generate PNGs? (slow)", cm_makePNG);
            cm_resolution = EditorGUILayout.IntPopup("Resolution: ", cm_resolution, resolutions, resSizes);

            EditorGUILayout.Space();

            // Advanced Options Foldout
            GUI.color = CubemapHelpers.ColorOrange;
            showAdvancedSettings = EditorGUILayout.Foldout(showAdvancedSettings, "Advanced Settings");
            GUI.color = Color.white;
            if (showAdvancedSettings)
            {
                GUI.color = CubemapHelpers.ColorBlue;
                EditorGUILayout.LabelField("Misc. Settings", EditorStyles.miniBoldLabel);
                GUI.color = Color.white;

                cm_useMipMaps = EditorGUILayout.Toggle("Mip Maps?", cm_useMipMaps);
                cm_mipmapBias = EditorGUILayout.Slider("Mip Map Bias", cm_mipmapBias, -10f, 10f);

                cm_useLinearSpace = EditorGUILayout.Toggle("Use Linear Space", cm_useLinearSpace);

#if !UNITY_2_6 && !UNITY_2_6_1 && !UNITY_3_0 && !UNITY_3_0_0 && !UNITY_3_1 && !UNITY_3_2 && !UNITY_3_3 && !UNITY_3_4 && !UNITY_3_5
                cm_smoothEdges = EditorGUILayout.Toggle("Smooth Edges?", cm_smoothEdges);
                if (cm_smoothEdges)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.BeginVertical(GUILayout.Width(150));
                        {
                            EditorGUILayout.LabelField("Edge Smooth Width:", GUILayout.Width(150));
                        }
                        EditorGUILayout.EndVertical();

                        EditorGUILayout.BeginVertical(GUILayout.Width(30));
                        {
                            cm_smoothEdgeWidth = EditorGUILayout.IntField(cm_smoothEdgeWidth, GUILayout.Width(30));
                        }
                        EditorGUILayout.EndVertical();

                        EditorGUILayout.BeginVertical(GUILayout.Width(30));
                        {
                            EditorGUILayout.LabelField("px", GUILayout.Width(30));
                        }
                        EditorGUILayout.EndVertical();
                    }
                    EditorGUILayout.EndHorizontal();
                }
#endif

                EditorGUILayout.Space();

                GUI.color = CubemapHelpers.ColorBlue;
                EditorGUILayout.LabelField("Advanced Camera Settings", EditorStyles.miniBoldLabel);
                GUI.color = Color.white;

                m_camClearFlagSelected = EditorGUILayout.Popup("Clear Flags", m_camClearFlagSelected, m_camClearFlagOptions);
                cm_camClearFlags = CubemapHelpers.SetClearFlagFromInt(m_camClearFlagSelected);
                if (cm_camClearFlags == CameraClearFlags.Color || cm_camClearFlags == CameraClearFlags.Skybox)
                {
                    cm_camBGColor = EditorGUILayout.ColorField("Background Color:", cm_camBGColor);
                }

                cm_cullingMask = CubemapHelpers.LayerMaskField("Culling Mask", cm_cullingMask, true);
                cm_farClipPlane = EditorGUILayout.FloatField("Far Clipping Plane", cm_farClipPlane);
            }

            EditorGUILayout.Space();

            CubemapHelpers.Separator();

            GUI.backgroundColor = CubemapHelpers.ColorGreen;
            if (GUILayout.Button("Generate Cubemaps!", GUILayout.Height(40)))
                InitGeneration();
            else
                DestroyManager();

            GUI.backgroundColor = Color.white;
        }
        EditorGUILayout.EndVertical();
    }