コード例 #1
0
    public void Init()
    {
        Shooter shooter = GetComponentInChildren <Shooter>();

        Gun gun = (Gun)Instantiate(gunPrefab);

        shooter.AddGun(gun);

        Shield shield = (Shield)Instantiate(shieldPrefab);

        shooter.AddShield(shield);
    }
コード例 #2
0
    override public void OnInspectorGUI()
    {
        //base.OnInspectorGUI();

        var debugManager = target as DebugManager;

//		Shooter[] shooters = new Shooter[] {
//			debugManager.pistolero.GetComponentInChildren<Shooter>(),
//			debugManager.badGuy.GetComponentInChildren<Shooter>()
//		};

        //for (int i = 0; i < 2; i++) {
        //Shooter s = shooters[i];
        Shooter s = debugManager.pistolero.GetComponentInChildren <Shooter>();

//			if (i == 0) EditorGUILayout.LabelField("Pistolero");
//			else {
//				EditorGUILayout.Separator();
//				EditorGUILayout.LabelField("Bad Guy");
//			}

        if (s.gun == null)
        {
            foreach (Gun gun in gunPrefabs)
            {
                if (GUILayout.Button("Add " + gun.name))
                {
                    s.AddGun((Gun)Instantiate(gun));
                    break;
                }
            }
        }
        else
        {
            if (GUILayout.Button("Remove " + s.gun.name))
            {
                s.RemoveGun();
            }
        }

        EditorGUILayout.Separator();

        if (s.shield == null)
        {
            foreach (Shield shield in shieldPrefabs)
            {
                if (GUILayout.Button("Add " + shield.name))
                {
                    s.AddShield((Shield)Instantiate(shield));
                    break;
                }
            }
        }
        else
        {
            if (GUILayout.Button("Remove " + s.shield.name))
            {
                s.RemoveShield();
            }
        }

        EditorUtility.SetDirty(s);
        //}
    }