Quantcast
Channel: Questions in topic: "exception"
Viewing all articles
Browse latest Browse all 470

NullReferenceException 999+... Still all working fine and especialy in that error lines :(

$
0
0
All is working fine on that lines , Its calling error on IF lines on all of 4 scripts. Can't get it to disappear from console. As you can see it's all working fine, activating and deactivating child objects on 0.3 percent of shield oil rockets cannon. That scripts control scaling of Bar's with caling information from main ammo rocket shield oil system scripts. And in that IF it is taking information for percentage same as for controling scale of Bar. Just can not see where did I make a mistake. Also second and third script have reverse order in IF but that didnt change anything and it's still working as it suppoused to. So I hope someone can help me with this. (("UPDATED-This is GIF> watch yellow bar")) https://gph.is/g/apyA6l3giphy This is IMAGE Error-Null-02-01

first script using UnityEngine; public class OilBar : MonoBehaviour { private OilAmmo oilAmmo; public void Setup(OilAmmo oilAmmo) { this.oilAmmo = oilAmmo; oilAmmo.OnOilChanged += OilAmmo_OnOilChanged; } private void OilAmmo_OnOilChanged(object sender, System.EventArgs e) { transform.Find("Bar").localScale = new Vector3(1, oilAmmo.GetOilPercent(), 1); } void Update (){ if (oilAmmo.GetOilPercent() <= 0.3) { gameObject.transform.GetChild(1).gameObject.SetActive(true); } else gameObject.transform.GetChild(1).gameObject.SetActive(false); } } second script using UnityEngine; public class AmmoBar : MonoBehaviour { private GunAmmo gunAmmo; public void Setup(GunAmmo gunAmmo) { this.gunAmmo = gunAmmo; gunAmmo.OnAmmoChanged += GunAmmo_OnAmmoChanged; } private void GunAmmo_OnAmmoChanged(object sender, System.EventArgs e) { transform.Find("Bar").localScale = new Vector3(1, gunAmmo.GetAmmoPercent(), 1); } void Update () { if (gunAmmo.GetAmmoPercent() >= 0.3) { gameObject.transform.GetChild(1).gameObject.SetActive(false); } else gameObject.transform.GetChild(1).gameObject.SetActive(true); } } third script using UnityEngine; public class RocketBar : MonoBehaviour { private RocketAmmo rocketAmmo; void Start(){} public void Setup(RocketAmmo rocketAmmo) { this.rocketAmmo = rocketAmmo; rocketAmmo.OnRocketChanged += RocketAmmo_OnRocketChanged; } void RocketAmmo_OnRocketChanged(object sender, System.EventArgs e) { transform.Find("Bar").localScale = new Vector3(1, rocketAmmo.GetRocketPercent(), 1); } void Update (){ if (rocketAmmo.GetRocketPercent() >= 0.3) { gameObject.transform.GetChild(1).gameObject.SetActive(false); } else gameObject.transform.GetChild(1).gameObject.SetActive(true); } } forth script using UnityEngine; public class ShieldBar : MonoBehaviour { private ShieldSystem shieldSystem; public void Setup(ShieldSystem shieldSystem) { this.shieldSystem = shieldSystem; shieldSystem.OnShieldChanged += ShieldSystem_OnShieldChanged; } private void ShieldSystem_OnShieldChanged(object sender, System.EventArgs e) { transform.Find("Bar").localScale = new Vector3(1, shieldSystem.GetShieldPercent(), 1); } void Update (){ if (shieldSystem.GetShieldPercent() <= 0.3) { gameObject.transform.GetChild(1).gameObject.SetActive(true); } else gameObject.transform.GetChild(1).gameObject.SetActive(false); } }

Viewing all articles
Browse latest Browse all 470

Trending Articles



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