Exemplo n.º 1
0
        private static FeatureEditorWindow OpenWindow()
        {
            FeatureEditorWindow window = GetWindow <FeatureEditorWindow>();

            window.titleContent = new GUIContent("Labrys Feature Editor");
            return(window);
        }
Exemplo n.º 2
0
 public static FeatureEditorWindow GetInstance()
 {
     if (instance == null)
     {
         instance = OpenWindow();
     }
     return(instance);
 }
Exemplo n.º 3
0
        private void DrawObjects()
        {
            FeatureAsset feature = FeatureEditorWindow.GetInstance().Feature;

            if (feature == null)
            {
                return;
            }

            Vector2 screenPosition = Vector2.zero;
            Rect    bounds         = new Rect(screenPosition, GetScaledTileSize());

            // Draw Sections
            foreach (KeyValuePair <Vector2Int, Section> section in feature.GetSections())
            {
                screenPosition  = GridToScreenPos(section.Key);
                bounds.position = screenPosition;
                bounds.center   = screenPosition;
                Color temp = GUI.color;
                GUI.color = feature.IsSelected(section.Key) ? sectionSelectedColor : Color.white;
                GUI.Box(bounds, section.Value.variant);
                GUI.color = temp;
            }

            // Draw Links
            foreach (KeyValuePair <Vector2Int, Link> link in feature.GetLinks())
            {
                screenPosition = GridToScreenPos(link.Key);
                Handles.color  = link.Value.open ? linkOpenColor : linkClosedColor;
                Handles.BeginGUI();
                Handles.DrawSolidDisc(new Vector3(screenPosition.x, screenPosition.y), Vector3.forward, scale * LINK_SIZE);
                if (link.Value.external)
                {
                    Handles.color = linkExternalColor;
                    Handles.DrawSolidArc(new Vector3(screenPosition.x, screenPosition.y), Vector3.forward, Vector3.left, 180f, scale * LINK_SIZE);
                }
                Handles.EndGUI();
            }
        }