Question by
Milenchy · Dec 28, 2015 at 04:57 PM ·
unity 5scripting probleminspectorvariablesbug-perhaps
Why is Unity showing the wrong variables in the Inspector?
Why in the world is Unity showing variables from a different script?
using UnityEngine;
public class AudioController : MonoBehaviour {
private AudioSource audio;
public AudioClip cubeSelectSound;
private void Start() {
audio = GetComponent<AudioSource>();
}
public void PlaySoundOnCubeSelection() {
if (!selectedCubes.Contains(gameObject)) {
float soundPitch;
switch (selectedCubes.Count) {
case 1:
soundPitch = 1f;
break;
case 2:
soundPitch = 1.02f;
break;
case 3:
soundPitch = 1.04f;
break;
case 4:
soundPitch = 1.06f;
break;
default:
soundPitch = 0;
break;
}
PlaySoundOnce(soundPitch);
}
}
private void PlaySoundOnce(float soundPitch = 1f) {
audio.pitch = soundPitch;
audio.PlayOneShot(cubeSelectSound, 1f);
}
}
capture.png
(9.5 kB)
Comment
It seems that you may already have a script by that name. In that case your script is not even compiling.
Try calling it something else.
Answer by RobertoLangarica · Mar 16, 2016 at 02:41 PM
Jajaja thats weird. It may sound ridiculous but did you try removing the script and then add again the script, is obviously an error and may be this could help or you could put the inspector in debug mode and then again in normal mode (i'm just thinking on ways to reset the inspector).
PD: Did you have any editor script that could be pointing to AudioController?