Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

Problem when using more classes in Hololens Emulator

Hi guys,
I have 2 classes (communication_final and backup) in my application. When I try to set a bool variable in the backup class from the communication_final class, it didn't work. Does the hololens emulator supports the usage of more classes and should it be possible to set a variable in another class? Does this work on hololens?

Thanks,
Chris

Answers

  • Options

    Could you please post your code on the bool variable and changing it?

  • Options

    Hi,

    Backup is my second class.

    Backup.comm_displayed = true;

    The funny thing is that the code works in the unity editor and also when I build a app for the desktop, only in the hololens emulator this didn't work.

  • Options

    @ChristophMarko I think what Shayne was referring to was you need to post the whole method containing where you change the variable not just a single line where you call something true. There could be a number of different things that could go wrong causing something like your variable not to be true.

    In order for someone to be able to help you out you need to show everywhere in your script that you reference your class and the variable.

    AR Developer

  • Options

    @dbarrett here are my 2 classes:

    Communication_v3.cs (only a extract)

    using System;
    using System.IO;
    using System.Linq;
    using System.Collections;
    using System.Runtime;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    using System.Diagnostics;
    using System.Collections.ObjectModel;
    using test_neu;

    if !UNITY_EDITOR

    using Windows.Networking.Sockets;
    using Windows.Networking;
    using Windows.Networking.Connectivity;
    using Windows.Devices.Bluetooth;
    using Windows.Devices.Bluetooth.GenericAttributeProfile;
    using Windows.Devices.Enumeration;
    using Windows.Storage.Streams;
    using test;
    using Windows.UI.Core;
    using System.Threading.Tasks;
    using backup_scene;

    endif

    namespace comm_final
    {

    public class Communication_v3 : MonoBehaviour
    {
    
    
        public Dropdown comm;
        public Dropdown comm_type;
        public Button Start_Stop_Conn;
        public Button Setup_Conn;
        public Dropdown BLE_ScanResults;
        public Button Scan_BLE_Button;
    
    
        public static bool udp_client_active;   //status of the active communications sessions
        public static bool udp_server_active;
        public static bool tcp_client_active;
        public static bool tcp_server_active;
        public static bool ble_client_active;
        public static bool ble_server_active;
    
        public string UDP_ClientIP;
        public string UDP_ClientPort;
        public string UDP_ServerPort;
    
    
        public static string IP_address;
        public static string UDP_Client_Port;
        public static string UDP_Server_Port;
    
        public Text connect_status;
        public RawImage comm_status;        //data for the dynamic connection symbols
        private Texture2D myTexture_comm;
    
    
        // Will be called everytime, when the scene will be reloaded
        void Start()
        {
    
            comm.gameObject.SetActive(false);
            comm_type.gameObject.SetActive(false);
            Start_Stop_Conn.gameObject.SetActive(false);
            Setup_Conn.gameObject.SetActive(true);
            comm_status.gameObject.SetActive(false);
            connect_status.GetComponentInChildren<Text>().text = "Connection status: No communication selected";
            BLE_ScanResults.gameObject.SetActive(false);
            Scan_BLE_Button.gameObject.SetActive(false);
    
    
            if (backup_scene.Backup.scene_first_time)
            {
    
                connect_status.gameObject.SetActive(true);
    
                backup_scene.Backup.scene_first_time = false;
    
            }
    

    }
    }
    }
    }

    and here is the backup file where the variables are located:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using System.Collections.ObjectModel;

    if !UNITY_EDITOR

    using Windows.Networking.Sockets;
    using Windows.Networking;
    using Windows.Networking.Connectivity;
    using Windows.Devices.Bluetooth;
    using Windows.Devices.Bluetooth.GenericAttributeProfile;
    using Windows.Devices.Enumeration;
    using Windows.Storage.Streams;
    using test;
    using test_neu;
    using comm_final;
    using Windows.UI.Core;
    using System.Threading.Tasks;

    endif

    namespace backup_scene
    {
    public class Backup
    {
    public static bool scene_first_time = true;
    public static bool udp_selected;
    public static bool tcp_selected;
    public static bool ble_selected;
    public static bool comm_displayed;

        public static bool udp_client_selected;
        public static bool udp_server_selected;
        public static bool tcp_client_selected;
        public static bool tcp_server_selected;
        public static bool ble_client_selected;
        public static bool ble_server_selected;
    
        public static bool udp_client_active;   //status of the active communications sessions
        public static bool udp_server_active;
        public static bool tcp_client_active;
        public static bool tcp_server_active;
        public static bool ble_client_active;
        public static bool ble_server_active;
        public static bool ble_devices_found;
    
        public static string IP_address;
        public static string Client_Port;
        public static string Server_Port;
    

    }
    }

  • Options

    Call me blind but, I don't see anywhere in this code where you say:

    Backup.comm_displayed = true;

    I'd also assume you have all of your required permissions set under the Player Settings?

    AR Developer

  • Options

    @dbarret: I'm sry I copied only a part of the source code and the mentioned part was in the other part. I set all the needed capabilites and when I run it as a Desktop app the program works, only it doesn't work with the emulator and the hololens.

  • Options

    @dbarrett: The start function in my communication_v3 class compares if a value of the backup class is set and afterwards sets a gameobject active and show a text in a textfield but this wouldn't work on the emulator and on the hololens.

  • Options
    Hey guys,
    I solved the problem I forgot to instantiate the needed class to create an object. ;)
Sign In or Register to comment.