View Issue Details

IDProjectCategoryView StatusLast Update
0001403NoesisGUIUnitypublic2019-04-05 12:24
ReporterKhonan Assigned Tosfernandez  
PrioritynormalSeveritymajor 
Status resolvedResolutionno change required 
Product Version2.1.0f1 
Summary0001403: Setting a fontfamily constant in a style makes unity Crash (fixed, not a bug)
Description

Setting a fontfamily constant in a style makes unity Crash
Using unity 2018.3.3f1

Steps To Reproduce

1/ Get NocturnalStyle.xaml
2/ Add this line on top of the style :

<FontFamily  x:Key="DefaultFontFamily">Fonts/#Roboto</FontFamily>

3/ use the style in your code :
ResourceDictionary style = (ResourceDictionary)LoadXaml("NocturnalStyle");
Noesis.GUI.SetApplicationResources(style);

4/ Run unity project
5/ Unity crashes

Attached Files
MainWindow.xaml (1,342 bytes)   
<UserControl x:Class="Atome2.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    xmlns:local="clr-namespace:Atome2"
    Background="#FF1A1A1D" Height="125" d:DesignWidth="1000" VerticalAlignment="Top">

    <Grid Height="Auto" HorizontalAlignment="Stretch">
        <StackPanel Orientation="Vertical">
            <Menu>
                <MenuItem Header="File">
                    <MenuItem Header="Load"></MenuItem>
                </MenuItem>
            </Menu>
            <TabControl>
            <TabItem Header="View 3D">
                <Button x:Name="itButtonTest" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Resources/Fonts/#Consolas" FontSize="12"  Margin="83.008,21.02,89.008,29" Height="49.98" Width="127.984">TEST BOUTON 1</Button>
            </TabItem>

            <TabItem Header="Settings">
                 
            </TabItem>
        </TabControl>
        </StackPanel>
        <!-- 
        <Image Source="Resources/Images/Home.png" Margin="-328.5,-1.5,328.5,1.5"></Image>
        -->
    </Grid>
</UserControl>
MainWindow.xaml (1,342 bytes)   
MainWindow.xaml.cs (2,628 bytes)   
#if UNITY_5_3_OR_NEWER
#define NOESIS
using Noesis;
using System;
using System.Reflection;
using UnityEngine;
#else
using System;
using System.Windows;
using System.Windows.Controls;
#endif


namespace Atome2
{

    /// <summary>
    /// Interaction logic for MainUserControl.xaml
    /// </summary>
    public partial class MainWindow : UserControl
    {
        public MainWindow()
        {
            InitializeComponent();
        }


#if NOESIS
        private void InitializeComponent()
        {
            //ResourceDictionary style = (ResourceDictionary)Noesis.GUI.LoadXaml("Assets/Code/XAML/AgileStyle.xaml");
            //ResourceDictionary style = (ResourceDictionary)Noesis.GUI.LoadXaml("Assets/Code/XAML/WindowsStyle.xaml");
            //ResourceDictionary style = (ResourceDictionary)Noesis.GUI.LoadXaml("Assets/Code/XAML/NocturnalStyle.xaml");
            //ResourceDictionary style = (ResourceDictionary)Noesis.GUI.LoadXaml("Assets/Code/XAML/Atome2Style.xaml");
            //ResourceDictionary style = (ResourceDictionary)LoadXaml("Atome2Style"); 
            ResourceDictionary style = (ResourceDictionary)LoadXaml("NocturnalStyle");
            Noesis.GUI.SetApplicationResources(style);
            Noesis.GUI.LoadComponent(this, "Assets/Code/XAML/MainWindow");

            Button itButtonTest = (Button) this.FindName("itButtonTest"); // Convert.ChangeType(ItemToCast, Type.GetType(stringNameOfType)))
            itButtonTest.Click += itButtonTest_Click;
        }

        object LoadXaml(string xaml) 
        {
#if NOESIS
            NoesisXaml xamlUnity = (NoesisXaml)UnityEngine.Resources.Load(xaml, typeof(NoesisXaml));
            return xamlUnity.Load();
#else
            string path = "/ControlGallery;component/Assets/NoesisGUI/Samples/ControlGallery/Resources/" + xaml + ".xaml";
            return Application.LoadComponent(new Uri(path, UriKind.RelativeOrAbsolute));
#endif
        }
         
        private void itButtonTest_Click(object sender, RoutedEventArgs e)
        {
            System.Console.WriteLine("Button was clicked");
        }


        // Event Declared in XAML // https://www.noesisengine.com/docs/Gui.Core._UIElement.html#events
        protected override bool ConnectEvent(object source, string eventName, string handlerName)
        {
            if (eventName == "Click" && handlerName == "itButtonTest")
            {
                ((Button)source).Click += this.itButtonTest_Click;
                return true;
            }
            return false;
        }

#endif
    }
}
MainWindow.xaml.cs (2,628 bytes)   
NocturnalStyle.xaml (295,596 bytes)
PlatformWindows

Activities

Khonan

Khonan

2019-01-30 15:22

reporter   ~0005430

After some investigations, I discovered all my troubles came from my inits not behing done during
OnInitialized(object sender, EventArgs args) ....

Causing random crash of unity..

Bug closed :)

Issue History

Date Modified Username Field Change
2019-01-30 12:12 Khonan New Issue
2019-01-30 12:12 Khonan File Added: MainWindow.xaml
2019-01-30 12:12 Khonan File Added: MainWindow.xaml.cs
2019-01-30 12:12 Khonan File Added: NocturnalStyle.xaml
2019-01-30 12:29 Khonan Description Updated
2019-01-30 12:29 Khonan Steps to Reproduce Updated
2019-01-30 15:22 Khonan Note Added: 0005430
2019-01-30 15:23 Khonan Summary Setting a fontfamily constant in a style makes unity Crash => Setting a fontfamily constant in a style makes unity Crash (fixed, not a bug)
2019-03-18 22:27 sfernandez Assigned To => sfernandez
2019-03-18 22:27 sfernandez Status new => assigned
2019-03-18 22:27 sfernandez Target Version => 2.2.1
2019-04-05 12:24 sfernandez Status assigned => resolved
2019-04-05 12:24 sfernandez Resolution open => no change required
2019-04-05 12:24 sfernandez Target Version 2.2.1 =>
2025-10-10 13:29 jsantos Category Unity3D => Unity