I’m attempting to expose the abilities of a given NPC and lock the window so I have easy access to them in the editor. Problem is, when I click the referenced script derived from GetComponent, instead of taking me to the ability in the project hierarchy it attempts to take me to the parent gameobject as far as I can tell.
Here’s the code i’m using:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class AbilityHolder : MonoBehaviour
{
public GameObject Fishpart;
public GameObject Fishpart2;
public List<AttackAbility> Abilities;
public List<AttackAbility> Abilities2;
private GameObject fishpartLastFrame;
private GameObject fishpartLastFrame2;
void Update()
{
if (Fishpart != null)
{
if (Fishpart != fishpartLastFrame) InitializeAbilities();
}
if (Fishpart2 != null)
{
if (Fishpart2 != fishpartLastFrame2) InitializeAbilities2();
}
fishpartLastFrame = Fishpart;
fishpartLastFrame2 = Fishpart2;
}
void InitializeAbilities()
{
var i = 0;
Abilities.Clear();
foreach (Transform t in Fishpart.transform)
{
var ability = t.GetComponent<AttackAbility>();
if (ability)
{
Abilities.Add(ability);
i++;
}
}
}
void InitializeAbilities2()
{
var i = 0;
Abilities2.Clear();
foreach (Transform t in Fishpart2.transform)
{
var ability = t.GetComponent<AttackAbility>();
if (ability)
{
Abilities2.Add(ability);
i++;
}
}
}
}
Any help is greatly appreciated!
