public void Load(string pPath, PersistantObject pObject) { using (BinaryReader reader = new BinaryReader(File.Open(pPath, FileMode.Open))) { pObject.Load(new GameDataReader(reader)); } }
protected void Read(Stream stream, int version) { using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { numPersistantObjects = 0; if (version < 69) { return; } numPersistantObjects = reader.ReadInt32(); persistantObjects = new PersistantObject[numPersistantObjects]; for (int i = 0; i < numPersistantObjects; i++) { var thisObject = new PersistantObject(); thisObject.x = reader.ReadSingle(); thisObject.y = reader.ReadSingle(); thisObject.unionData = new PackedVUID(); thisObject.unionData.creator_ = reader.ReadUInt32(); thisObject.unionData.num_ = reader.ReadUInt32(); thisObject.unionData.index_ = reader.ReadByte(); reader.ReadBytes(3); //align on Int32 boundary thisObject.visType = reader.ReadInt16(); thisObject.flags = reader.ReadInt16(); persistantObjects[i] = thisObject; } } }
public void Save(PersistantObject pObject) { using (BinaryWriter writer = new BinaryWriter(File.Open(savePath, FileMode.Create))) { pObject.Save(new GameDataWriter(writer)); } }
public void ResetTour() { EnableComponents.MakeCanvasAppear(StartTourCanvas); player.transform.position = StartPosition.transform.position; EnableComponents.MakeCanvasDisappear(ResetTourCanvas); PersistantObject po = FindObjectOfType <PersistantObject> (); po.SetCountToOne(); }
public override void Load(GameDataReader reader) { int count = reader.ReadInt(); for (int i = 0; i < count; i++) { PersistantObject o = Instantiate(cube); o.Load(reader); objects.Add(o); } }
void CreateObject() { PersistantObject o = Instantiate(cube); Transform t = o.transform; t.localPosition = Random.insideUnitSphere * 5f; t.localRotation = Random.rotation; t.localScale = Vector3.one * Random.Range(0.1f, 1f); objects.Add(o); }
void Awake() { if(persistantObject == null) //If manager doesn't exist, create one { DontDestroyOnLoad(gameObject); persistantObject = this; } else if(persistantObject != null) //if manager does exist, destroy this copy { Destroy(gameObject); } persistantObject = this; }
// Use this for initialization void Awake() { if (instanceRef == null) { instanceRef = this; DontDestroyOnLoad(gameObject); } else { DestroyImmediate(gameObject); } }
private void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else if (instance != this) { Destroy(gameObject); } }