質問編集履歴
1
▼追記1 を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -80,6 +80,80 @@
|
|
80
80
|
|
81
81
|
|
82
82
|
|
83
|
+
▼追記1 async/awaitを使用(これでも変わらず)
|
84
|
+
|
85
|
+
```c#
|
86
|
+
|
87
|
+
public class TestScript : MonoBehaviour {
|
88
|
+
|
89
|
+
private GameObject Monster { get; set; }
|
90
|
+
|
91
|
+
private float Speed { get; set; } = 3;
|
92
|
+
|
93
|
+
private bool Loaded { get; set; } = false;
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
void Start () {
|
98
|
+
|
99
|
+
Monster = GameObject.Find("monster");
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
void Update() {
|
106
|
+
|
107
|
+
Monster.transform.Rotate(new Vector3(0, 0, Speed));
|
108
|
+
|
109
|
+
if (!Loaded) {
|
110
|
+
|
111
|
+
Loaded = true;
|
112
|
+
|
113
|
+
Task nowait = ReadSaveDataFileAsync(Application.persistentDataPath + "/Test.sav");
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
public async Task ReadSaveDataFileAsync(string filePath) {
|
122
|
+
|
123
|
+
string fileName = filePath;
|
124
|
+
|
125
|
+
SaveData saveData = (SaveData)LoadFromBinaryFile(fileName);
|
126
|
+
|
127
|
+
await Task.Delay(0);
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
// ファイル読込
|
134
|
+
|
135
|
+
public static object LoadFromBinaryFile(string path) {
|
136
|
+
|
137
|
+
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
|
138
|
+
|
139
|
+
BinaryFormatter f = new BinaryFormatter();
|
140
|
+
|
141
|
+
object obj = f.Deserialize(fs);
|
142
|
+
|
143
|
+
fs.Close();
|
144
|
+
|
145
|
+
return obj;
|
146
|
+
|
147
|
+
}
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
```
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
83
157
|
◆環境
|
84
158
|
|
85
159
|
Unity2019.2.17f1
|