示例#1
0
 //Show the objects
 public IEnumerator GetShowRenderers(MyCustomIENumeratorOutput output)
 {
     if (myRenderers == null)
     {
         if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)
         {
             SetupVars(false);
         }
         yield return 0;
     }
     output.SetOutput((object)myRenderers);
 }
示例#2
0
    IEnumerator RecalculateCulling(bool weAreInAtLeastOneArea)
    {
        calculatingCulling = true;
        Dictionary<Renderer, bool> rendererSettings = new Dictionary<Renderer, bool>();

        //Disable all  disabled areas using the new master list
        //After which we enable the other areas to take the right union
        foreach (CullingAreaSettings_Auto liveCullGroup in currentCameraSettingsForAllAreas)
        {
            if (liveCullGroup.cullingOptions == CullingOptions_Auto._)
            {
                //Add all renderers to the list
                MyCustomIENumeratorOutput output = new MyCustomIENumeratorOutput();
                yield return StartCoroutine(liveCullGroup.script.GetHideRenderers(output));
                if (output.GetOutput() != null)
                {
                    SetRendererSetting((ArrayList)output.GetOutput(), rendererSettings, false);
                }
            }
        }
        //Enable all enabled areas
        foreach (CullingAreaSettings_Auto liveCullGroup in currentCameraSettingsForAllAreas)
        {
            if (liveCullGroup.cullingOptions == CullingOptions_Auto.Show || (!weAreInAtLeastOneArea && (outsideAllAreas == CullingCameraOption_OutsideAllAreas_Auto.PrintErrorShowAllGroups || outsideAllAreas == CullingCameraOption_OutsideAllAreas_Auto.ShowAllGroups)))
            {

                MyCustomIENumeratorOutput output = new MyCustomIENumeratorOutput();
                yield return StartCoroutine(liveCullGroup.script.GetShowRenderers(output));
                if (output.GetOutput() != null)
                {
                    SetRendererSetting((ArrayList)output.GetOutput(), rendererSettings, true);
                }
            }
        }
        //Final pass, remove the HIDDEN renderers
        foreach (CullingAreaSettings_Auto liveCullGroup in currentCameraSettingsForAllAreas)
        {
            if (liveCullGroup.cullingOptions == CullingOptions_Auto.AlwaysHide)
            {
                MyCustomIENumeratorOutput output = new MyCustomIENumeratorOutput();
                yield return StartCoroutine(liveCullGroup.script.GetHideRenderers(output));
                if (output.GetOutput() != null)
                {
                    SetRendererSetting((ArrayList)output.GetOutput(), rendererSettings, false);
                }
            }
        }

        //Apply actual culling
        foreach (KeyValuePair<Renderer, bool> kvp in rendererSettings)
        {
            kvp.Key.enabled = kvp.Value;
        }

        //We aren't in any area! Show error?
        if (!weAreInAtLeastOneArea && (outsideAllAreas == CullingCameraOption_OutsideAllAreas_Auto.PrintErrorHideAllGroups || outsideAllAreas == CullingCameraOption_OutsideAllAreas_Auto.PrintErrorShowAllGroups))
        {
            Debug.LogError("CullingError: OUTSIDE of all  CullingAreas at " + transform.position);
        }
        calculatingCulling = false;
    }