private void OnScenePresetDraw(Preset preset)
        {
            if (preset == null)
            {
                self.OnValidate();
                return;
            }

            // for any reason fail safe, if it failure to find tmp-camera.
            if (TmpCamera == null ||
                !TmpCamera.ContainsKey(preset) ||
                TmpCamera[preset] == null)
            {
                InitTmpCameraOnScene();
                return;
            }

            // maintance hierarchy structure.
            if (preset.transform.parent != self.transform)
            {
                preset.transform.SetParent(self.transform, false);
            }

            PresetEditor.OnSceneTargetForwardReference(controlId, preset);
            OnSceneHandleCoordinatesTools(preset);
            PresetEditor.OnSceneRotationHints(controlId, preset, delta5sec);
            PresetEditor.OnSceneZoomRange(preset);
        }
Beispiel #2
0
        private void OnSceneGUIPlayMode()
        {
            Preset preset = self.PresetList[self.Selected];

            if (preset == null)
            {
                return;
            }

            PresetEditor.OnSceneZoomRange(preset);
        }
        /// <summary>Draw handler of camera stand. Move & Rotate.</summary>
        /// <param name="preset"></param>
        private void OnSceneHandleCoordinatesTools(Preset preset)
        {
            if (Tools.current == Tool.Move)
            {
                PresetEditor.OnSceneHandlePosition(preset);
                // Override Move tools in EditorScene
                Tools.hidden = IsAnyCameraDisplayOnScene;
            }
            else if (Tools.current == Tool.Rotate)
            {
                // Override Move tools in EditorScene
                Tools.hidden = IsAnyCameraDisplayOnScene;
                bool  moveAll = Event.current.control;
                float diffH, diffV;
                if (PresetEditor.OnSceneHandleRotation(preset, moveAll, out diffH, out diffV))
                {
                    if (moveAll)
                    {
                        foreach (Preset otherPreset in self.PresetList)
                        {
                            if (otherPreset.m_DisplayOnScene)
                            {
                                PresetEditor.UpdatePresetCoordinatesValue(otherPreset, diffH, diffV);
                            }
                        }
                    }
                }
            }
            // Update Relative PointTo Location
            if (TmpCamera.ContainsKey(preset))
            {
                TmpCamera[preset].transform.position = preset.Instance.GetCameraPivot().position;
                Vector3 upward;
                switch (preset.m_ClampAngle.m_UpwardReferenceMethod)
                {
                default:
                case UpwardReferenceMethod.World: upward = Vector3.up; break;

                case UpwardReferenceMethod.Custom: upward = (preset.m_ClampAngle.m_UpReference == null)? Vector3.up : preset.m_ClampAngle.m_UpReference.up; break;

                case UpwardReferenceMethod.Local: upward = Vector3.Lerp(Vector3.Project(preset.Instance.m_CameraPivot.transform.up, preset.Instance.transform.up), preset.Instance.transform.up, .5f); break;

                case UpwardReferenceMethod.RealLocal: upward = preset.Instance.CameraPivot.transform.up; break;
                }
                TmpCamera[preset].transform.LookAt(preset.Instance.GetCameraLookAt(), upward);
            }
        }