using UnityEngine;
using System;
public interface IAimPanel
{
public GameObject GetGameObject();
}
public class Target : MonoBehaviour, IAimPanel
{
public GameObject GetGameObject()
{
return gameObject;
}
}
public class Test : MonoBehaviour
{
public IAimPanel aimPanel;
private void Start()
{
aimPanel.GetGameObject().SetActive(true);
}
}
I want to be able to access gameObject via interface in Unity C#, I've done it in the code above, but I want a more elegant implementation.
Something like this
private void Start()
{
aimPanel.gameObject.SetActive(true);
}