public override void OnDrawingGizmosSelected()
            {
                if (GetScenePlayerMode(SceneEditor.Current.Scene) != PlayerMode.Trajectory)
                {
                    return;
                }

                wasSelected = Target;
                var influenceArea = getInfluenceArea(Target);

                if (influenceArea == null)
                {
                    return;
                }

                var boundaries = GetElementBoundaries(Target);
                var rect       = influenceArea.ScreenRect(boundaries);

                if (!influenceArea.hasInfluenceArea())
                {
                    rect.position -= new Vector2(20, 20);
                    rect.size      = boundaries.size + new Vector2(40, 40);
                }

                rect = rect.AdjustToViewport(SceneEditor.Current.Size.x, SceneEditor.Current.Size.y, SceneEditor.Current.Viewport);

                EditorGUI.BeginChangeCheck();
                var newRect = HandleUtil.HandleRect(influenceArea.GetHashCode() + 1, rect, 10f,
                                                    (polygon, over, active) =>
                {
                    HandleUtil.DrawPolyLine(polygon, true, Color.blue);
                    HandleUtil.DrawPolygon(polygon, new Color(0, 0, 1f, 0.3f));
                },
                                                    (point, over, active) => HandleUtil.DrawSquare(point, 6.5f, Color.yellow, Color.black));

                newRect = HandleUtil.HandleRectMovement(influenceArea.GetHashCode(), newRect);

                if (EditorGUI.EndChangeCheck())
                {
                    var original = newRect.ViewportToScreen(SceneEditor.Current.Size.x, SceneEditor.Current.Size.y, SceneEditor.Current.Viewport);

                    original.position -= boundaries.position;
                    var rectFixed = FixToBoundaries(new RectInt((int)original.x, (int)original.y, (int)original.width, (int)original.height), boundaries);
                    // And then we set the values in the reference
                    influenceArea.setInfluenceArea(rectFixed.x, rectFixed.y, rectFixed.width, rectFixed.height);
                }
            }
Example #2
0
            private void DrawExit(SceneDataControl scene, ExitDataControl exit)
            {
                var scenes = Controller.Instance.SelectedChapterDataControl.getScenesList();
                var index  = scenes.getSceneIndexByID(exit.getNextSceneId());

                // If the exit points to a cutscene it normally is out of the array
                if (index < 0 || index > scenes.getScenes().Count)
                {
                    return;
                }

                var polygon = AdaptToViewport(GetExitArea(scene, exit), space);

                if (polygon == null || polygon.Length == 0)
                {
                    // If the exit is empty use the scene center itself to prevent errors
                    polygon = new [] { AdaptToViewport(GetSceneRect(scene), space).center };
                }

                var c = sceneColors[scene.getId()];

                c = new Color(c.r, c.g, c.b, 0.8f);
                HandleUtil.DrawPolygon(polygon, c);

                var nextScene = scenes.getScenes()[index];
                var sceneRect = AdaptToViewport(GetSceneRect(nextScene), space);

                Vector2 origin = polygon.Center(), destination;

                if (exit.hasDestinyPosition())
                {
                    destination   = new Vector2(exit.getDestinyPositionX(), exit.getDestinyPositionY());
                    destination.x = sceneRect.x + (destination.x / sizes[nextScene.getPreviewBackground()].x) * sceneRect.width;
                    destination.y = sceneRect.y + (destination.y / sizes[nextScene.getPreviewBackground()].y) * sceneRect.height;
                }
                else
                {
                    destination = sceneRect.ToPoints().Center();
                }

                HandleUtil.DrawPolyLine(new [] { origin, destination }, false, sceneColors[scene.getId()], 4);

                DrawArrowCap(destination, (destination - origin), 15f);
            }
 private void DrawArea(Vector2[] points, Color lineColor, Color backgroundColor)
 {
     HandleUtil.DrawPolyLine(points, true, lineColor);
     HandleUtil.DrawPolygon(points, backgroundColor);
 }