Inspector removing references?
So i am using this script
IdleN = this.GetComponent().sprite;
in startup of the script.
I go to the inspector, and set the reference to a model i created, (a texture), and everything is good. Until i press play, and then the inspector removes all of the references i gave, and sets it to (none).
Help...
This is how it looks
public Sprite IdleN;
// Use this for initialization
void Start () {
sprite = this.GetComponent<SpriteRenderer>();
}
Can you include screenshots of your inspector before and after?
Answer by FortisVenaliter · Sep 28, 2017 at 08:58 PM
Woah, so in your start function, you're setting all sprites to this.GetComponent().sprite.
That means you're overwriting all of your stored sprite variables with whatever sprite is currently set in the attached SpriteRenderer.
What are you trying to do?
Your answer
![](https://koobas.hobune.stream/wayback/20220612135845im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
[Help] how do I reference/access another script in unity C# 2 Answers
The name `FindObjectOfType' does not exist in the current context 2 Answers
NullReferenceException problems. 0 Answers
Launching local Unity API Reference from MonoDevelop on Linux 0 Answers
The referenced script on this Behaviour (Game Object 'Main Camera') is missing! 1 Answer