A "Create UI Button" editor script [Obsolete]

This is the place to post add-on scripts you have written that use EZ GUI. Please remember only to post your add-on content and not the original EZ GUI scripts.
Forum rules
Only post your own add-on content and not any of the original EZ GUI scripts.

Re: A "Create UI Button" editor script

Postby ibyte » Sun Oct 10, 2010 11:42 pm

Little Angel,

your script seems to be working for me now after I changed the refernces from .text to .Text. I also did as Brady suggested and added a UIManger to my scene and set the default font.

And even having done that the script still wasn't working until I unloaded Unity and reloaded it again.

When I tried it the first time - I put a break point in the class that creates the SpriteText and was surpised it worked ... so I stopped unity via Mondevelop and fired it up on it''s own and it still worked, so it must have been just restarting Unity that did it.
ibyte
 
Posts: 258
Joined: Tue Sep 07, 2010 8:23 pm

Re: A "Create UI Button" editor script

Postby Little Angel » Mon Oct 11, 2010 12:25 am

I've posted the most recent code (with .Text) and some other pops and giggles on the main page.

That should be it for a while.

It seems to be working. It creates new UIButtons, it Parents these new UIButtons if you want to, it edits bits of existing UIButtons.

Let me know what you'd like to see this script do, but like anything, the more complex it gets, the less stable it is... I'm already worried about creating AND editing UIButtons in this script without screwing up someone's project...
Little Angel
 
Posts: 772
Joined: Thu Sep 02, 2010 10:23 pm

Re: A "Create UI Button" editor script

Postby Little Angel » Mon Oct 11, 2010 12:29 am

I figured out how to get the texture back from thisButton.State[s], so I'll post a new version tomorrow that shows and can edit button textures.
Little Angel
 
Posts: 772
Joined: Thu Sep 02, 2010 10:23 pm

Re: A "Create UI Button" editor script

Postby Brady » Mon Oct 11, 2010 2:02 am

BTW, sorry for the potential confusion with .text versus .Text, but unfortunately it is necessary to make it work in the inspector. I could work around it with a custom inspector, but then it would break all Unity iPhone 1.7 support. So until Unity 3.0 gets some time behind it and use of Unity iPhone 1.7 drops off, I'll have to continue to support it, and that means keeping some of these awkward conventions around.
Brady
 
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: A "Create UI Button" editor script

Postby Little Angel » Mon Oct 11, 2010 11:18 am

Brady: NP re: .text vs .Text. I thought I was using .Text but was not really paying attention when it was in front of me.

I've posted a NEW VERSION where the wizard can be updated with the current textures assigned to a button, along with some other minor changes and simplifications (mostly internal).

(See the first post for the most recent version of the code...)

PS: I've included a Unity Package of the scripts I'm currently updating - so you don't need to copy and paste the code anymore. You'll find it at the top of the main page.

-

Things I'm working on:

- Assigning the Sprite Material to the UIButton.
Currently this is imperfect. When I poll an existing button for it's material, it seems to force the material to become an instance, which worries me. I have yet to find an elegant way for the editor script to keep track of a persistent material, eg: the main SpriteMaterial being used by the main SpriteAtlas, or keep an array of all potential materials to choose from... we'll see what works out best.

- Looking at the size of the Original Graphic and assigning Height & Width to match.
Currently just a wishful thinking... Still looking to see if this is even possible.
Little Angel
 
Posts: 772
Joined: Thu Sep 02, 2010 10:23 pm

Re: A "Create UI Button" editor script

Postby Little Angel » Tue Oct 12, 2010 9:16 am

Updated Code (1.02) (Check the first post for the package.)

This includes assigning or updating materials to new and existing buttons.

To prevent null values (missing materials in the materials variable) from over-writing and deleting existing sprite materials, there is a check box "Update Sprite Material" that must be checked before the sprite material is assigned or updated.

With hope this will change when I can successfully poll the existing UIButton for it's sprite material without getting an instance of it. Easy I'm sure, but I've not looked into it yet.
Little Angel
 
Posts: 772
Joined: Thu Sep 02, 2010 10:23 pm

Re: A "Create UI Button" editor script

Postby GC_Cryss » Tue Oct 12, 2010 8:32 pm

Is this script package Unity3 only?

I tried importing it into 2.61, and I'm getting some funky errors...

Code: Select all
Assets/Editor/CustomItems/CreateUIButton.cs(31,26): error CS0308: The non-generic method `DisplayWizard' cannot be used with type arguments
Assets/Editor/CustomItems/MakeGUIImage.js(9,31): BCE0019: 'textureType' is not a member of 'UnityEditor.TextureImporter'.
Assets/Editor/CustomItems/MakeGUIImage.js(9,45): BCE0005: Unknown identifier: 'TextureImporterType'.
Assets/Editor/CustomItems/MakeGUIImage.js(28,31): BCE0019: 'lightmap' is not a member of 'UnityEditor.TextureImporter'.
GC_Cryss
 
Posts: 26
Joined: Mon Sep 13, 2010 5:10 pm

Re: A "Create UI Button" editor script

Postby Little Angel » Tue Oct 12, 2010 10:11 pm

Hummmm....

Good point!

I'd not really planned on any particular target platform, but I am on 3.0 and I'm coding them to solve some particular problems I have, and I seem to have coded it in a way that will only work in 3.0!

Oh dear.

Things like the errors in MakeGUIImage are because of the new 3.0 texture importer details. I believe this could be an easy edit with the 2.6 docs open. Look at the UntiyEditor.TextureImporter properties and adjust them to match the 2.6 set of properties...

The DisplayWizard not working would need a little more work if the base Method is different. You'd have to track down the difference in the arguments and see if they can be adjusted.

I don't really have time to make it back compatible right now, but if you want to take a swipe at it, I'll help out by shouting from the engine room.

-

I'm just perfecting a batch button creator where you can select as many texture2d's as you want and make them into basic buttons AND auto save them as prefabs, with the choice of deleting the button if you only want a palette of prefabs saved for later copying.
Little Angel
 
Posts: 772
Joined: Thu Sep 02, 2010 10:23 pm

Re: A "Create UI Button" editor script

Postby GC_Cryss » Wed Oct 13, 2010 12:07 am

Cool. I'll give it a toss when I'm done fixing my Slider bars. I went from upgrade EZGui 1.05b3 to b4, and it bailed; I lost my slider knobs and all functionality. I'll see if the new b5 fixes it.
GC_Cryss
 
Posts: 26
Joined: Mon Sep 13, 2010 5:10 pm

Re: A "Create UI Button" editor script

Postby Little Angel » Wed Oct 13, 2010 12:30 am

I trust b5 will do the trick!

I've posted a new version of this in a new thread, combining all of the scripts, and one new one here:
viewtopic.php?f=9&t=242

Updates and changes:
1.03:
This wizard now reads the Sprite Material from the existing button and sets this properly as the Sprite Material variable. With less risk of accidentally over-writing or erasing the existing Sprite Material, the "Update Sprite Material" button has been removed.

This wizard will optionally use the height and width of the "Main Texture" to set the height and width of the UIButton if "Set Size From Texture" is checked.
Little Angel
 
Posts: 772
Joined: Thu Sep 02, 2010 10:23 pm

PreviousNext

Return to EZ GUI Add-ons

Who is online

Users browsing this forum: No registered users and 6 guests

cron