< All Topics

Attributes

When an Experior model is saved, data added to an Attributes object is saved together with the rest of the model data.

Example

The TestObject is an example of an object that is going to be saved:

(Note: The object has to be serializable)

[Serializable]
public class TestObject
{
    public TestObject()
    {
        private string text;
        public string Text
        {
            get { return text; }
            set { text = value; }
        }
        
        private int count;
        public int Count
        {
            get { return count; }
            set { count = value; }
        }
    }
}

Now create an instance of the TestObject class.

TestObject test = new TestObject();
test.Count = 100;
test.Text = "Hello";

And an instance of the Attribute class and then add the instance of the TestObject. The name Test1 is used to identify the object when the model is reloaded or whenever you want to get hold of the object.

Core.Environment.Scene.Attributes attributes = new Core.Environment.Scene.Attributes();
attributes.Add("Test1", test);

The test object can at any time be removed by disposing the attribute object or by calling the static method Remove.

attributes.Dispose();

or

Core.Environment.Scene.Attributes.Remove(this.Name);
Was this article helpful?
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
Next Environment Properties