locked
Loading custom page first in Unity3d

    Question

  • im also working in something like this : 

    mainPage.xaml content the unity scripts 

    BasicPage.xaml content button

    it's not a probleme to show unity's splash screen .. my probleme is to load the BasicPage.xaml before unity loads , and when the button is clicked , the mainPages.xaml loads
    ..
    i'h tried to load the basicpage with this code in app.xaml.cs :

    protected override void OnLaunched(LaunchActivatedEventArgs args)
    {
                
                var mainPage = new BasicPage();
    Window.Current.Content = mainPage;
    Window.Current.Activate();
                
    }

    and is the button void : 

    private void Button_Click(object sender, RoutedEventArgs a)
            {
                
                this.Frame.Navigate(typeof(MainPage));
            }


    it's return a NULLEXCEPTION At this line  this.Frame.Navigate(typeof(MainPage));


    Thursday, January 29, 2015 5:45 PM

All replies

  • hi :)

    im working on a project in unity3d , and i build a solution to windows app store , that i opened it using visual studio community , then when i run it , automaticly the first page is the page of the game ..

    i want to add a new page with a button , and when i click it navigate to the page that content the game ..

    im stuck , i need help 
    Thursday, January 29, 2015 4:34 PM
  • You can only call Frame.Navigate if you have a frame to navigate. In your case your root Window (Window.Current.Content) is the page. You should be able to mimic navigation by setting the Window content to your new page.

    You might also consider implementing the app's start screen in Unity with a separate scene.

    Thursday, January 29, 2015 6:04 PM
    Owner
  • i hv set the window.Curent.content = newpage;
    olse i set the code of the button to this.Frame.Navigate(typeof(MainPage));

    there is an NULLexception if u want , i can send u my code ..
    Thursday, January 29, 2015 7:00 PM
  • You don't have a Frame so you can't call Frame.Navigate
    Thursday, January 29, 2015 7:04 PM
    Owner
  • Okey , but it only load the main page (dark screen) without any content of it....

    here's some of my code : 

    stackoverflow.com/questions/28220964/adding-custom-xaml-to-unity-project

    • Edited by Aymen Tlili Saturday, January 31, 2015 9:58 PM
    Saturday, January 31, 2015 9:32 PM