TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Trigger a command from Unity

    Scheduled Pinned Locked Moved Instructions
    1 Posts 1 Posters 1.3k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • RussR Offline
      Russ
      last edited by Russ

      This is an example script you can put on any object in Unity, so now you can trigger commands in the games you build.

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      using UnityEngine.Networking;
      
      public class scr : MonoBehaviour
      {
          // Start is called before the first frame update
          void Start()
          {
              
          }
      
          // Update is called once per frame
          void Update()
          {
              if (Input.anyKeyDown)
              {
                  Debug.Log("A key or mouse click has been detected");
      
                  var trigger = "calculator";
                  var computer = "laptop";
                  var parameters = "";
                  var token = "(your token)";
                  StartCoroutine(TriggerCMD(trigger, computer, parameters, token));
              }
          }
      
          IEnumerator TriggerCMD(string trigger,string computer,string parameters, string token)
          {
              UnityWebRequest www = UnityWebRequest.Get("https://www.triggercmd.com/api/run/triggerSave?trigger=" + trigger + "&computer=" + computer + "&params=" + parameters + "&token=" + token);
              yield return www.SendWebRequest();
      
              if (www.isNetworkError || www.isHttpError)
              {
                  Debug.Log(www.error);
              }
              else
              {
                  // Show results as text
                  Debug.Log(www.downloadHandler.text);
      
                  // Or retrieve results as binary data
                  byte[] results = www.downloadHandler.data;
              }
          }
      }
      

      I created an example VR app for Oculus Quest to demonstrate. I recommend using SideQuest to install it.

      Russell VanderMey

      1 Reply Last reply Reply Quote 0
      • RussR Russ referenced this topic on

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post