예제 #1
0
        private void SavePositionState()
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(filename, FileMode.OpenOrCreate);

            PositionData positionData = new PositionData();

            positionData.Position = transform.parent.transform.position;
            positionData.Rotation = transform.parent.transform.eulerAngles;
            positionData.Scale    = transform.parent.transform.localScale;

            bf.Serialize(file, positionData);
            file.Close();
        }
예제 #2
0
        private void LoadPositionState()
        {
            print(filename);
            if (File.Exists(filename))
            {
                print("here");
                BinaryFormatter bf           = new BinaryFormatter();
                FileStream      file         = File.Open(filename, FileMode.Open);
                PositionData    positionData = (PositionData)bf.Deserialize(file);
                file.Close();

                transform.parent.position    = positionData.Position;
                transform.parent.eulerAngles = positionData.Rotation;
                transform.parent.localScale  = positionData.Scale;
            }
        }