And then another to use the script in the static variable (PointItemIcon) hung on in a lot of game objects, and then I go to modify the static variables, didn't have to share effect, after modify the static variables, other objects script Timer. The time value did not change
Please answer thank you!
Public class PointItemIcon: MonoBehaviour, IPointerEnterHandler
{
Public int key;//backpack items keys
Bool timeBool;//control timer switch
BagManager managerObj;//BagManager instance of the
Void the Update ()
{
If (timeBool)
{
The Timer. The time +=time. DeltaTime;
If (Timer. The time & gt; 2)
{
ManagerObj. BagTip. SetActive (false);
TimeBool=false;
}
}
}
Public void OnPointerEnter (PointerEventData eventData)
{
If (gameObject. ActiveSelf==true)
{
ManagerObj=BagManager. Instance;
ManagerObj. BagTip. SetActive (true);
ManagerObj. BagTip. Transform. GetChild (0). GetComponent
The Timer. The time=0;
TimeBool=true;
}
}
}
CodePudding user response:
Script similar properties, on the object of the game, why change have this sharing effect, illogical, you can try the script of the value of time is to obtain a value of the parent, and modifying the superclass object of the game valueCodePudding user response:
The Timer. The time will surely become it is the only global static variables, the Timer. The time +=time. DeltaTime; Are you sure this call and the Timer class without error