I have two materials called “m_” + theSexOfTheChatacter + “SayingNo”, where ‘theSexOfTheChatacter’ is a string with a gender of a character.
I attach this material to an object using this code:
characterConditionMat = (Material)Resources.Load("m_" + theSexOfTheChatacter + "SayingNo", typeof(Material));
this.renderer.material = characterConditionMat;
I have a situation where I need to show right from the start the first material, than attach another material in two seconds.
IEnumerator GoAhead() {
print("Starting " + Time.time);
yield return StartCoroutine(SayingNo());
yield return StartCoroutine(TakingShower());
}
IEnumerator SayingNo() {
yield return new WaitForSeconds(2);
characterConditionMat =(Material)Resources.Load("m_" + theSexOfTheChatacter + "SayingNo", typeof(Material));
this.renderer.material = characterConditionMat;
processBool = true; // can't click on other objects
print("No " + Time.time);
}
IEnumerator TakingShower() {
characterConditionMat =(Material)Resources.Load("m_" + theSexOfTheChatacter + "TakingShower", typeof(Material));
this.renderer.material = characterConditionMat;
processBool = true; // can't click on other objects
yield return new WaitForSeconds(2);
print("TakeShower " + Time.time);
}
But it doesn’t work at all in spite of the fact, that “print-function” shows that the time passed.
Why can’t I attach materials in this situation?
Thank you.