Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Scriptable Object becomes Null randomly

$
0
0
To Keep things concise, I'd like to draw your attention to the two pseudo code comments in this script. For some reason, the debug.log under the first comment prints out the string field of the scriptable object correctly while the debug.log under the second comment throws a null reference exception. I've spent hours trying to sort this out but haven't been succesful. The "buildingSO" scriptable object itself never get deleted or modified but somehow at somepoint, it becomes null past the "Initialize" method. Help appreciated public class BuildItemHolder : MonoBehaviour, IUIDraggable { private ScriptableObject buildingSO; public int slotIndex = 0; public TabbedSoListDrawer parentDrawerList; public Transform ImageTransform; public Image ThisImage; public float upperUIdragBound; public void initializeSlot(int index,TabbedSoListDrawer parentList, ScriptableObject thisSlotScriptableObject, float upperUIbound) { ThisImage = GetComponentInChildren(); slotIndex = index; parentDrawerList = null; parentDrawerList = parentList; buildingSO = thisSlotScriptableObject; ThisImage.sprite = (buildingSO as BuildingSO).UI_image; //WORKS WORKS WORKS WORKS WORKS WORKS WORKS WORKS WORKS WORKS Debug.Log((buildingSO as BuildingSO).buildingName); upperUIdragBound = upperUIbound; } public void BuildingDraggedOutOffDraw() { Debug.Log("building dragged out of draw"); //DOESN'T WORK Doesn't WORK doesn't WORK doesn't Work Debug.Log((buildingSO as BuildingSO).buildingName); BuildingPlacer.instance.EnableAndSetBuilding(buildingSO); TouchManager.instance.TurnOffUITouchManager(); AllMenuPathManager.instance.HideActiveElements(); }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>