I’m currently working on a game, in Unity, which has levels stored inside of ScriptableObjects. The current way that I’m doing is by using a TextField and manually typing the exact level design that’ll be drawn by a controller object.
I’ve been searching around for a way to implement a graph field inside of the inspector panel, but without much luck. Is there a way to implement this type of field in Unity?
I’m using Unity 2019.4.5f.
Your title mentioned “Grid Component”, and your question above mentions “graph field”. They are somewhat different concepts. I’m also not sure how your current TextField is supposed to map to a grid or a graph field. More details would help.
Also, to confirm, you’re using UI Toolkit (formally UIElements) to draw your Inspector, or are you using IMGUI?
Let me see how I can word this properly.
I’m building a 2D game and I’m using ScriptableObjects to store the level format. I’m currently doing this via a text area field, but it becomes very cumbersome to change the level format. The levels are always a fixed size, though that doesn’t necessarily mean that all of the space will be used.
I was thinking of a field that displays a grid on the side to design the level. It would show up on the inspector side, so that could be the UI Toolkit that you’re referring to.
I hope that gives you a better idea on what I’m thinking.
I understand better what you’re after. That said, I’d recommend either asking in the IMGUI (ie. GUI.TextField
) forum here:
Or learning a bit about UI Toolkit, the new UI framework for Unity, here:
I’m happy to help with the specifics if you do go the UI Toolkit route and you run into problems.
Got it. Not sure if I have to start another thread but since my levels will alway have a fixed size, I’m going with the button approach.
My question is how can I create a row of buttons? Adding buttons just puts them in one column.
EDIT: Never mind. There’s USS attribute to do this
Yep, it’s flex-direction: row;