Hi guys. I am having a really annoying problem with inheritance.
I am using UI to dynamically populate a shop with Weapons from a list.
Weapon is the base class and I then have other classes such as Pistol, Machinegun, etc, that extend Weapon.
public abstract class Weapon : MonoBehaviour{
public int weaponID;
}
…
public class Pistol : Weapon {
public Pistol() {
weaponID = 1; // test value;
}
…
public class MachineGun : Weapon {
public MachineGun () {
weaponID = 2; // test value;
}
…
for (int i = 0; i < weaponsForSale.Length; i++) {
GameObject weaponPrefab = Instantiate (weaponsForSale *);*
-
Weapon weaponComp = weaponPrefab.GetComponent<Weapon>();* -
Debug.Log(weaponComp); // this displays the correct class, Pistol, Machinegun, etc* -
Debug.Log(weaponComp.weaponID); // this displays 0, the base stat of weapon instead of the pistol, machinegun, etc*
Well, if your editor hardware does support compute shaders but they simply doesn't work when the target is Android you should file [a bug report as suggested here.][1]. You may have a look at [the bottom of this page][2]. It might be possible that OpenGL ES 3.1 might not be supported by your PC hardware. What OS and hardware do you use? [1]: https://blogs.unity3d.com/2015/05/26/dx11-features-on-mobile/ [2]: https://docs.unity3d.com/Manual/OpenGLCoreDetails.html
– Bunny83