Beispiel #1
0
    // Start is called before the first frame update
    public void ChangeName(string nm)
    {
        filename      = nm;
        nameText.text = filename;
        records       = GameObject.Find("Player").GetComponent <RecordPlayerMovement>();
        Debug.Log("player found: " + records.name);
        //try to load a file
        //Re-import the file to update the reference in the editor


        StreamReader reader = new StreamReader("Assets/Resources/" + filename + ".txt");
        string       asset  = reader.ReadToEnd();

        //Read the text from directly from the test.txt file

        //if no file, use the player memory to playback poses
        if (asset != null && !string.IsNullOrEmpty(asset))
        {
            poses = new List <TimedPose>();
            string[] lines = asset.Split(';');
            foreach (string line in lines)
            {
                try
                {
                    string[]  vals = line.Split(',');
                    TimedPose t    = new TimedPose();
                    t.elapsedTime       = float.Parse(vals[0]);
                    t.headPosition      = new Vector3(float.Parse(vals[1]), float.Parse(vals[2]), float.Parse(vals[3]));
                    t.headRotation      = new Quaternion(float.Parse(vals[4]), float.Parse(vals[5]), float.Parse(vals[6]), float.Parse(vals[7]));
                    t.leftHandPosition  = new Vector3(float.Parse(vals[8]), float.Parse(vals[9]), float.Parse(vals[10]));
                    t.leftHandRotation  = new Quaternion(float.Parse(vals[11]), float.Parse(vals[12]), float.Parse(vals[13]), float.Parse(vals[14]));
                    t.rightHandPosition = new Vector3(float.Parse(vals[15]), float.Parse(vals[16]), float.Parse(vals[17]));
                    t.rightHandRotation = new Quaternion(float.Parse(vals[18]), float.Parse(vals[19]), float.Parse(vals[20]), float.Parse(vals[21]));

                    poses.Add(t);
                }
                catch (System.FormatException e)
                {
                    Debug.Log("incorrect line format detected.");
                }
            }
        }
        else
        {
            poses = records.Poses;
        }
    }
Beispiel #2
0
 // Start is called before the first frame update
 void Awake()
 {
     recordMovement = GetComponent <RecordPlayerMovement>();
     spawnLogic     = GetComponent <Spawning>();
 }