- Home /
Avatar constructor returns null
Constructor of the Avatar object returns null. It is weird, since it is not entirely possible in C# except for some cases (Nullable objects). You can test with this code:
[ExecuteInEditMode]
public class Test : MonoBehaviour {
void Update(){
Avatar avatar = new Avatar();
if(avatar == null) Debug.Log("Constructor really returns null.");
}
}
Any thoughts? Is this a bug or shennanigans?
$$anonymous$$aybe you can achieve that by overloading its Equals() method, making it return true when compared to a null value. Overloading Equals() and Operator ==
Answer by Vizas · Feb 18, 2015 at 08:43 PM
Try using the AvatarBuilder for creating Avatars.
I need to create Avatar with constructor. What I am asking is, why the constructor is returning null. It shouldn't happen normally.
Your answer
![](https://koobas.hobune.stream/wayback/20220613183649im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
C# Array index is out of range but index is zero 1 Answer
Distribute terrain in zones 3 Answers
Hint Joint like a rope have weird behavior 1 Answer
Photon networking doesn't sync 0 Answers