Пример #1
0
        private void OnDialogDestroyed(Dialog dialog)
        {
            RuntimeWindow dialogWindow = dialog.Content.GetComponentInParent <RuntimeWindow>();

            OnContentDestroyed(dialog.Content);

            if (!m_dialogManager.IsDialogOpened)
            {
                Transform pointerOverWindow = dialog.Content != null?FindPointerOverWindow(dialogWindow) : null;

                if (pointerOverWindow != null)
                {
                    RuntimeWindow window = pointerOverWindow.GetComponentInChildren <RuntimeWindow>();
                    if (window == null)
                    {
                        window = m_editor.GetWindow(RuntimeWindowType.Scene);
                    }
                    window.IsPointerOver = true;
                    m_editor.ActivateWindow(window);
                }
                else
                {
                    RuntimeWindow window = m_editor.GetWindow(RuntimeWindowType.Scene);
                    m_editor.ActivateWindow(window);
                }

                if (DeferUpdate != null)
                {
                    DeferUpdate();
                }
            }
        }
Пример #2
0
        protected virtual void Start()
        {
            if (m_prefab == null)
            {
                Debug.LogWarning("m_prefab is not set");
                return;
            }

            m_editor = IOC.Resolve <IRTE>();
            m_scene  = m_editor.GetWindow(RuntimeWindowType.Scene);

            IResourcePreviewUtility resourcePreview = IOC.Resolve <IResourcePreviewUtility>();

            m_texture = resourcePreview.TakeSnapshot(m_prefab);
            if (m_preview != null)
            {
                m_preview.sprite = Sprite.Create(m_texture, new Rect(0, 0, m_texture.width, m_texture.height), new Vector2(0.5f, 0.5f));
                m_preview.color  = Color.white;
            }

            if (m_prefabName != null)
            {
                m_prefabName.text = m_prefab.name;
            }
        }
Пример #3
0
        private void Awake()
        {
            m_editor = IOC.Resolve <IRTE>();

            if (Window == null)
            {
                Window = m_editor.GetWindow(RuntimeWindowType.SceneView);
                if (Window == null)
                {
                    Debug.LogError("m_window == null");
                    enabled = false;
                    return;
                }
            }

            m_awaked = true;

            AwakeOverride();

            if (IsWindowActive)
            {
                OnWindowActivated();
            }
            m_editor.ActiveWindowChanged += OnActiveWindowChanged;
        }
        private void Start()
        {
            if (m_window == null)
            {
                m_window = m_editor.GetWindow(RuntimeWindowType.Scene);
                if (m_window == null)
                {
                    Debug.LogError("m_window == null");
                    enabled = false;
                    return;
                }
            }

            if (m_selectionGizmoModel == null)
            {
                if (GLRenderer.Instance == null)
                {
                    GameObject glRenderer = new GameObject();
                    glRenderer.name = "GLRenderer";
                    glRenderer.AddComponent <GLRenderer>();
                }

                if (m_exposeToEditor != null && m_exposeToEditor.ShowSelectionGizmo)
                {
                    GLRenderer.Instance.Add(this);
                }
            }

            if (!m_editor.Selection.IsSelected(gameObject))
            {
                Destroy(this);
            }
        }
Пример #5
0
        private void OnCreatePolyshape()
        {
            GameObject     go;
            ExposeToEditor exposeToEditor;

            CreateShape(PBShapeType.Cube, out go, out exposeToEditor);
            exposeToEditor.SetName("Poly Shape");

            IRTE          rte   = IOC.Resolve <IRTE>();
            RuntimeWindow scene = rte.GetWindow(RuntimeWindowType.Scene);

            Vector3    position;
            Quaternion rotation;

            GetPositionAndRotation(scene, out position, out rotation);
            go.transform.position = position;
            go.transform.rotation = rotation;

            PBMesh pbMesh = go.GetComponent <PBMesh>();

            pbMesh.Clear();

            PBPolyShape polyShape = go.AddComponent <PBPolyShape>();

            polyShape.IsEditing = true;

            rte.Selection.activeGameObject = go;

            IProBuilderTool tool = IOC.Resolve <IProBuilderTool>();

            tool.Mode = ProBuilderToolMode.PolyShape;
        }
Пример #6
0
        private void OnCreatePrimitive()
        {
            PBShapeType    type = PBShapeType.Stair;
            GameObject     go;
            ExposeToEditor exposeToEditor;

            CreateShape(type, out go, out exposeToEditor);

            IRTE          rte   = IOC.Resolve <IRTE>();
            RuntimeWindow scene = rte.GetWindow(RuntimeWindowType.Scene);
            Vector3       position;
            Quaternion    rotation;

            GetPositionAndRotation(scene, out position, out rotation);

            go.transform.position = position + rotation * Vector3.up * exposeToEditor.Bounds.extents.y;
            go.transform.rotation = rotation;
        }
        private void CreateRenderTextureCamera()
        {
            bool wasActive = m_camera.gameObject.activeSelf;

            m_camera.gameObject.SetActive(false);
            m_renderTextureCamera = m_camera.gameObject.AddComponent <RenderTextureCamera>();

            if (m_output != null)
            {
                m_renderTextureCamera.OutputRoot = m_output;
            }
            else
            {
                IRTE          rte         = IOC.Resolve <IRTE>();
                RuntimeWindow sceneWindow = rte.GetWindow(RuntimeWindowType.Scene);
                m_renderTextureCamera.OutputRoot = (RectTransform)sceneWindow.transform;
            }
            m_renderTextureCamera.OverlayMaterial = new Material(Shader.Find("Battlehub/RTCommon/RenderTextureOverlay"));
            m_camera.clearFlags      = CameraClearFlags.SolidColor;
            m_camera.backgroundColor = new Color(0, 0, 0, 0);
            m_camera.gameObject.SetActive(wasActive);
        }
Пример #8
0
        private void OnEndFrameRendering(UnityEngine.Rendering.ScriptableRenderContext arg1, Camera[] arg2)
        {
            UnityEngine.Rendering.RenderPipelineManager.endFrameRendering -= OnEndFrameRendering;

            //LWRP OR HDRP;

            bool wasActive = m_graphicsLayerCamera.gameObject.activeSelf;

            m_graphicsLayerCamera.gameObject.SetActive(false);

            m_renderTextureCamera = m_graphicsLayerCamera.gameObject.AddComponent <RenderTextureCamera>();
            //m_renderTextureCamera.Fullscreen = false;

            IRTE          rte         = IOC.Resolve <IRTE>();
            RuntimeWindow sceneWindow = rte.GetWindow(RuntimeWindowType.Scene);

            m_renderTextureCamera.OutputRoot      = (RectTransform)sceneWindow.transform;
            m_renderTextureCamera.OverlayMaterial = new Material(Shader.Find("Battlehub/RTCommon/RenderTextureOverlay"));
            m_graphicsLayerCamera.clearFlags      = CameraClearFlags.SolidColor;
            m_graphicsLayerCamera.backgroundColor = new Color(0, 0, 0, 0);

            m_graphicsLayerCamera.gameObject.SetActive(wasActive);
        }
        public static IRuntimeSelectionComponent GetScenePivot(this IRTE editor)
        {
            if (editor.ActiveWindow != null)
            {
                IRuntimeSceneComponent scenePivot = editor.ActiveWindow.IOCContainer.Resolve <IRuntimeSceneComponent>();
                if (scenePivot != null)
                {
                    return(scenePivot);
                }
            }

            RuntimeWindow sceneWindow = editor.GetWindow(RuntimeWindowType.Scene);

            if (sceneWindow != null)
            {
                IRuntimeSelectionComponent scenePivot = sceneWindow.IOCContainer.Resolve <IRuntimeSelectionComponent>();
                if (scenePivot != null)
                {
                    return(scenePivot);
                }
            }

            return(null);
        }
Пример #10
0
 protected virtual RuntimeWindow GetDefaultWindow()
 {
     return(m_editor.GetWindow(RuntimeWindowType.Scene));
 }