Beispiel #1
0
        public SceneMeshState GetCameraState(Camera camera, bool generate)
        {
            if (!camera)
            {
                return(null);
            }

            if (CameraStates != null)
            {
                for (int i = CameraStates.Length - 1; i >= 0; i--)
                {
                    var sceneMeshState = CameraStates[i];
                    if (sceneMeshState == null ||
                        System.Object.ReferenceEquals(sceneMeshState.Camera, null) ||
                        !sceneMeshState.Camera)
                    {
                        ArrayUtility.RemoveAt(ref CameraStates, i);
                        continue;
                    }
                    if (CameraStates[i].Camera == camera)
                    {
                        return(CameraStates[i]);
                    }
                }
            }

            if (!generate)
            {
                return(null);
            }

            int index;

            if (CameraStates != null)
            {
                index = CameraStates.Length;
                Array.Resize(ref CameraStates, index + 1);
            }
            else
            {
                CameraStates = new SceneMeshState[1];
                index        = 0;
            }

            CameraStates[index]                         = new SceneMeshState();
            CameraStates[index].Camera                  = camera;
            CameraStates[index].WorldPointSizes         = new float[PointControlId.Length];
            CameraStates[index].WorldPointBackfaced     = new bool[PointControlId.Length];
            CameraStates[index].WorldPointColors        = new Color[PointControlId.Length * 2];
            CameraStates[index].PolygonCenterPointSizes = new float[PolygonCenterPoints.Length];
            return(CameraStates[index]);
        }
Beispiel #2
0
        public SceneMeshState GetSceneViewState(SceneView sceneView, bool generate)
        {
            if (!sceneView)
            {
                return(null);
            }

            if (SceneViewStates != null)
            {
                for (int i = SceneViewStates.Length - 1; i >= 0; i--)
                {
                    var sceneMeshState = SceneViewStates[i];
                    if (sceneMeshState == null ||
                        System.Object.ReferenceEquals(sceneMeshState.SceneView, null) ||
                        !sceneMeshState.SceneView)
                    {
                        ArrayUtility.RemoveAt(ref SceneViewStates, i);
                        continue;
                    }
                    if (SceneViewStates[i].SceneView == sceneView)
                    {
                        return(SceneViewStates[i]);
                    }
                }
            }

            if (!generate)
            {
                return(null);
            }

            int index;

            if (SceneViewStates != null)
            {
                index = SceneViewStates.Length;
                Array.Resize(ref SceneViewStates, index + 1);
            }
            else
            {
                SceneViewStates = new SceneMeshState[1];
                index           = 0;
            }

            SceneViewStates[index]                         = new SceneMeshState();
            SceneViewStates[index].SceneView               = sceneView;
            SceneViewStates[index].WorldPointSizes         = new float[PointControlId.Length];
            SceneViewStates[index].WorldPointBackfaced     = new bool[PointControlId.Length];
            SceneViewStates[index].WorldPointColors        = new Color[PointControlId.Length * 2];
            SceneViewStates[index].PolygonCenterPointSizes = new float[PolygonCenterPoints.Length];
            return(SceneViewStates[index]);
        }