05-14-2014, 10:49 PM
Hey, thanks for the pointers.
I am learning about Editor scripting as fast as I can. It seems the most useful aspect of working in Unity.
It still doesn't work, but here is my new attempt:
My idea so far is to drop the custom editor on a prefab of a CurvySplineSegment, then drop a text file into it, click READ and automate adding a CurvySpline control point for each line. I hope I am going about this the right way. I shall keep doing research.
Heres the script, and advice or tips or direction would very welcome:
[font]using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor( typeof( splineReader ) )]
public class splineReader : Editor
{
public TextAsset track;
string fileRead = track.text;
public override void OnInspectorGUI()
{
base.OnInspectorGUI ();
EditorGUILayout.LabelField ("Spine Reader");
if( GUILayout.Button ( "READ!"))
{
Debug.Log("pressed read");
string lines = fileRead.Split("\n")
while (lines != null)
{
string[] position = fileRead.Split (" ");
CurvySpline.Add(new vector3 ([0],[1],[2]))
Debug.Log("made a CP")
string lines = fileRead.Split ("\n");
}
Debug.Log("done making a spline")
}
}
}[/font]
i found these tutorials the most helpful ~
building a custom editor:
https://www.youtube.com/watch?v=WlGwBmM-dfA
Reading text files into strings (also awesome accent hehe):
https://www.youtube.com/watch?v=4hnItE2gZ40
I am learning about Editor scripting as fast as I can. It seems the most useful aspect of working in Unity.
It still doesn't work, but here is my new attempt:
My idea so far is to drop the custom editor on a prefab of a CurvySplineSegment, then drop a text file into it, click READ and automate adding a CurvySpline control point for each line. I hope I am going about this the right way. I shall keep doing research.
Heres the script, and advice or tips or direction would very welcome:
[font]using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor( typeof( splineReader ) )]
public class splineReader : Editor
{
public TextAsset track;
string fileRead = track.text;
public override void OnInspectorGUI()
{
base.OnInspectorGUI ();
EditorGUILayout.LabelField ("Spine Reader");
if( GUILayout.Button ( "READ!"))
{
Debug.Log("pressed read");
string lines = fileRead.Split("\n")
while (lines != null)
{
string[] position = fileRead.Split (" ");
CurvySpline.Add(new vector3 ([0],[1],[2]))
Debug.Log("made a CP")
string lines = fileRead.Split ("\n");
}
Debug.Log("done making a spline")
}
}
}[/font]
i found these tutorials the most helpful ~
building a custom editor:
https://www.youtube.com/watch?v=WlGwBmM-dfA
Reading text files into strings (also awesome accent hehe):
https://www.youtube.com/watch?v=4hnItE2gZ40