Created
April 4, 2018 02:18
-
-
Save codehoose/97f6ad7cb051ab385f885e16bc4fa4fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Serializable] | |
public class MyComponentData | |
{ | |
public Vector3 pos; | |
public string name; | |
} | |
public class MyComponent : MonoBehaviour | |
{ | |
void Start() | |
{ | |
// TODO: Load json from disk somehow and place in variable called 'json' | |
var data = JsonUtility.FromJson<MyComponentData>(json); | |
transform.position = data.pos; | |
name = data.name; | |
} | |
void OnDestroy() | |
{ | |
var data = new MyComponentData(); | |
data.pos = transform.pos; | |
data.name = name; | |
var json = JsonUtility.ToJson(data); | |
// TODO: Save JSON | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment