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

Skyblue Screen in Between Scenes #65

Closed stanleyjoy closed 11 years ago

stanleyjoy commented 11 years ago

I have skyblue screens during the load between scenes and at the start of the game. I found this when I tried to debug the game on my Lumia 610. Any reason why this is happening and also a solution will be grateful. Stan

fehaar commented 11 years ago

I think you should take a look in the Game1.cs file. In Draw there will probably be a call that clears the screen to the default XNA SkyBlue color. Just change that.

stanleyjoy commented 11 years ago

Even though we have to clear the graphics device with some sort of color.

fehaar commented 11 years ago

The clear from XNA will only show when you have no cameras active in unity. That usually happens when loading as the cameras in the scene get destroyed if they have not had DontDestroyOnLoad called on them. I think Unity clears to black when that happens in the unity player.

stanleyjoy commented 11 years ago

This will clear the problem between loading scenes. What about when the game first starts???

stanleyjoy commented 11 years ago

I have added a DontDestroyOnLoad to the Camera gameObject yet I get the clear screen issue. Stan

fehaar commented 11 years ago

When the game first starts. Before any scenes are loaded. You can only control the screen directly in XNA. Typically you would do that in Game1.cs.

I am surprised that it doesn't work with DontDestoyOnLoad. There must be an issue with the rendering code. Then you will have to control it in Game1.cs as well.

stanleyjoy commented 11 years ago

I have loading text in the spritebatch.draw but its useless in the beginning of the game so I wanted to use the splash screen in the beginning of the game and during loading different scenes I want to bring a loading page. Can I access the Texture2D from my Unity Script. If so how???

fehaar commented 11 years ago

You have access to your Unity scripts directly in XNA in Visual studio, so it is easy to add logic there. If you need to make code in your Unity scripts that run only in XNA - you must use conditional compilation in the script, otherwise it will fail compilation in Unity. See the Scripting wiki page for more info: https://github.com/fehaar/FFWD/wiki/Scripting.

stanleyjoy commented 11 years ago

Well I am not able to access the Game1.cs (FFWD.Template.WP7) from levelChange.cs(FFWD.Template.Scripts)

fehaar commented 11 years ago

You can do it the other way around though, and just pass a delegate from Game1 to levelChange that it can call back on.

stanleyjoy commented 11 years ago

I created a delegate in Game1.cs but how do I create a object reference for Game1.cs in my Unity C# Script. Its spitting out Missing Assembly reference. Please bear with me on this. Stan

fehaar commented 11 years ago

Do it the other way around. Here is a very simple example using the built in Action delegate. You can also use your own delegate or even an event.

In your Unity script:

public class SomeUnityScript : MonoBehaviour {
    public static Action callToClass1

    public void Update() {
       if (someConditionIsMet && (callToClass1 != null))
       {
           callToClass1();
       }
    } 

}

In Game1:

public class Game1 {
   public void Initialize() {
           SomeUnityScript.callToClass1 = Callback;

   } 

   public void Callback() {
     // This will be called from your script.

   }
}
stanleyjoy commented 11 years ago

Ok dude thanks for the help. First time using delegates thats why.. Stan