Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

XAML controls and inheritance exception

Discussion in 'Windows' started by bdovaz, Nov 25, 2018.

  1. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,042
    Hi @Tautvydas-Zilys

    I'm creating a native dialog and I have a problem.

    If you put this script on a Button and run the example you will see that it will work for the first dialog but it will crash with a exception on the second one. The only difference is that the second one in a subclass on a XAML control.

    It's a Unity bug? It works on a native UWP application of course.

    Configuration:

    Unity 2018.2.15f1
    IL2CPP
    XAML
    .NET Standard 2.0

    Exception:

    Code:

    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.EventSystems;
    6. #if !UNITY_EDITOR && UNITY_WSA
    7. using Windows.UI.Xaml;
    8. using Windows.UI.Xaml.Controls;
    9. using Windows.UI.Xaml.Controls.Primitives;
    10. using Windows.UI.Xaml.Input;
    11. using Windows.UI.Xaml.Media;
    12. using Windows.UI.Xaml.Shapes;
    13. #endif
    14.  
    15. public class Test : MonoBehaviour, IPointerClickHandler {
    16.  
    17. #if !UNITY_EDITOR && UNITY_WSA
    18.         public class ContentDialogTwo : ContentDialog { }
    19. #endif
    20.  
    21.     public void OnPointerClick(PointerEventData eventData) {
    22. #if !UNITY_EDITOR && UNITY_WSA
    23.         string title = "My title";
    24.         string message = "My message";
    25.         string positiveButton = "My positive button";
    26.  
    27.         UnityEngine.WSA.Application.InvokeOnUIThread(async () => {
    28.             ContentDialog d0 = new ContentDialog {
    29.                 Title = title,
    30.                 Content = message,
    31.                 CloseButtonText = positiveButton
    32.             };
    33.  
    34.             ContentDialogResult result = await d0.ShowAsync();
    35.  
    36.             Debug.Log(result);
    37.  
    38.             ContentDialog d1 = new ContentDialogTwo {
    39.                 Title = title,
    40.                 Content = message,
    41.                 CloseButtonText = positiveButton
    42.             };
    43.  
    44.             result = await d1.ShowAsync();
    45.  
    46.             Debug.Log(result);
    47.         }, false);
    48. #endif
    49.     }
    50.  
    51. }
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    What exactly throws? What's the message for that exception? I can't really tell what's going wrong just by looking at the code.
     
  3. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,042
    If you want I can create a repro project but I think that it's not necessary because you only need that snippet to replicate the bug:
    1. Create a Button.
    2. Add that script to the button.

    It has to do with inheriting that component in a subclass.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    It indeed looks like a bug in IL2CPP. Can we get a bug report on this?
     
  5. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,042
    @Tautvydas-Zilys Case 1104540
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Thanks, we'll take a look.
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Hi, the fix for this issue landed to Unity 2019.2.0a2, 2019.1.0b1, 2018.3.6f1 and 2017.4.19f1.
     
  8. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,042