Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

[SOLVED]Can't connect between Unity and XAML

Discussion in 'Windows' started by Looking4Game, May 13, 2015.

  1. Looking4Game

    Looking4Game

    Joined:
    Aug 21, 2013
    Posts:
    16
    Hi,
    - My PC is running Windows 8.1 and Unity3D 5.0.1
    - I download example from http://docs.unity3d.com/uploads/Main/XAMLUnityConnection.zip
    - I build Windows Store -> Phone 8.1
    - When I run the example under Device->Debug mode of Visual Studio 2013, I got error at
    UnityEngine.GameObject go = UnityEngine.GameObject.Find("Cube"); //line 160, MainPage.xaml.cs

    Output windows show:
    Anybody know about this issue?
     
    Last edited: May 13, 2015
  2. Looking4Game

    Looking4Game

    Joined:
    Aug 21, 2013
    Posts:
    16
    I just switched Unity3d back to version 4.6.1. Now I can pass the connection. It means: UnityEngine.Object.FindObjectOfType and UnityEngine.GameObject.Find functions in XAML file work well. I didn't get error as described above anymore.

    Any Unity Technologies or some one know about this? I want to use new features of Unity 5.x. :|
    Thank
     
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,664
    Is this the most recent unmodified example? In such case please report a bug.

    You certainly should be able to connect XAML with Unity, just you need to be careful with calling things from correct thread.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,526
    Hi,

    I believe that's a documentation bug. Wrap the function in this - it should solve it:

    Code (csharp):
    1. AppCallbacks.InvokeOnAppThread(() =>
    2. {
    3. });
     
  5. Looking4Game

    Looking4Game

    Joined:
    Aug 21, 2013
    Posts:
    16
    Hi, Thank for reply.
    This example is newest example about connect XAML with Unity from Unity Document site. Seem Unity need to update it.
    After digging info from Google. Now I can connect XAML with Unity by using: static class or App Callback. With static class, I don't need to call FindObject from Unity Engine anymore.

    Thank.