public interface IVector3ValueList
{
public List<Vector3> GetVector3List();
}
public class Vector3ListGetter : IVector3ValueList
{
private List<float> xList, yList, zList;
public Vector3ListGetter(List<float> xList, List<float> yList, List<float> zList)
{
this.xList = xList;
this.yList = yList;
this.zList = zList;
}
public List<Vector3> GetVector3List()
{
float minX = xList.Min();
float minY = yList.Min();
float minZ = zList.Min();
// return ...
}
}
public class StartingPos : MonoBehaviour
{
public JsonConverter jsonConverter;
private IVector3ValueList _iVector3ValueList;
private List<Vector3> vertex;
private void Start()
{
_iVector3ValueList = new Vector3ListGetter(jsonConverter.XList,
jsonConverter.YList, jsonConverter.ZList); // What do I want to delete
vertex = _iVector3ValueList.GetVector3List();
}
}
This is an example of the code I want to use. I purposely used the interface for an example. And I wrote the following for Method Injection.
public class StartingPos : MonoBehaviour
{
public JsonConverter jsonConverter;
private IVector3ValueList _iVector3ValueList;
private List<Vector3> vertex;
[Inject]
public void Init(IVector3ValueList iVector3ValueList)
{
_iVector3ValueList = iVector3ValueList;
}
private void Start()
{
_iVector3ValueList = new Vector3ListGetter(jsonConverter.XList,
jsonConverter.YList, jsonConverter.ZList); // What do I want to delete
vertex = _iVector3ValueList.GetVector3List();
}
}
But it doesn’t work properly because it didn’t get the constructor parameters.
new Vector3ListGetter(jsonConverter.XList, jsonConverter.YList, jsonConverter.ZList)
How should I inject this object? In similar situations, it worked properly when there were no parameters in the constructor.