public class LoadMatPresetsDemo : MVRScript
{
private Atom personAtom;
private JSONStorable clothingItemStorable;
public override void Init()
{
var loadButton1 = CreateButton("Load 1", true);
loadButton1.button.onClick.AddListener(LoadPresets1);
var loadButton2 = CreateButton("Load 2", true);
loadButton2.button.onClick.AddListener(LoadPresets2);
var loadButton3 = CreateButton("Load 3", true);
loadButton3.button.onClick.AddListener(LoadPresets3);
var loadButton4 = CreateButton("Load Default", true);
loadButton4.button.onClick.AddListener(LoadDefault);
var saveButton1 = CreateButton("Save 1");
saveButton1.button.onClick.AddListener(SavePresets1);
var saveButton2 = CreateButton("Save 2");
saveButton2.button.onClick.AddListener(SavePresets2);
var saveButton3 = CreateButton("Save 3");
saveButton3.button.onClick.AddListener(SavePresets3);
// Find the 'Person' atom
Atom personAtom = SuperController.singleton.GetAtomByUid("Person");
// Get the storable with ID "[creator:itemNameMaterialMaterialName]"
clothingItemStorable = personAtom.GetStorableByID("[creator:itemNameMaterialMaterialName]");
}
private void LoadPresets1()
{
if (clothingItemStorable != null)
{
clothingItemStorable.RestoreFromStore1();
}
else
{
SuperController.LogMessage("not found");
}
}
private void LoadPresets2()
{
if (clothingItemStorable != null)
{
clothingItemStorable.RestoreFromStore2();
}
else
{
SuperController.LogMessage("not found");
}
}
private void LoadPresets3()
{
if (clothingItemStorable != null)
{
clothingItemStorable.RestoreFromStore3();
}
else
{
SuperController.LogMessage("not found");
}
}
private void LoadDefault()
{
if (clothingItemStorable != null)
{
clothingItemStorable.RestoreAllFromDefaults();
}
else
{
SuperController.LogMessage("not found");
}
}
private void SavePresets1()
{
if (clothingItemStorable != null)
{
clothingItemStorable.SaveToStore1();
}
else
{
SuperController.LogMessage("not found");
}
}
private void SavePresets2()
{
if (clothingItemStorable != null)
{
clothingItemStorable.SaveToStore2();
}
else
{
SuperController.LogMessage("not found");
}
}
private void SavePresets3()
{
if (clothingItemStorable != null)
{
clothingItemStorable.SaveToStore3();
}
else
{
SuperController.LogMessage("not found");
}
}
}