Glossary


The glossary is a place for you to look up a brief explanation of every aspect of SwiftTree.


Attribute Names

STAlias

If you have renamed a class, place STAlias in front of it with the old class name so that old data can still be loaded.

STChild

Place STChild before a class definition to specify a class that will become a child class. The child class can now be added to this class in the SwiftTree editor.

STClass

Place STClass in front of your class definition to make it available to the SwiftTree editor.

[STAlias("Place")]
[STClass("Area({VarValues})", "adventure", 1, true)]
[STChild(typeof(Interaction), "adventure")]
[STLink(typeof(Area), "adventure")]
class Area
{
    [STVar]
    public string UniqueName = "";
STLink

Place STLink before a class definition to specify a class that will become a linkable class. Links to the linkable class can now be added as children of this class in the SwiftTree editor. Linkable classes must have a [STVar] string UniqueName; in them so they can be referred to.

STVar

Place STVar in before any members you want to be editable from within the SwiftTree editor.


Method Names to implement

STAddChild

STAddChild is the method that is called on a class for each and every child of that class. An instance of the child class is passed as an object to this method.

public bool STAddChild (object child)
{
    bool success = false;
    if (child is DLGThread) 
    {
        mThreads.Add ((DLGThread)child);
        success = true;
    } 
    else
    {
        Logger.Error ("child object is a " + child.GetType () + " not a " + typeof(DLG_Thread) );
    }
    return success;
}

STAddLink

Very similar to STAddChild, STAddLink is the method that is called on a class for each and every link within that class. The single instance of the linked class will be passed as an object to this method for every class that has a link to it.

STCommit

The STCommit method is called on every class after they are all constructed and have finished being connected together by calling the STAddChild and STAddLink methods. That is, every class is constructed before the first class has STCommit called upon it. The parentObj parameter is not the immediate parent of the class, but the overall parent container class that was passed in to SwiftTree.Build.FromStrings(... , parentObj). So this could be null if the created objects don't need to know. If you want the child objects to know about their parent, then add your own SetParent(...) method to the child class and call it from STAddChild or STCommit.

void STCommit( object parentObj )
{
    // Perform commit operations here
}


Special Member Names

UniqueName

A special member name that is required in any class type that has been linked to using the STLink keyword.

UniqueNameOfLink

Reserved special member name for SwiftTree usage. It is used for linking classes together and should not be used.


Special String Commands for STClass

The following are all string sequences that will be replaced by the current values of your [STVar] members of your class. The string is the first parameter of the STClass attribute and is the string displayed in the inspector window for your SwiftTree for the relevant class

{0}, {1}... etc

Just like string.Format, this sequence will be replaced by the value of the first, second, third, ...etc STVar in your class.

{ClassName}

This will be replaced by the name of your class.

{VarPairs}

This will be replaced by the current values of all of your STVars, as a comma separated list of name=value pairs.

{VarValues}

This will be replaced by the current values of all of your STVars, as a comma separated list of values.


Utility Methods

The following are methods that will convert your SwiftTree data into instances of your classes

SwiftTree.Build.FromStrings(...)

This will construct your objects from the array of strings that is your SwiftTree data. e.g. List<object> myObjs = SwiftTree.Build.FromStrings( mySwiftTree.swiftTreeText.lines );

SwiftTree.Build.LoadFileAsStrings(...)

This will use the standard file system to load a Unity asset text file and convert it to an array of strings for use with the SwiftTree.Build.FromStrings method. Use this only when your data needs to be loaded and used outside of the Unity system. e.g. Test code, alternative render framework or server code.


Big Bag of Bits
Big Bag of Bits