Reputation: 311
I'm using Unity 2018.4.0f1 for an introductory course on Unity.
For some reason, Unity is not updating my script, even after saving on Visual Studio and being displayed correctly in my Unity scripts folder.
This is a snippet of my program from Unity, which is being displayed correctly.
However, whenever I enter Play Mode the attributes reset to the values I had in the pre-updated script.
My program is quite simple, hence I'm certain this is not a software issue. I also found similar issue raised here:
https://forum.unity.com/threads/why-is-unity-not-updating-my-scripts.497383/
As well as here:
https://answers.unity.com/questions/17460/unity-is-not-updating-my-scripts.html
None of these contain a conclusive answer, and I haven't been able to resolve this issue.
My full program is below:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float speed = 10.0f;
public float turn = 25.0f;
public float horizontalInput;
public float verticalInput;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
horizontalInput = Input.GetAxis("Horizontal");
verticalInput = Input.GetAxis("Vertical");
// We'll move the player forward
transform.Translate(Vector3.forward * Time.deltaTime * speed * verticalInput);
transform.Rotate(Vector3.up, Time.deltaTime * turn * horizontalInput);
}
}
Upvotes: 1
Views: 2621
Reputation: 93
When you have public variables that are also serialized, the value from editor overrides the value declared in the script, you'd probably have to delete some meta data of the scene to completely reset it. Just change it from editor, or make those values private, then editor won't have access to them and won't change the values
Upvotes: 2