How to access scene elements through code

The title bears the gist of it, using C# is it possible to reference the elements in a scene within a method?

Something loosely like:

void UpdateTextElement()
{
// Get text element with name ‘testtext’ in scene structure

// Set text element’s containing text to “Hello World”
}

I have tried looking around for information regarding this but haven’t been able to find anything. If I haven’t looked hard enough, please point me in the right direction.

Hi @amesa,

Interface Assets do not have access to the UI elements in Composer, so in your case the “right way” of doing this is to

  • Raise an event from your C# code with the new text to set
  • In Composer, add a trigger that will call the “Set Text” action on your Text asset, using your event parameter as the value

Let me know if that makes sense :wink:

1 Like

I am trying to find where to retrieve the event’s parameter when calling:

if ((QueueNotEmpty != null) && (m_lstVideos.Count != 0))
{
QueueNotEmpty(this, m_lstVideos[0]);
}

Where in the IntuiFace UI can I get the reference to m_lstVideos[0] that was passed by the event?

You need to declare this parameter in the Intuiface Descriptor. This is actually a limitation of the “GenerateDescriptor” tool that doesn’t do this automatically, so you have to edit the ifd manually to add this property to your event.

Here is a syntax example

"events": {         
         "CodeScanned": {
             "id": "CodeScanned",
             "properties": {
                 "Message": {
                     "type": "string",
                     "title": "Code",
                     "description": "Code scanned"
                 }
             }
         }
      }

You can then access this in your Composer through a binding

I believe that I have implemented this correctly though I am not getting the right results. I have updated the code to:

// Get the amount of items in the list.
int amt = m_lstVideos.Count;

if (QueueUpdated != null)
{
// Fire the QueueUpdated event, passing the amt variable
// so that it can be evaluated in IntuiFace.
QueueUpdated(this, amt);
}

but when the trigger is fired (I have a visual representation that the trigger is indeed firing), it is supposed to set a text element to the amt variable that is passed through it. After editing the ifd file to include the amt as an integer parameter to the event and testing it in a handful of different ways I simply cant get the text element to update with the amt variable.

I have uploaded the IntuiFace experience and have shared it with xp-for-support@intuiface.com. The element in the red box should change every time every time either of the buttons are pressed, but they do not, and I am having a hard time tracking down the issue.

Hi @amesa,

To make sure you get the best and fastest support, can you please contact our support team here and just copy your last messages in the request? That’ll be easier to make a proper follow-up and diagnostic via through our open community forum :slight_smile:

Thanks

Seb

1 Like