Skip to content

Instantly share code, notes, and snippets.

@keijiro
Created September 9, 2011 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keijiro/1205428 to your computer and use it in GitHub Desktop.
Save keijiro/1205428 to your computer and use it in GitHub Desktop.
Workaround for asset reference problem.
@MenuItem ("MyMenu/Do Something")
static function DoSomething () {
var header1 = ScriptableObject.CreateInstance.<StateHeader>();
var header2 = ScriptableObject.CreateInstance.<StateHeader>();
AssetDatabase.CreateAsset(header1, "Assets/State1Set.asset");
AssetDatabase.CreateAsset(header2, "Assets/State2Set.asset");
var state1 = ScriptableObject.CreateInstance.<State1>();
var state2 = ScriptableObject.CreateInstance.<State2>();
state1.reference = state2;
state2.reference = state1;
AssetDatabase.AddObjectToAsset(state1, header1);
AssetDatabase.AddObjectToAsset(state2, header2);
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(state1));
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(state2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment