GetComponent method not working on android buid
Hello, friends!
Sorry for my awful english.
Faced a problem in Unity3d when running on Android. The script does not find the component in the object found by the tag.
What I do in steps:
1) I'm looking for an object by tag in the 'Awake()' method:
GameObject timeLineSpanGo = GameObject.FindGameObjectWithTag(KeyStringConstants.InitiativeSpanTag);
At this step GameObject was found successfully (timeLineSpanGo != null).
2) I'm trying to get a component from 'timeLineSpanGo':
TimeLine = timeLineSpanGo.GetComponent<TimeLine>();
(Here 'TimeLine' is the field in the GameManager.)
At this step GameObject - not found (TimeLine == zero).
Therefore, the 'GetComponent()' method does not find the desired component.
update:
Interesting. If I try to find the 'FindObjectOfType()' after checking, then the object was found. But in my project only one object of this type.
TimeLine = timeLineSpanGo.GetComponent <TimeLine>();
if (TimeLine == null)
{
TimeLine = FindObjectOfType<TimeLine>();
}
That is, the component exists in memory, but is not found by the 'GetComponent<>()' method of the parent object.
The error appears only when starting on the Android device. When starting from Editor, an error does not occur.
Unity version - 2017.2.0f3 Personal
Android version is 7.1.2
Android device = Nokia 6 (TA-1021)
Help please solve this problem.
Thank you!
Your answer
Follow this Question
Related Questions
Update() function not working on Android. 1 Answer
Animation working in Unity and PC build, but not Android 1 Answer
because my game does not access my Scriptable Object 0 Answers
Animators in Android build 2 Answers
Camera FOV is adjustable in editor but not in Android Phone build (Google VR 1.6 and Unity 5.6.1f1) 1 Answer