Пример #1
0
 void DeleteCameras(VarjoLayer varjoLayer)
 {
     for (int i = 0; i < varjoLayer.viewportCameras.Count; ++i)
     {
         if (varjoLayer.viewportCameras[i] != null)
         {
             DestroyImmediate(varjoLayer.viewportCameras[i].gameObject);
         }
     }
     varjoLayer.viewportCameras.Clear();
 }
Пример #2
0
        public void SetupCamera(CAMERA_ID cameraId, Camera sourceCamera, bool copyCameraComponents, VarjoLayer owner)
        {
            VerifyCamera();

            CameraId = cameraId;
            m_Owner  = owner;
            cam.CopyFrom(sourceCamera);

            if (copyCameraComponents)
            {
                CopyCameraComponents(sourceCamera);
            }
        }
Пример #3
0
        private bool VerifyCamera()
        {
            if (cam == null)
            {
                cam = GetComponent <Camera>();
            }
            if (cam == null)
            {
                cam = gameObject.AddComponent <Camera>();
            }
            if (m_Owner == null)
            {
                m_Owner = GetComponentInParent <VarjoLayer>();
            }

            return(cam != null);
        }
Пример #4
0
        private bool VerifyCamera()
        {
            if (cam == null)
            {
                cam = GetComponent <Camera>();
            }
            if (cam == null)
            {
                cam = gameObject.AddComponent <Camera>();
            }
            if (m_Owner == null)
            {
                m_Owner = GetComponentInParent <VarjoLayer>();
            }

            if (cam && m_Owner && m_Owner.useOcclusionMesh && (m_OcclusionMeshVerts == null))
            {
                m_OcclusionMesh      = null;
                m_OcclusionMeshVerts = VarjoPlugin.GetOcclusionMesh((int)CameraId);

                if (m_OcclusionMeshVerts.Length > 0)
                {
                    m_OcclusionMesh = new Mesh();
                    int vertCount = m_OcclusionMeshVerts.Length / 2;
                    var vertices  = new Vector3[vertCount];
                    var indices   = new int[vertices.Length];
                    for (int i = 0; i < vertices.Length; ++i)
                    {
                        vertices[i] = new Vector3(m_OcclusionMeshVerts[i * 2], m_OcclusionMeshVerts[i * 2 + 1], 0.0f);
                        indices[i]  = i;
                    }

                    m_OcclusionMesh.vertices  = vertices;
                    m_OcclusionMesh.triangles = indices;
                }
            }

            return(cam != null);
        }
Пример #5
0
        public override void OnInspectorGUI()
        {
            VarjoLayer varjoLayer = (VarjoLayer)target;

            if (PlayerSettings.virtualRealitySupported)
            {
                EditorGUILayout.HelpBox("ERROR: Unity VR is enabled.\nPlease disable VR from Unity: Project Settings | Player ", MessageType.Error);
            }

            if (QualitySettings.vSyncCount > 0)
            {
                EditorGUILayout.HelpBox("Warning: VSync is enabled.\nPlease disable VSync: Project Settings | Quality", MessageType.Warning);
            }

            if (varjoLayer.varjoCamera == null)
            {
                EditorGUILayout.HelpBox("No main camera assigned. Varjo manager will try to use camera tagged as Main Camera.", MessageType.Info);
            }

            if (varjoLayer.submitDepth)
            {
                if (QualitySettings.antiAliasing > 1 && varjoLayer.varjoCamera.allowMSAA)
                {
                    EditorGUILayout.HelpBox("Warning: Depth submission is not supported when anti-aliasing is used.", MessageType.Warning);
                }

                if (GraphicsSettings.renderPipelineAsset != null)
                {
                    EditorGUILayout.HelpBox("Warning: Depth submission does not support scriptable render pipelines.", MessageType.Warning);
                }
            }

            DrawDefaultInspector();

            EditorGUILayout.Separator();



            if (!Application.isPlaying)
            {
                EditorGUI.indentLevel++;
                if (varjoLayer.viewportCameras != null && varjoLayer.viewportCameras.Count > 0)
                {
                    if (Button("Hide viewport cameras"))
                    {
                        DeleteCameras(varjoLayer);
                        EditorUtility.SetDirty(varjoLayer);
                        EditorUtility.SetDirty(varjoLayer.gameObject);
                        EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                    }

                    if (Button("Regenerate viewport cameras"))
                    {
                        DeleteCameras(varjoLayer);
                        EditorUtility.SetDirty(varjoLayer);
                        EditorUtility.SetDirty(varjoLayer.gameObject);
                        EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                        varjoLayer.CreateCameras();
                        EditorUtility.SetDirty(varjoLayer);
                        EditorUtility.SetDirty(varjoLayer.gameObject);
                        EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                    }
                }
                else
                {
                    if (Button("Generate viewport cameras"))
                    {
                        if (varjoLayer.varjoCamera == null)
                        {
                            Debug.LogError("Can't enable Advanced Mode when Varjo Layer Main Camera is not set!");
                        }
                        else
                        {
                            varjoLayer.CreateCameras();
                            EditorUtility.SetDirty(varjoLayer);
                            EditorUtility.SetDirty(varjoLayer.gameObject);
                            EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                        }
                    }
                }
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();
            //varjoManager.debug = EditorGUILayout.Toggle("Debug", varjoManager.debug);
        }
Пример #6
0
 public static void UnregisterLayer(VarjoLayer layer)
 {
     layers.Remove(layer);
 }
Пример #7
0
 public static void RegisterLayer(VarjoLayer layer)
 {
     layers.Add(layer);
 }