Exemplo n.º 1
0
 void OnDestroy()
 {
     GameObject.Destroy(this.lightObject);
     this.lightObject         = null;
     this.skyDirectionalLight = null;
     this.hdLight             = null;
     this.timer        = null;
     this.dayFlare     = null;
     this.nightFlare   = null;
     this.volume       = null;
     this.pbsky        = null;
     this.clouds       = null;
     this.whiteBalance = null;
 }
Exemplo n.º 2
0
        private static void LogSkyData(Volume volume, HDCamera hd)
        {
            PhysicallyBasedSky sky = null;

            foreach (var component in volume.profile.components)
            {
                if (component is PhysicallyBasedSky bps)
                {
                    sky = bps;
                    break;
                }
            }

            if (sky == null)
            {
                Debug.LogError("No sky component available.");
                return;
            }

            var skyUpdateContext = hd.GetType().GetProperty("visualSky", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(hd);

            if (skyUpdateContext == null)
            {
                Debug.LogError("No sky context available.");
                return;
            }

            var skyRenderer = skyUpdateContext.GetType().GetProperty("skyRenderer", BindingFlags.Public | BindingFlags.Instance)?.GetValue(skyUpdateContext);

            if (skyRenderer == null)
            {
                Debug.LogError("No sky renderer available.");
                return;
            }

            var baseFrameField = skyRenderer.GetType().BaseType?.GetField("m_LastFrameUpdate", BindingFlags.NonPublic | BindingFlags.Instance);

            if (baseFrameField == null)
            {
                Debug.LogError("No frame count field available in sky renderer base class.");
                return;
            }

            var precomputedData = skyRenderer.GetType().GetField("m_PrecomputedData", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(skyRenderer);

            if (precomputedData == null)
            {
                Debug.LogError("No precomputed data field available in sky renderer.");
                return;
            }

            var frameField = precomputedData.GetType().GetField("m_LastFrameComputation", BindingFlags.NonPublic | BindingFlags.Instance);

            if (frameField == null)
            {
                Debug.LogError("No frame count field available in precomputed data.");
                return;
            }

            var currentBounces = precomputedData.GetType().GetField("m_LastPrecomputedBounce", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(precomputedData);

            if (currentBounces == null)
            {
                Debug.LogError("No bounce data available in precomputed data.");
                return;
            }

            var targetBounces = sky.numberOfBounces.value;
            var bouncesVal    = currentBounces is int bounces ? bounces : 0;

            Debug.LogError($"Current bounces: {bouncesVal} expected: {targetBounces}");
        }