fehaar / FFWD

This is the FFWD framework for XNA, that allows you to port Unity3D games to XNA for use on WP7 or XBox360 (XBLIG)
Microsoft Public License
133 stars 36 forks source link

GUIStyle Overload Issue #45

Closed stanleyjoy closed 10 years ago

stanleyjoy commented 12 years ago

I wrote a script which makes use of Unity GUI.Button along with GUIStyle to provide mouse over and mouse click textures. I used the script below to make it happen

if (GUI.Button(new Rect(100, 400, 75, 75), "", CWBtn)) { model.gameObject.transform.localEulerAngles += new Vector3(0,RotationSpeed * Time.deltaTime,0); }

It worked in the Unity Editor as expected. However when I exported to XNA. I was greeted with this error "The best overloaded method match for 'PressPlay.FFWD.GUI.Button(PressPlay.FFWD.Rect, PressPlay.FFWD.Texture, PressPlay.FFWD.GUIStyle)' has some invalid arguments"

When I do what XNA wants me to do i.e. change the string to a texture2D. I am greeted by another error "XML element "fontSize" not found." When I checked this it is pointing me to the scene.xml

Is this an error on my part?? Stan

stanleyjoy commented 12 years ago

Update on the issue. Even declaration of a GUIStyle will be added to scene.xml which will result in the error as said above.

Stan

fehaar commented 12 years ago

It is probably just a missing override in FFWD. I will take a look at it.

Thomas Gravgaard Senior Software Developer Press Play ApS thomas@pressplay.dk +45 26 74 26 74

stanleyjoy commented 12 years ago

wondering how you guys did the UI for Tentacles??? Stan

fehaar commented 12 years ago

We did it purely in XNA using SpriteBatches and some custom code that was built upon a sample from the XNA site. Nothing in Unity at all.

fehaar commented 12 years ago

And for our current product we are using NGUI. An extension for Unity. The version we are using plays fine with FFWD with some small customizations in the scripts.

stanleyjoy commented 12 years ago

So you guys use this, was using EZGUI for a while. will check the demo. Stan

stanleyjoy commented 12 years ago

I tried to bring 2 buttons using NGUI into XNA. The buttons had no events or custom scripts attached. So they do nothing other than provide click and normal state yet the XNA throws errors in the scene.XML "There was an error while deserializing intermediate XML. Cannot find type "UISlicedSprite""

Thinking of doing the UI in XNA now. how did you change scenes in a game from XNA's C# do they respond to Application.LoadLevel(); if they were written in XNA.

fehaar commented 12 years ago

The error you get is because you don't have the NGUI scripts added in XNA. Remember to do a Script export and add the scripts manually in XNA.

Thomas Gravgaard Senior Software Developer Press Play ApS thomas@pressplay.dk +45 26 74 26 74

stanleyjoy commented 12 years ago

ok will check that out!!

stanleyjoy commented 12 years ago

I thought a full export will export all the assets?? Stan

//Update Got a bunch of assembly reference issues after exporting the scripts anything I did wrong?? -I pushed the NGUI folder to the scripts folder in my Unity Project. -Then did a full export and export all scripts. -Added the exported folder to XNA project, i.e., NGUI to template.scripts and NGUI Atlas to template.content and template.XML.content. -Build the product throws around 124 errors related to assembly reference.

Stan

fehaar commented 12 years ago

It will. But it will not include the scripts in the XNA project, it will only convert them and copy them to XNA.

Thomas Gravgaard Senior Software Developer Press Play ApS thomas@pressplay.dk +45 26 74 26 74

stanleyjoy commented 12 years ago

Got a bunch of assembly reference issues after exporting the scripts anything I did wrong?? -I pushed the NGUI folder to the scripts folder in my Unity Project. -Then did a full export and export all scripts. -Added the exported folder to XNA project, i.e., NGUI to template.scripts and NGUI Atlas to template.content and template.XML.content. -Build the product throws around 124 errors related to assembly reference.

stanleyjoy commented 12 years ago

I am trying to use XNA's spritebatch to draw my UI. The issue I am facing is that I am not able to draw the texture as PressPlay.FFWD is also using the same texture2D "Error 1 'Texture2D' is an ambiguous reference between 'Microsoft.Xna.Framework.Graphics.Texture2D' and 'PressPlay.FFWD.Texture2D' "

fehaar commented 12 years ago

Just use the full namespace for the class when you create it like this:

new Microsoft.Xna.Framework.Graphics.Texture2D(...);

stanleyjoy commented 12 years ago

Ya trying that but have to find a work around. Otherwise I will need to put the full namespace for a lot of things. Can you just give me a brief overview of how FFWD hierarchy works. Like game1.cs works first then what comes next????

stanleyjoy commented 12 years ago

Any thoughts on getting NGUI working for me!!! :D Stan

fehaar commented 12 years ago

Game1.cs load the FFWD Application up as a DrawableGameComponent. That will start the engine running. Then it will kick FFWD into gear by loading in a scene - just like Unity does by opening the base scene. After that all the Components on the GameObjects in the scene will take over and do their thing and things will progress like they do in Unity.

If you want to create your own GUI system that is not part of FFWD at all, the easiest way to do it is to make a DrawableGameComponent that can handle it and draw after the FFWD.Application has drawn, then it will draw on top of what your FFWD app has drawn. Then you can use standard XNA and not worry about the FFWD types at all. You can still interrogate FFWD to get some data about your game objects, but if you take that approach you should think about having game data kept in some way that is easier to get to than through FFWD (singleton classes or a data repository).

Regarding NGUI, the key to getting it working is to make sure that the Unity scripts have the right FFWD attributes applied. The attribute system in Unity (https://github.com/fehaar/FFWD/wiki/Scripting) was actually refined to get NGUI to work, as NGUI hides away a lot of properties for prying eyes.

When you do work with it, use the following operating mode: 1) Get the NGUI scripts into XNA and see them compile. 2) Make a simple Unity scene with a simple NGUI setup on it and export it. 3) Check the generated XML to see that NGUI components have the right data exported. Add FFWD attributes to the Unity scripts until they do. 4) Test the scene and see if it is working. If it fails, find out what data is missing. Repeat from 3.

As I said. We have gotten NGUI to work in XNA, so it is possible and FFWD should support most of what NGUI does. Of course there will probably be cases where that is not true. In that case report the specific issues and I will see what I can do to help.

I hope it gives you some ideas to get further. I am sorry that the built in GUI system is not up to snuff in FFWD yet, as this is a bit of a daunting task. At the moment I am extremely busy, so I haven't had much time to look at FFWD - but I will soon get back to it, and will see if I can make a test scene with the GUI parts and brush it up a bit so it is useful.

stanleyjoy commented 12 years ago

Ok my head of programming is asking me to try and push via NGUI. As any changes in terms of UI can be done in Unity rather than XNA. Hope you can guide me through. In step 3 you said check the generated XML. Are you talking about the XML that is created for the scene. Stan

stanleyjoy commented 12 years ago

Hello anyone there???

fehaar commented 12 years ago

Sorry Stan, I have missed out on the earlier comment. Yes. It is the scene XML I am talking about.

stanleyjoy commented 12 years ago

Ok will check it out

stanleyjoy commented 12 years ago

Thomas, you really need to incorporate the entire Unity GUI to work with FFWD and XNA. Rather than using plugins from Unity. This way atleast everyone knows where to look if they are blocked or cut-off. Stan

fehaar commented 12 years ago

True. But no-one I know use the GUI system for real production. And at the moment I don't even have time to work on the real missing pieces of FFWD. So it is a trade off.

stanleyjoy commented 12 years ago

You are right that no-one uses Unity3Ds GUI as its one draw call per button or text. However with FFWD and XNA we are able to make the UI with apparently no draw calls or the stats might be wrong. Stan

stanleyjoy commented 12 years ago

Have you tried to use plugins from Unity3D to XNA

fehaar commented 12 years ago

The GUI takes draw calls in XNA. But only up to two depending on what you draw. It is probably not counted the way it is now. It should be possible to draw everything made with GUI (when it gets done) in one draw call.

What plugins are you referring to?

stanleyjoy commented 12 years ago

lets say if I wanted to use iTween

fehaar commented 12 years ago

Ah. Yes. iTween is in use in Tentacles running on FFWD. So it works. I can't remember how much we had to change to get it working. but not a lot, as I recall. So I think it should be pretty easy to get running. As I said earlier in the thread, we have the NGUI package running on FFWD as well as some other pakcages, so it is entirely possible. The amount of work nessecary will vary from package to pakcage.

stanleyjoy commented 12 years ago

Since we strayed away from the main topic. Did you check GUIStyle Overload Issue??? Stan

fehaar commented 12 years ago

Not yet.

Thomas Gravgaard Senior Software Developer Press Play ApS thomas@pressplay.dk +45 26 74 26 74

stanleyjoy commented 12 years ago

Does FFWD export only from a folder called scripts for scripts or does it take the C# scripts found anywhere in the project???

Waiting for the new patch.... Stan

InitoryDad commented 12 years ago

Waiting for patch, too. I will test NGUI on FFWD, ;)

maconbot commented 10 years ago

I've found some good reasons to start paying with FFWD again...should I use the old version of ngui or the latest?

fehaar commented 10 years ago

I haven't tested it with any version later than a year ago. That is not the same as saying that it won't work though.