I’m trying to create a GUI and instead of having 10 draw calls I decided to use the SpriteManager script. Unfortunately I don’t seem to get it to work. Is there a GUI sample somewhere working? For the sake of simplicity let’s say I just want to display a 64x64 texture on the left-bottom part of the iphone screen. What should I do?
This is what I did so far:
- Created a gameobject at position 0,0,0 and attached the SpriteManager script to it. Set the texture and all for the SpriteManager.
- Created a gameobject that I call “map”, it’s at a random position right now, I just moved it in front of the camera.
- Created a gameobject named ‘spriteCreator’ and attached a script to it that has a link pointing to the instance of the SpriteManager and another link to the ‘map’ object and then this line:
sm.AddSprite(map, 1, 1, 0, 64, 64, 64, false);
I was hoping to see the map on screen but I don’t see anything. I played around with the xy axis and all the spritemanager variables without much luck. What am I missing? anyone got a sample GUI working?
On page 11 of the SpriteManager thread you’ll find an example. There is one addition I’ve made to it so far, since if it is used on the first scene the orientation hasn’t been setup properly. But, if you make the one change to SpriteManager that is in the project it will work just fine.
I guess I’ll have to include a readme.txt in there for how everything works and document it a lot better.
Maybe a little high level overview description would help. I got that you put all your buttons in a single texture, and you can define them with AddButton. But how would you, say, change the settings for that button to show it in a different state?
Also, in the example, the UI camera seems to not be showing the actual UI (only Options Help and Credits are shown rest cut off) but its not clear how to shift the camera view if I ran into the same problem.
Finally, the input seems to be based on a mouse (eg: Input.GetMousebuttonUp) I’m not sure how we’d plug touches into what you’ve written, or if the mouse is emulated by touches on the iPhone?
You wrote the code for your own needs so, expecting a lot of support from you may not be fair. Just wanted to let you know where my confusion was.
I don’t need anything complicated-- just to put a bunch of button on the screen and be able to change them. I’ve already written code to handle the touches.
The example is for iPhone Tall, and there is the error that if on the first screen it doesn’t know what the orientation is. I’ve added a variable to make it set orientation, but I haven’t uploaded the fix yet.
The mouse calls work for iPhone as touch one, which is perfect for most UI calls. Obviously this isn’t setup for pinching. I’ll upload a new version tonight, since I have some time. I’ll add some more documentation in the code, as well as a readme.txt in the example. I don’t want to put it in the forum since I already have (somewhere back at page 6 or 7) and it just gets lost.
I don’t mind supporting it since I effectively get free QA