I decided to make this thread after I stumbled upon Riolis’ window script. Please contribute any scripts that you think are useful when working with 4.6 UI. Also, don’t forget about the cool scripts included in the UI Example Project, but I won’t be listing them here.
UIWindowBase by Riolis - create draggable windows in 1 click - just drag this script to a panel with your window. Approved by Tim C
ReturnKeyTriggersButton - if put on an input field, makes pressing a Return key highlight and trigger a specified button. The highlight is optional.
TabNavigation - a temporary solution to Tab key currently not triggering the navigation to the next element. Should be placed on a persistent object in the scene, will trigger on all GUI elements. Works with “Select On Down” and all navigation types. By me, as is the previous script.
RayCastMask by senritsu - a must if you want to create a round button or a button of any other shape that’s not rect. Change the button sprite texture to Advanced and check “Read/Write Enabled”, then just add this script to your button.
ComboBox by jbooth - creates selection/dropdown lists for you! Especially useful since 4.6 won’t have selection lists at the time of the release. Much like the official controls, it can be styled without any coding. I took the liberty to put the files in a .unitypackage for those who prefer it this way. Screenshot | Forum thread
uGUITools by Senshi - after you’ve resized a GUI element, positioning anchors to corners precisely can be difficult. With this script you can automatically position them from the menu or by pressing ctrl + [ , and do the reverse (corners to anchors) with ctrl + ] . Place the script in the Editor folder.
NicerOutline and BestFitOutline by me - a modified version of built-in Outline effect, but with a radius that scales along with Best Fit. Just use in place of the default outline, the radius that you set will be applied to the max font size, it will scale down from it when a smaller font is used. Screenshot NicerOutline also fixes the “holes” that Outline sometimes has - screenshot
Are Editor scripts allowed on the list? I had an annoyance in that, after positioning a UI element, I couldn’t easily/ nicely/ precisely move the anchors to the element’s corners. To that end I created a simple Editor script that adds a uGUI menubar item, with “Anchors to Corners” mapped to cmd+[ and “Corners to Anchors” mapped to cmd+]. Perhaps someone else will find this useful as well!
So the images live in the DefaultResourcesExtra package. What this means is that they only get included in a build if they are referenced by a scene / prefab that is included in the build. So if you want them included include them in some scene and then include that scene in the build… even if it is never used.
Is there a way to load/retrieve them while within the editor? Or a way to instantiate the default properties for scripts.
Creating a button currently involves a prefab or assigning a texture before hand. Creating custom controls would be easier to share / create if the workflow for adding them to the UI is the same.
What I / we need is a way for the rightclick on gameobject in hierarchy, add UI / CustomControl to work identical to say UI / Button, where it populates the field with initial values. It’s fine if we have to include some Editor only code here, it’s just so that we can share a script instead of a whole package that just works out of the box without needing to assign some base textures manually.
As an attribute this would rock
[DefaultSprite(“Button”)]
public Sprite image;
Just wanted to say thanks to Senshi for this awesome “anchors to corners” solution. It allows to position anchors for stretching even when the parent rect is smaller than the child rect - totally impossible by default unless i missed something.
This results in anchor values that are < 0 and >1 and they don’t display correctly but they seem to work so far, nice!
Ha, I found out about that unintended side-effect after posting as well! I was originally going to fix it as it doesn’t seem very stable/ sustainable, but I hadn’t gotten around to it yet. It also seems to save and load just fine, so… magic? Anyway, thanks for the thanks! =)
Finally i decided to finish project with interactable text. check lighting scene in package and last sentence on screen. this is very little presentation but there is too late for more. maybe later i will add more explanation. I hope this is bug free (i bug hunted a lot) but i think it still could be optimized (i made some already but not 100%). If anyone need extends or optimize this i added some comment to code but this isnt very professional.
maybe i will improve this but as Pro (paid version)
NOTE: this not support fade-in/out like button and animation nor spriteswap (sprite of course isnt supported for text while animation will be added later if it is possible but probably as Pro)
Just tested your package and it works great, thanks for sharing this with the community. With this, everyone can start making WoW-style chat links, and ingame encyclopedias.
Here’s a modified Outline script, its radius scales along with Best Fit font scale. By default, when outlined text gets scaled down, its outline radius remains the same, and can look too bold, this fixes it.