Im having some scoping issues when using an abstract function, I think. Not sure why its doing a implicitly convert of the type when they are the same?
Class im inheriting from
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LB.Managers;
namespace LB.AStarPathFinding
{
public abstract class AStarFindPath<T,U> : MonoBehaviour {
public virtual void FindPath<T>(Vector3 startPos, Vector3 targetPos) {
}
public abstract U NodeFromWorldPoint<T,U> (Vector3 worldPos);
}
}
Error in child class
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LB.Managers;
using LB.AStarPathFinding;
namespace LB.HexSphereBuild
{
[RequireComponent (typeof(PlanetBuildManager))]
public class AStarHexSphere: AStarFindPath<Hexsphere,HexTile>
{
private HexSphere _hexSphereObj;
void Awake ()
{
// Reference to HexSphere
_hexSphereObj = gameObject.GetComponent<PlanetBuildManager> ().hexSphereObj;
}
override public HexTile NodeFromWorldPoint<HexSphere,HexTile> (Vector3 worldPos ){
int startNodeIndex = _hexSphereObj.GetHexIndexFromPoint (worldPos);
//error CS0029: Cannot implicitly convert type `LB.HexSphereBuild.HexTile' to `HexTile'
// _hexSphereObj.Hexes is public List<HexTile> Hexes { get{ return _hexes; }}
HexTile startHex = _hexSphereObj.Hexes [startNodeIndex];
return startHex;
}
//--------------------------------------------------------------------
public void FindPath (Vector3 startPos, Vector3 targetPos)
{
// Get HexTile from start and end positions
int startNodeIndex = _hexSphereObj.GetHexIndexFromPoint (startPos);
HexTile startHex = _hexSphereObj.Hexes [startNodeIndex];
int targetNodeIndex = _hexSphereObj.GetHexIndexFromPoint (targetPos);
HexTile endHex = _hexSphereObj.Hexes [targetNodeIndex];
}
}
}