VR模拟枪支打靶,消灭鬼怪,换弹以及上弦等等硬核枪支操作。 使用HTCVive设备,开启SteamVR进行游玩。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

54 lines
2.0 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SaveManager : MonoBehaviour {
public List<GameObject> objType;
public List<SaveObject> objInstance;
private int allObjectNum;
private int currentId;
//加载物品使用的变量
private string loadObjName;
private int loadObjType;
private Vector3 loadObjPos;
private Vector3 loadObjAngle;
private Vector3 loadObjScale;
public void SaveAll() {
print("aa");
GameObject[] allObject = GameObject.FindGameObjectsWithTag("canSave");
foreach (GameObject obj in allObject) {
objInstance.Add(obj.GetComponent<SaveObject>());
allObjectNum++;
}
SaveSystem.SetInt("AllSaveObjectNum",allObjectNum);
foreach (SaveObject sobj in objInstance)
{
sobj.id = currentId;
sobj.SaveObjMassage();
currentId++;
}
}
public void LoadAll() {
GameObject[] allObject = GameObject.FindGameObjectsWithTag("canSave");
foreach (GameObject obj in allObject)
{
Destroy(obj);
}
int loadObjectNum = SaveSystem.GetInt("AllSaveObjectNum");
for (int id = 0;id < loadObjectNum;id++) {
loadObjType = SaveSystem.GetInt("Object" + id + "type");
loadObjName = SaveSystem.GetString("Object" + id + "name");
loadObjPos = SaveSystem.GetVector3("Object" + id + "pos");
loadObjAngle = SaveSystem.GetVector3("Object" + id + "angle");
loadObjScale = SaveSystem.GetVector3("Object" + id + "scale");
GameObject loadObj = Instantiate(objType[loadObjType]);
//loadObj.name = loadObjName;
loadObj.transform.position = loadObjPos;
loadObj.transform.localEulerAngles = loadObjAngle;
loadObj.transform.localScale = loadObjScale;
print(loadObjType+" "+loadObjName);
//GameObject loadObj = Instantiate();
}
}
}