Hey, trying to make GUI dialog boxes in my game and having some difficulties. I’m using the .json files from the demo code.
-
Adding the adventue-gui-skin.json to my content pipeline causes a build error, saying Object Reference not found. Looking at the demo code I realized that the ski.json wasn’t added in the content pipeline so I just put it in the directory and left it at that. It seems to work now but I would really like to know the cause of the problem.
-
Removed, found a typo in my version somehow.
-
Finally, no so much an error as a strange thing, like 70% of the demo projects are set to being Class Libraries, which means I can’t call them as executable and see them in action. I can’t even change them from Class Libraries as the action is greyed out, thoughts?
FWIW Here’s the file I’m using https://github.com/craftworkgames/MonoGame.Extended/blob/develop/Source/Demos/Demo.Features/Content/adventure-gui-skin.json
I’m really grateful for these extensions, but I’m finding the lack of documentation on how to use anything to be extremely difficult.
I have no idea what anything in this json is intuitively or why it’s placed where it is. I have no idea what NinePatches is.
Really hoping someone can explain some things to me.
I came here to ask the same question. I cannot for the life of me figure out how the Demo references that json file because of the same error you are running into. As far as I can tell the Demo doesn’t actually include title-screen.json
or adventure-gui-skin.json
in the Content but is able to use them like it is.
I gave up and decided to make my own. Spent less time on it than i did trying to understand what was going on with the extended.
The problem is, GUI is currently WIP, and I think it has lower priority than the other components of the library.
The project Demo.Features.WindowsDirectX and Demo.Features.WindowsOpenGL are application projects. You should be able to build and run those two.
Anyway, here’s how I use the skin file. Basically, I include it into the content file. However, make sure to change the Build Action to Copy. This way the file will be copied over to the content directory by the content pipeline tool (without manually copying over).
Then, in the code, load the skin file using GuiSkin.FromFile
. The parameter path should point to the file inside the content directory, and includes the file extension.
for example
var guiSkin = GuiSkin.FromFile(Content, Content.RootDirectory + "/title/main-menu.json");
From there, I am able to create the gui control from the skin, using GuiSkin.Create()
.