Guys, in connection with the situation I had to get acquainted with inheritance on a quick basis, I understood the principle, but in fact the trouble, when I added grade 1, everything was normal, when I started writing grade 2, and take variables out of 1. He simply does not see them, but this is what, when I save the script, try to start the scene, the unit swears, you forgot to correct the mistakes, but the console is silent, and monodevelop is also silent.
I was told that there are problems with inheritance, but where? I really need your help, all hope for you. The code seems to be simple, understandable, if you write something, I will designate what works. What needs to be fixed? How to return console messages?
using UnityEngine; using System.Collections; using System.Collections.Generic; public class Weapon : MonoBehaviour { class BaseWeapon { public int weapon_damage, ammo_amount, reload_time; public bool weapon_active=false; public GameObject pistolprefab; public GameObject autorifleprefab; public GameObject currect_weapon; public GameObject previos_weapon; public BaseWeapon pistol = new BaseWeapon(10, 7, 2); public BaseWeapon autorifle = new BaseWeapon(20, 30, 5); public BaseWeapon(int wd, int aa, int rt) { weapon_damage = wd; ammo_amount = aa; reload_time = rt; } public void weapon_on_off() { if (weapon_active=true) { currect_weapon.SetActive(true); previos_weapon.SetActive(false); } } } class ManagerWeapon { public void change_weapon() { if (Input.GetKey("1")) { currect_weapon=pistol; previos_weapon=autorifle; weapon_active=true; } if (Input.GetKey("2")) { currect_weapon=autorifle; previos_weapon=pistol; weapon_active=true; } } } void Start() { currect_weapon=pistol; previos_weapon=autorifle; weapon_active=true; } }