Hello,
i’ve developed a script computing the response of an electronic filter. Now i’m trying to render it through a GUI, to do so i’m using a linerenderer and the canvas system and they don’t seem to work really great together. I’ve trouble with resolution and the line can go out of screen when you change it. Is there any better feature to render a list of points ?
This some view of the actual rendering but if i change the resolution everything goes out:
And this is the code rendering the line :
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public void reload(){
if (PlayerPrefs.GetString ("Type") == "OrderOne") {
f2=new OrderOne("PB",PlayerPrefs.GetFloat ("T0"), PlayerPrefs.GetFloat ("Tinf"), PlayerPrefs.GetFloat ("Omega0"));
}
if (PlayerPrefs.GetString ("Type") == "OrderTwo") {
f2=new OrderTwo("PB", PlayerPrefs.GetFloat ( "Omega0"), PlayerPrefs.GetFloat ( "m") , PlayerPrefs.GetFloat("T0"), PlayerPrefs.GetFloat("Tmax"),PlayerPrefs.GetFloat("Tinf"));
}
f2.autoscale (45f,20f);
lineSol.SetVertexCount (0);
lineModule.SetVertexCount (0);
linePhase.SetVertexCount (0);
echelon.SetVertexCount (0);
lineSol.SetVertexCount (f2.getSol().Count);
linePhase.SetVertexCount (f2.getOmega().Count);
lineModule.SetVertexCount (f2.getOmega().Count);
echelon.SetVertexCount (f2.getEchelon().Count);
this.loadPosition ();
}
private void loadPosition(){
int i = 0;
lineSol.useWorldSpace = true;
lineModule.useWorldSpace = true ;
linePhase.useWorldSpace = true;
echelon.useWorldSpace = true;
List<float> ech = f2.getEchelon ();
while (i < f2.getT().Count) {
Vector3 pos = new Vector3 ( f2.getT () [i]+20f, f2.getSol () [i]+25f, 50f);
lineSol.SetPosition (i, pos);
i++;
}
i=0;
while (i < f2.getT().Count) {
Vector3 pos = new Vector3 ( f2.getT ()[i] + 20f , ech [i] + 25f, 50f);
echelon.SetPosition (i, pos);
i++;
}
i = 0;
while (i < f2.getOmega().Count) {
Vector3 pos = new Vector3 (f2.getOmega () [i]+20f, f2.getModule () [i], 50f);
lineModule.SetPosition (i, pos);
i++;
}
i = 0;
while (i < f2.getOmega().Count) {
Vector3 pos = new Vector3 (f2.getOmega () [i]+20f, f2.getPhase () [i]-30f, 50f);
linePhase.SetPosition (i, pos);
i++;
}
}
}