Search Unity

Does anyone know how to access OcclusionCullingData and manually get/set it?

Discussion in 'Editor & General Support' started by snarlynarwhal, Mar 14, 2019.

  1. snarlynarwhal

    snarlynarwhal

    Joined:
    Jan 16, 2014
    Posts:
    30
    For our project we use prefabs for our maps instead of scenes since they have less overhead. The con is that we have to manually export scene-specific data like LightmapData. We easily built tools to do this thanks to the wonderful Lighting APIs. However, Occlusion Culling does seem to not provide access to OcclusionCullingData nor an API to set/get a camera's OcclusionCullingData. Does anyone know of how we might accomplish this?
     
  2. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    328
    You can't, even with reflection
     
  3. snarlynarwhal

    snarlynarwhal

    Joined:
    Jan 16, 2014
    Posts:
    30
    Oh man :/ alright thanks for the confirmation!
     
  4. TurboHermit

    TurboHermit

    Joined:
    Dec 20, 2011
    Posts:
    40
    I've been looking around for something similar and couldn't find any other forum posts on it. I started experimenting today, so maybe this info is useful for anyone still hitting this post in their searches.

    You CAN access OcclusionCullingData through the use of SerializedObjects and SerializedProperties, at least to read the data directly from the assets. It's very unwieldy of course and an accessible API would be a good feature request.

    My use-case is only for in the editor though, so not sure if it's useful to you, but here's what I do:
    1. Get the OcclusionCullingData.asset file through AssetDatabase.Load or through EditorGUILayout.ObjectField as a UnityEngine.Object
    2. new SerializedObject and pass the OcclusionCullingData Object as parameter
    3. Iterate through the property names using SerializedObject.GetIterator and SerializedProperty.Next
    4. Check the names of the properties and use that info to get/set what you want
    5. SerializedObject.ApplyModifiedProperties if you want to save the changes
     
  5. mohammedakkam6

    mohammedakkam6

    Joined:
    Jan 16, 2021
    Posts:
    6
    I need to make json file the key will be which chunk am I and value will be list of chunks that can I see