1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlayerReplay : MonoBehaviour
- {
- public Transform[] joints = new Transform[25];
- public Material boneMaterial;
- // (need to implement controller click to trigger save)
- public void Save()
- {
- SaveSystem.Save(this);
- }
- public void Load()
- {
- JointsData data = SaveSystem.Load();
- if(data == null)
- {
- Debug.LogError("Load failed");
- return;
- }
- for(int i = 0; i < joints.Length; i++)
- {
- // Create GameObject cubes for joints
- GameObject jointObj = GameObject.CreatePrimitive(PrimitiveType.Cube);
- LineRenderer lr = jointObj.AddComponent<LineRenderer>();
- lr.positionCount = 2;
- lr.material = boneMaterial;
- lr.startWidth = 0.3f;
- lr.endWidth = 0.3f;
- jointObj.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
- // (need to test)
- jointObj.transform.position = new Vector3(data.jointsPositionsX[i], data.jointsPositionsY[i], data.jointsPositionsZ[i]);
- // Connect the joints with LineRenderer
- }
- }
- }
|