Hi!
I am developing a plugin and want to persist a couple of properties with the layout when the file is saved.
The approach I chose based on API documentation is
- Create a custom Layout Item
- Create necessary properties within the given Layout Item
- Make Layout Item persistent
Problem: while there are no build errors, when I run the code it seems ISimWorld.CreateLayoutItem() method fails to create the Layout Item: the method returns null, and also when I search for the given item by name the find method returns null.
the code snippet and definitions are below.
Utils.MEV_SETTINGS_LI is a string constant to hold the layout item name.
Did I understand the Layout Item wrong?
IApplication app = IoC.Get<IApplication>();
ISimWorld simWorld = app.World;
IProperty prop;
ILayoutItem mev_li_item = null;
string path = "valid_path";
mev_li_item = simWorld.CreateLayoutItem<ILayoutItem>(Utils.MEV_SETTINGS_LI);
prop = mev_li_item.CreateProperty(path.GetType(),PropertyConstraintType.AllValuesAllowed,"Path"); //Property to store path to the model
if (prop != null) { prop.Value = path; }
mev_li_item.IsPersistent = true;