Someone could tell me why when I call the “playing1” function from a button (using the inspector’s OnClick and selecting the object to which the script is attached) it performs the “print (” enter “);” and the “indica1” .SetActive (true); “, but when calling this function from another script, just execute” print (“enter”); "?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Principal : MonoBehaviour
{
public GameObject indica1;
(...)
public void playing1(string _velocity)
{
print("enter");
indica1.SetActive(true);
}
}
follows the excerpts of the script where the call is made:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.IO;
using System.IO.Ports;
using System;
using System.Threading;
public class UnitySerialPort : MonoBehaviour
{
Principal principal;
void Start ()
{
principal = gameObject.GetComponent<Principal>();
string valorComando = "100";
}
(...)
private void GenericSerialLoop ()
{
switch (comando){
case "p":
principal.playing1(valorComando);
break;
}
}
}