- Home /
Access Script from inactive game object
hi, so i am currently facing a problem right now. I want to access a script from an inactive game object. this object has a timer script. now this timer script pauses when the said object is inactive (this is the only way i can pause the timer, because if i use Timer.timeScale = 0; the whole game freezes, which is not what i want. just the timer). so what i want is if objectA with timer scriptA turns inactive, a scriptB from objectB, checks if objectA is inactive or not; if objectA is inactive, scriptB will access a int value (the time it paused) from scriptA.
I tried using GameObject.Find("objectA");
but it does not work with inactive objects;
I tried using
Transform getObjectA = transform.FindChild ("objectA"); scriptA timeGot = transform.GetComponentsInChildren<scriptA> (true); passedSec = timeGot.strSec; passedMin = timeGot.strMin; passedHrs = timeGot.strHrs;
but it doesn't work either. can someone help me? like maybe i'm wrong in using these codes, or if i should use other way. thanks in advance <3 <3
Your answer
![](https://koobas.hobune.stream/wayback/20220612100333im_/https://answers.unity.com/themes/thub/images/avi.jpg)