public void OnEnable() { script = target as AiBehave; FindImplement(); UpdateTreeAsset(); }
public void RemoveAiBehave() { if (m_behave != null) { Destroy(m_behave.gameObject); m_behave = null; } }
public void SetupAibehave(GameObject aiPrefab) { if (aiPrefab == null) { return; } if (m_behave != null) { Destroy(m_behave.gameObject); m_behave = null; } GameObject go = Instantiate(aiPrefab, transform.position, transform.rotation) as GameObject; if (go == null) { Debug.LogError("Instantiate ai prefab failed."); return; } go.transform.parent = transform; m_behave = go.GetComponent <AiBehave>(); if (m_behave == null) { Debug.LogError("cant find AiBehaveTree."); return; } AiBehaveSingle bs = m_behave as AiBehaveSingle; if (bs != null) { bs.RegisterAiObject(this); } else { Debug.LogWarning("ai [" + m_behave + "] is not a AiBehaveSingle"); } }