Give Page Feedback

Scriptable Assets - Scriptable Object Lock Monitor

The Scriptable Object Lock Monitor is an experimental concept that should hopefully enable development teams to support team based workflows in a limited way. At present, the Lock Monitor is only supported for Streamable Grids while working with the World Designer Tool. Since we do not work with a team based workflow, the concept of the Lock Monitor cannot be tested by us. Please feel free to provide feedback regarding the monitor as to its usefulness or ways to improve it (or suggest alternative solutions).

The basic idea is, whenever a team member wants to work with specific World Groupings in a way that would write changes to its underlying Streamable Grid asset (enabling/disabling cells or changing the number of Asset Chunks each Cell uses), they need to check out the Streamable Grid asset and write lock it (so that modifications cannot be made to it by other team members). The actual mechanism for checking out and locking the Scriptable Asset is up to you. The only purpose the Lock Monitor serves is to tell the World Designer Tool whether the Streamable Grid has been write locked.

The Streamable Grid Lock Monitor is queried every time the user of the World Designer Tool tries to perform an action that could modify a Streamable Grid. The action is only allowed if the Lock Monitor indicates that the Streamable Grid is not locked. Locking the Streamable Grid should not result in other team members not being able to access the Streamable Grid asset, as doing so will stop the World Designer Tool from working. Instead, locking should simply stop other team members from being able to commit changes for the locked asset.

When To Lock

Developers should lock the Streamable Grid any time they anticipate their World Designer Use will result in modifications to the asset. The locking mechanism should function such that the Lock Monitor only shows the asset as locked for other developers, not the developer that has the asset checked out!

Creating A Lock Monitor

In order to create a custom Scriptable Object Lock Monitor, start by creating a new script with a class that derives from the ScriptableObjectLockMonitor base abstract class. You will need to add a using DeepSpaceLabs.EditorSAM; statement in order to use the ScriptableObjectLockMonitor class, and the script file you create needs to be placed inside a folder called Editor in order for it to see the DeepSpaceLabs.EditorSAM namespace.

--Special Note--
An easy way to start with your custom class is to hover over your custom class name and choose the option Show potential fixes -> Implement abstract class. This will provide default overrides for all abstract class members (1 method in total).

The IsWriteLocked method should be overridden to return a value that indicates whether the Scriptable Object asset passed into the method is currently write locked.

Creating A Lock Monitor (Generating the Asset)

Once you finish creating custom Scriptable Object Lock Monitor script, you will need to make an editor command to generate new instances of the Scriptable Asset within your project. To do so, create a static method inside some editor class that has the following attribute:

[MenuItem(GlobalValues.ASSET_CREATION_PATH + "Custom Lock Monitor Name", false)]

Within this method, you can use the following line of code to create the Scriptable Asset, replacing CustomLockMonitor with the class name of your Custom Lock Monitor.

ScriptableObjectAssetCreator.GenerateScriptableObjectAssetAtSelectedFolder("CustomLockMonitor");

ScriptableObjectAssetCreator is a special class found inside the DeepSpaceLabs.EditorCore namespace. You will need to add a using statement or type out the full namespace with the class name when declaring the variable in order to use it.

Assigning The Lock Monitor

The Streamable Grid Lock Monitor can be assigned to the Streamable Grid Lock Monitor field on the GlobalEditorSettings asset. You can find this asset in the Assets/Editor Default Resources/Deep Space Labs/SAM/ScriptableAssets folder. Once you assign the monitor, it will be used anytime you use the World Designer Tool. If you do not assign a Lock Monitor to this field, all Streamable Grids will be treated as unlocked at all times.