public void Initialize(VolumetricLightBeam master) { Debug.Assert(master != null); var customHideFlags = Consts.ProceduralObjectsHideFlags; m_Master = master; transform.SetParent(master.transform, false); meshRenderer = gameObject.GetOrAddComponent <MeshRenderer>(); meshRenderer.hideFlags = customHideFlags; meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; meshRenderer.receiveShadows = false; meshRenderer.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off; // different reflection probes could break batching with GPU Instancing #if UNITY_5_4_OR_NEWER meshRenderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; #else meshRenderer.useLightProbes = false; #endif if (!shouldUseGPUInstancedMaterial) { m_CustomMaterial = MaterialManager.NewMaterial(gpuInstanced: false); ApplyMaterial(); } if (SortingLayer.IsValid(m_Master.sortingLayerID)) { sortingLayerID = m_Master.sortingLayerID; } else { Debug.LogError(string.Format("Beam '{0}' has an invalid sortingLayerID ({1}). Please fix it by setting a valid layer.", Utils.GetPath(m_Master.transform), m_Master.sortingLayerID)); } sortingOrder = m_Master.sortingOrder; meshFilter = gameObject.GetOrAddComponent <MeshFilter>(); meshFilter.hideFlags = customHideFlags; gameObject.hideFlags = customHideFlags; #if UNITY_EDITOR UnityEditor.GameObjectUtility.SetStaticEditorFlags(gameObject, master.GetStaticEditorFlagsForSubObjects()); gameObject.SetSameSceneVisibilityStatesThan(master.gameObject); #endif RestartFadeOutCoroutine(); }
public void Initialize(VolumetricLightBeam master) { var hideFlags = Consts.ProceduralObjectsHideFlags; m_Master = master; transform.SetParent(master.transform, false); meshRenderer = gameObject.GetOrAddComponent <MeshRenderer>(); meshRenderer.hideFlags = hideFlags; meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; meshRenderer.receiveShadows = false; #if UNITY_5_4_OR_NEWER meshRenderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; #else meshRenderer.useLightProbes = false; #endif if (Config.Instance.actualRenderingMode != RenderingMode.GPUInstancing) { m_CustomMaterial = MaterialManager.NewMaterial(gpuInstanced: false); ApplyMaterial(); } if (SortingLayer.IsValid(m_Master.sortingLayerID)) { sortingLayerID = m_Master.sortingLayerID; } else { Debug.LogError(string.Format("Beam '{0}' has an invalid sortingLayerID ({1}). Please fix it by setting a valid layer.", Utils.GetPath(m_Master.transform), m_Master.sortingLayerID)); } sortingOrder = m_Master.sortingOrder; meshFilter = gameObject.GetOrAddComponent <MeshFilter>(); meshFilter.hideFlags = hideFlags; gameObject.hideFlags = hideFlags; #if UNITY_EDITOR // Apply the same static flags to the BeamGeometry than the VLB GAO var flags = UnityEditor.GameObjectUtility.GetStaticEditorFlags(master.gameObject); flags &= ~(UnityEditor.StaticEditorFlags.ContributeGI); // remove the Lightmap static flag since it will generate error messages when selecting the BeamGeometry GAO in the editor UnityEditor.GameObjectUtility.SetStaticEditorFlags(gameObject, flags); #endif RestartFadeOutCoroutine(); }
public void Initialize(VolumetricLightBeam master) { var hideFlags = Consts.ProceduralObjectsHideFlags; m_Master = master; transform.SetParent(master.transform, false); meshRenderer = gameObject.GetOrAddComponent <MeshRenderer>(); meshRenderer.hideFlags = hideFlags; meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; meshRenderer.receiveShadows = false; #if UNITY_5_4_OR_NEWER meshRenderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; #else meshRenderer.useLightProbes = false; #endif if (Config.Instance.actualRenderingMode != RenderingMode.GPUInstancing) { m_CustomMaterial = MaterialManager.NewMaterial(gpuInstanced: false); ApplyMaterial(); } if (SortingLayer.IsValid(m_Master.sortingLayerID)) { sortingLayerID = m_Master.sortingLayerID; } else { Debug.LogError(string.Format("Beam '{0}' has an invalid sortingLayerID ({1}). Please fix it by setting a valid layer.", Utils.GetPath(m_Master.transform), m_Master.sortingLayerID)); } sortingOrder = m_Master.sortingOrder; meshFilter = gameObject.GetOrAddComponent <MeshFilter>(); meshFilter.hideFlags = hideFlags; gameObject.hideFlags = hideFlags; RestartFadeOutCoroutine(); }