Пример #1
0
        // Update is called once per frame
        void Update()
        {
            if (!target)
            {
                target = GameObject.FindGameObjectWithTag("Player");
            }
            if (!target && Camera.current)
            {
                target = Camera.current.transform.gameObject;
            }

            if (Input.GetKeyDown(inGameToggle))
            {
                Toggle();
            }

            if (Input.GetKeyDown(pinGameToggle))
            {
                TogglePin();
            }

            if (Input.GetKeyDown(areaGameToggle))
            {
                ToggleArea();
            }

            // Set GUI data
            if (intialVisabilityStateArea || intialVisabilityStatePin)
            {
                var s = FindObjectsOfType <BlockoutSceneViewCubeGizmo>();
                var p = FindObjectsOfType <BlockoutPinGizmo>();
                List <GameObject> comments = new List <GameObject>();

                if (intialVisabilityStateArea)
                {
                    comments.AddRange(s.ToList().Select(x => x.gameObject).ToList());
                }
                if (intialVisabilityStatePin)
                {
                    comments.AddRange(p.ToList().Select(x => x.gameObject).ToList());
                }

                generalNoteData = "";
                toDoNoteData    = "";
                otherNoteData   = "";

                targetName = SceneManager.GetActiveScene().name;

                Notepad targetNote = GlobalNotes;
                for (int t = 0; t < comments.Count; ++t)
                {
                    if (comments[t].GetComponent <Collider>())
                    {
                        if (comments[t].GetComponent <Collider>().bounds
                            .Contains(
                                target.transform.position)
                            )
                        {
                            if (targetNote == null)
                            {
                                targetNote = comments[t].GetComponent <Notepad>();
                            }
                            else
                            {
                                if (Vector3.Distance(
                                        target.transform.position, targetNote.transform.position) >
                                    Vector3.Distance(
                                        target.transform.position, comments[t].transform.position)
                                    )
                                {
                                    targetNote = comments[t].GetComponent <Notepad>();
                                }
                            }
                        }
                    }
                }

                if (targetNote != GlobalNotes)
                {
                    targetName = targetNote.gameObject.name;
                }

                if (targetNote.generalNotes != "")
                {
                    generalNoteData = targetNote.generalNotes;
                }
                else
                {
                    generalNoteData = "There are no general notes.";
                }
                if (targetNote.toDoNotes != "")
                {
                    toDoNoteData = targetNote.toDoNotes;
                }
                else
                {
                    toDoNoteData = "There are no ToDo notes.";
                }
                if (targetNote.otherNotes != "")
                {
                    otherNoteData = targetNote.otherNotes;
                }
                else
                {
                    otherNoteData = "There are no other notes.";
                }



                camPos = target.transform.position;
            }
        }
Пример #2
0
        public static void Update()
        {
            if (showAreaComments != showAreaCommentsInternal)
            {
                var giz = FindObjectsOfType <BlockoutSceneViewCubeGizmo>().ToList();
                giz.ForEach(x => { x.commentsActive = showAreaComments; x.Update(); });
                if (SceneView.lastActiveSceneView)
                {
                    SceneView.lastActiveSceneView.Repaint();
                }
                showAreaCommentsInternal = showAreaComments;
            }
            if (showPinComments != showPinCommentsInternal)
            {
                var pins = FindObjectsOfType <BlockoutPinGizmo>().ToList();
                pins.ForEach(x => { x.commentsActive = showPinComments; x.Update(); });
                if (SceneView.lastActiveSceneView)
                {
                    SceneView.lastActiveSceneView.Repaint();
                }
                showPinCommentsInternal = showPinComments;
            }

            if (!ShowCommentInfo)
            {
                return;
            }

            var s = FindObjectsOfType <BlockoutSceneViewCubeGizmo>();
            var p = FindObjectsOfType <BlockoutPinGizmo>();
            List <GameObject> comments = s.ToList().Select(x => x.gameObject).ToList();

            comments.AddRange(p.ToList().Select(x => x.gameObject).ToList());

            if (generalNoteData == "")
            {
                generalNoteData = "There are no general notes here.";
            }
            if (toDoNoteData == "")
            {
                toDoNoteData = "There are no TODO notes here.";
            }
            if (otherNoteData == "")
            {
                otherNoteData = "There are no other notes here.";
            }

            targetName = "Global";
            List <Notepad> notes = Selection.gameObjects.ToList().Where(x => x.GetComponent <Notepad>() != null).Select(x => x.GetComponent <Notepad>()).ToList();

            if (notes.Count > 0)
            {
                targetName = notes[0].gameObject.name;
                if (notes[0].generalNotes != "")
                {
                    generalNoteData = notes[0].generalNotes;
                }
                else
                {
                    generalNoteData = "There are no general notes.";
                }
                if (notes[0].toDoNotes != "")
                {
                    toDoNoteData = notes[0].toDoNotes;
                }
                else
                {
                    toDoNoteData = "There are no ToDo notes.";
                }
                if (notes[0].otherNotes != "")
                {
                    otherNoteData = notes[0].otherNotes;
                }
                else
                {
                    otherNoteData = "There are no other notes.";
                }
            }
            else
            {
                Notepad targetNote = GlobalNotes;
                for (int t = 0; t < comments.Count; ++t)
                {
                    if (comments[t].GetComponent <Collider>())
                    {
                        if (comments[t].GetComponent <Collider>().bounds
                            .Contains(
                                SceneView.lastActiveSceneView.camera.ScreenToWorldPoint(new Vector3(0.5f, 0.5f, 0.15f)))
                            )
                        {
                            if (targetNote == GlobalNotes)
                            {
                                targetNote = comments[t].GetComponent <Notepad>();
                            }
                            else
                            {
                                if (Vector3.Distance(
                                        SceneView.lastActiveSceneView.camera.ScreenToWorldPoint(new Vector3(0.5f, 0.5f,
                                                                                                            0.15f)), targetNote.transform.position) >
                                    Vector3.Distance(
                                        SceneView.lastActiveSceneView.camera.ScreenToWorldPoint(new Vector3(0.5f, 0.5f,
                                                                                                            0.15f)), comments[t].transform.position)
                                    )
                                {
                                    targetNote = comments[t].GetComponent <Notepad>();
                                }
                            }
                        }
                    }
                }

                if (targetNote != GlobalNotes)
                {
                    targetName = targetNote.gameObject.name;
                }

                if (targetNote.generalNotes != "")
                {
                    generalNoteData = targetNote.generalNotes;
                }
                else
                {
                    generalNoteData = "There are no general notes.";
                }
                if (targetNote.toDoNotes != "")
                {
                    toDoNoteData = targetNote.toDoNotes;
                }
                else
                {
                    toDoNoteData = "There are no ToDo notes.";
                }
                if (targetNote.otherNotes != "")
                {
                    otherNoteData = targetNote.otherNotes;
                }
                else
                {
                    otherNoteData = "There are no other notes.";
                }
            }

            if (SceneView.lastActiveSceneView)
            {
                camPos = SceneView.lastActiveSceneView.camera.ScreenToWorldPoint(new Vector3(0.5f, 0.5f, 0f));
            }
        }
        public override void Update()
        {
            if (showSceneInformationInternal != showSceneInformation)
            {
                showSceneInformationInternal   = showSceneInformation;
                CommentBoxSceneGUI.GlobalNotes = GlobalNotes;

                if (showSceneInformation)
                {
                    CommentBoxSceneGUI.Enable();
                }
                else
                {
                    CommentBoxSceneGUI.Disable();
                }

                if (SceneView.lastActiveSceneView)
                {
                    SceneView.lastActiveSceneView.Repaint();
                }
            }

            if (showAreaCommentsInternal != showAreaComments)
            {
                CommentBoxSceneGUI.showAreaComments = showAreaComments;
                showAreaCommentsInternal            = showAreaComments;
            }

            if (showPinCommentsInternal != showPinComments)
            {
                CommentBoxSceneGUI.showPinComments = showPinComments;
                showPinCommentsInternal            = showPinComments;
            }

            if (CommentBoxSceneGUI.ShowCommentInfoInternal != CommentBoxSceneGUI.ShowCommentInfo)
            {
                CommentBoxSceneGUI.GlobalNotes = GlobalNotes;
                if (SceneView.currentDrawingSceneView)
                {
                    SceneView.currentDrawingSceneView.Repaint();
                }
                else if (SceneView.lastActiveSceneView)
                {
                    SceneView.lastActiveSceneView.Repaint();
                }
                CommentBoxSceneGUI.ShowCommentInfoInternal = CommentBoxSceneGUI.ShowCommentInfo;
            }

            // Repaint window is a area / pin comment is selected
            if (Selection.activeGameObject)
            {
                if (Selection.activeGameObject.GetComponentInParent <BlockoutPinGizmo>())
                {
                    selectedNote = Selection.activeGameObject.GetComponentInParent <BlockoutPinGizmo>()
                                   .GetComponent <Notepad>();
                    repaint = true;
                }
                else if (Selection.activeGameObject.GetComponent <BlockoutSceneViewCubeGizmo>())
                {
                    selectedNote = Selection.activeGameObject.GetComponent <BlockoutSceneViewCubeGizmo>()
                                   .GetComponent <Notepad>();
                    repaint = true;
                }
                else if (Selection.activeGameObject.GetComponent <Notepad>())
                {
                    selectedNote = Selection.activeGameObject.GetComponent <Notepad>();
                    repaint      = true;
                }
                else
                {
                    selectedNote = null;
                    repaint      = true;
                }
            }
            else
            {
                selectedNote = null;
                repaint      = true;
            }

            // Set text colour if chanaged
            if (sceneViewTextColor != sceneViewTextColorInternal)
            {
                CommentBoxSceneGUI.textColor = sceneViewTextColor;
                sceneViewTextColorInternal   = sceneViewTextColor;
                if (SceneView.lastActiveSceneView)
                {
                    SceneView.lastActiveSceneView.Repaint();
                }
            }
        }