Im having some strange problems with GUITextures that are using transparent PNG’s and other GUI weirdness.
There are some texture clamping artifacts that extend out from the edges of the GUITextures ive created - unless i make the edge of the PNG 100% transparent, i get these strange blurred bits.
(as an aside - I cant seems to accurately detect the OnMouseUp() function - is it related)
I have included 2 screenshots of my GUI - one on Mac which looks perfect, the other from a PC which looks too overly transparent. I tried it on an HP Pavillion ze 2000 Notebook - it has an ATI card (didnt check in detail abt OpenGL support)
am i doing something totally stupid or is this a compatibility problem.
Holy crap thaa tree is awesome. Is that real time? Nice slick GUI too.
Oh, errrm back to the problem ;). I don’t know what could cause that. Unity builds should always look exactly alike no matter what platform. Just so you know, since Unity reformats all images that you import it doesn’t matter what format your textures are in in the assets folder. But the import settings can have an effect on things. You might want to look at that.
Also if you select a texture in the project pane you will get it’s properties in the inspector where you can set the wrap mode. That might help your wrap artifacts.
Hi Yoggy - thanks for the tips. cool name by the way - sounds like a character from Star Wars.
Tried playing around with the texture mode - but still got the same problem.
Most of my textures are nonPower2 - could this be a problem? I dont want to be forced to pow2 textures because it will make the mousehit checking a right pain in the arse (right?).
The Mac/PC texture thing is a tough one - i think that may be a more complex Unity issue for the OTEE guys to look at. (I would guess its related to how OpenGL handles the DXT5 textures (am i right that all textures are converted to DXT5 normally?)- the problem only seems to occur on slightly older hardware, i havent tried using RGBA32 format yet)
Ive noticed that the clamps extend vertically down and horizontally left only. i was a bit confused about setting up GUITextures that are always ‘pixel-perfect’ - the Unity method is kind of weird compared to most of development environments - i wish they would standardize it. (like Virtools would be good)
The OnMouseUp function is wildly innaccurate too - any ideas on what might be causing that - im getting MouseUps even when im clicking nowhere near the button (or its not registering when i am clicking in the right spot)
thanks heaps - the Unity forum is really full of top people - v. helpful
ps. sorry the tree is a background image - a photo in fact. thats probably why it looks so good ^^;
Are you talking about getting mouse ups after you click the button, move your mouse away and un click? That can be fixed by keeping track of whether the mouse is inside the button and only doing the event if it is on mouse up.
You could try a power of two texture and see if that one displays correctly. You can do mousehit checking on larger than life GUI textures but you will need to make a separate mouse hit receiving object. Yep, pain in the arse. Mostly non power of two is the way to go for GUI.
Another idea is to check what happens when you use the same transparent textures in other ways, like on particle systems, an alpha shader plane, etc. Might just be a GUI bug or could be texture related. I am pretty sure this will end with a bug report and a wait until the next version.
That tree looks very unreal somehow like its not a photo. The clouds are very realistic though.
Wild guess: does your game run very slow on the PC? If so, that might indicate that no OpenGL drivers are installed. You can check that by looking at Data\output_log.txt file after running the game, first few lines will contain OpenGL driver information. If it’s “GDI Generic” by Microsoft, then you need to install proper display drivers. No OpenGL drivers also mean that some of texture combiner modes are not supported, thus everything can turn twice too dark.
I don’t see “clamps” in the images - where are they?
Do you want to use “pixel perfect” textures, or you don’t? If you’re using pixel perfect ones, then you “anchor” them somewhere on the screen with transform’s position, and then use pixel insets to position&size it in pixels. What would you like to be changed?
Aras and Yoggy - thanks very much for your good advice.
Ive solved the clamping issue - it was a PEBCAK (Problem exists between keyboard and chair) - I was mistaken in my use of Pixel Inset and border functions~
IMHO i think 3 simple things would help a lot with GUI layout and design
Using Top/Left/width/height (or optionally TopLeft, Bottom Right) screen coords for sizing and positioning 2d elements - its pretty much the default standard in most other 3d engines ive used (calculating the Pixel Inset values every time you move a 2d frame is really time consuming when you have 30 or more buttons etc)
a simple click-and drag option (with keyboard nudging) for visual positioning of 2d elements.
Auto inheritance of parent properties (i.e. if i hide a “form” then all child “buttons” and “textboxes” should dissapear.
re OpenGL - I will have to check that - is there any way to programmatically check for degraded OpenGL drivers and warn the user?
Aras - by default does Unity send DXT5’s to OpenGL or RGBA32
There are deviceName, deviceVendor and deviceVersion variables in Graphics class. So the proper check would be something like: if deviceVersion starts with “OpenGL” and deviceName is “GDI Generic” and deviceVendor is “Microsoft Corporation” then no drivers are installed.
If your texture format is DXT5 (set in texture’s Import Settings; it’s the default for textures with alpha channel) and the hardware supports DXT textures, it it sent compressed. If the hardware does not support DXT, it is decompressed into RGBA32 and sent. Decompression is in our code, and it surely does not result in darker images.
I’ll chime in with support for these ideas. For the first two I end up with little scraps of paper, jotting down dimensions to hand craft GUIs. For the third I ended up building complex scripts that chain together multiple GUI elements so I could fade them in and out in unison. (Inheritence of transparency and active state would be incredibly helpful here.)
Also, if you’re willing to share your experiences, Shaun, I’d love to see how CMUNE progresses.
Hi Tom - ive been doing the same thing - a notebook full of co-ordinates and an oldskool calculator.
I’m more than happy to share any development progress on CMUNE.
Im reasonably new to Unity - but I am pretty experienced in Virtools - so i hope i can bring something useful.
As for GUI development - my software is pretty heavy on forms for user input. Im considering some standard methodology for Form State, Show/Hide, Tab control, textbox enable/disable etc - would love to know how you’re handling these issues.
Ive also hit an problem whereby my textboxes are a fixed width, but im using a non-fixed width font (such as Myriad) - thus i cant determine how to limit the number of characters a user can input. Also the TAB key is giving me headaches - have you run into these problems?
I think theoretically you shouldn’t have to tell Unity to update. (I don’t think there’s a way to do that, anyways.) If you move a GUIText it’ll update, but not if you move a GUITexture. That suggests a bug, but before I found this out about GUIText I posted this thread:
The general strategy I use is to have controllers that handle “stuff.” So I might have a number of buttons or text areas linked to a single controller via a public array variable in the controller. It’s then the controller’s job to catch all the input and dispatch it appropriately. Sometimes this is straightforward, sometimes it’s tedious.
Limiting the number of characters has been a matter of checking text.Length before appending new characters. (I have so far avoided the problems with variable width fonts, line wrapping, and potential pixel overruns. At some point I will have to bite the bullet on this one, though.) For the tab character I’m just looking for “\t” (Input.inputString) or “tab” (Input.GetKeyDown(“tab”)) in the input string and handling it as a special case.
Tom - thanks for that. Ive got a great tabbing system working between my textboxes. I basically assign a TABID to each box and have a global var for TABCount that i change based on which form is open.
I also have default values (like “enter text here”) in the textboxes and when they are clicked on or tabbed to, they automatically clear (and the password boxes use XXX when you type in them)
I will post some code once i figure out a good text wrapping method for variable width fonts, system caret display and how to make scrollable text/image boxes.
Like have the text scroll up and down? The only way I can think of is to keep an array of the lines as separate strings and change them on the GUIText depending on the scroll status.