Browse Source

More work on documentation

BearishSun 8 years ago
parent
commit
5c8a8ab593
27 changed files with 642 additions and 478 deletions
  1. 4 0
      Documentation/GitHub/dependencies.md
  2. 3 1
      Documentation/Manuals/Native/manuals.md
  3. 270 0
      Documentation/Manuals/Native/mono.md
  4. 220 0
      Documentation/Manuals/Native/scriptObjects.md
  5. 0 332
      Documentation/Manuals/Native/scripting.md
  6. 3 3
      Source/BansheeMono/Include/BsMonoField.h
  7. 3 3
      Source/BansheeMono/Source/BsMonoField.cpp
  8. 4 4
      Source/SBansheeEditor/Source/BsMenuItemManager.cpp
  9. 3 3
      Source/SBansheeEditor/Source/BsScriptDropDownWindow.cpp
  10. 4 4
      Source/SBansheeEditor/Source/BsScriptEditorWindow.cpp
  11. 1 1
      Source/SBansheeEditor/Source/BsScriptGizmoManager.cpp
  12. 1 1
      Source/SBansheeEditor/Source/BsScriptHandleManager.cpp
  13. 8 8
      Source/SBansheeEditor/Source/BsScriptImportOptions.cpp
  14. 1 1
      Source/SBansheeEditor/Source/BsScriptInspectorUtility.cpp
  15. 2 2
      Source/SBansheeEditor/Source/BsScriptModalWindow.cpp
  16. 6 6
      Source/SBansheeEditor/Source/BsToolbarItemManager.cpp
  17. 4 4
      Source/SBansheeEngine/Include/BsScriptObject.h
  18. 10 10
      Source/SBansheeEngine/Source/BsManagedSerializableObjectInfo.cpp
  19. 7 7
      Source/SBansheeEngine/Source/BsScriptAnimation.cpp
  20. 2 2
      Source/SBansheeEngine/Source/BsScriptAnimationClip.cpp
  21. 18 18
      Source/SBansheeEngine/Source/BsScriptAnimationCurves.cpp
  22. 3 3
      Source/SBansheeEngine/Source/BsScriptGUIContent.cpp
  23. 2 2
      Source/SBansheeEngine/Source/BsScriptGUIContentImages.cpp
  24. 1 1
      Source/SBansheeEngine/Source/BsScriptGUIWidget.cpp
  25. 58 58
      Source/SBansheeEngine/Source/BsScriptPostProcessSettings.cpp
  26. 1 1
      Source/SBansheeEngine/Source/BsScriptSerializableObject.cpp
  27. 3 3
      Source/SBansheeEngine/Source/BsScriptSkeleton.cpp

+ 4 - 0
Documentation/GitHub/dependencies.md

@@ -193,6 +193,10 @@ If the library structure still isn't clear, download one of the pre-compiled dep
     - OSDependent.lib (Compile using "release" configuration)
     - OSDependentd.lib (Compile using "debug" configuration)
    
+**XShaderCompiler**
+- Distributed with Banshee source in Source/External/XShaderCompiler
+- Required by BansheeSL
+   
 **bison**
 - Bison 2.7
 - http://sourceforge.net/projects/winflexbison/files/

+ 3 - 1
Documentation/Manuals/Native/manuals.md

@@ -107,7 +107,9 @@ A set of manuals covering advanced functionality intented for those wanting to e
  - [Creating custom importers](@ref customImporters)
 - **Scripting**
  - [Exposing code to script API (automated)](@ref scriptingAuto)
- - [TODO - Exposing code to script API (manual)](@ref scripting)
+ - **Exposing code to script API (manually)**
+  - [Interacting with the script runtime](@ref mono)
+  - [Script objects](@ref scriptObjects)
  
 ## General guides
 Name                                      | Description

+ 270 - 0
Documentation/Manuals/Native/mono.md

@@ -0,0 +1,270 @@
+Interacting with the script runtime									{#mono}
+===============
+[TOC]
+
+In the previous chapter we talked about how to expose a C++ type to the scripting API by using the script binding generator tool. This tool ensures you can generate script bindings easily, but in some cases it is not robust enough and you must interact with the scripting API manually. This manual will explain how to interact with the scripting API and expose C++ code to it manually (without the script binding generator tool). 
+
+You can use manual generation to achieve everything as with the script binding generator tool (in fact this tool uses the same API as described in this manual), plus a lot more. It is preferred you use automatic generation whenever possible, but when working with lower level systems that closely interact with the scripting system (like serialization, script compilation, etc.) you need more direct access.
+
+All C# script code is executed using the Mono runtime. Mono runtime allows you to communicate with C# code and vice-versa by invoking methods and querying class/method/field information. In this section we'll focus on how to interact with Mono (and therefore the C# runtime).
+
+# MonoManager {#mono_a}
+BansheeMono is a plugin that wraps the functionality of the Mono runtime. The main entry point of the scripting system is the @ref bs::MonoManager "MonoManager" class which allows you to start the runtime and load managed (script) assemblies. The most important method here is @ref bs::MonoManager::loadAssembly "MonoManager::loadAssembly()". It loads all the script code from the managed assembly (.dll) at the provided path, and provides meta-data for the entire assembly through the returned @ref bs::MonoAssembly "MonoAssembly" object. 
+
+~~~~~~~~~~~~~{.cpp}
+// Loads the MyManagedAssembly.dll
+MonoAssembly& assembly = MonoManager::instance().loadAssembly("Path/To/Assembly", "MyManagedAssembly");
+~~~~~~~~~~~~~ 
+
+In most cases Banshee will load all the necessary assemblies for you, in which case you can just retrieve them by calling @ref bs::MonoManager::getAssembly "MonoManager::getAssembly()".
+
+~~~~~~~~~~~~~{.cpp}
+// Retrieve the MonoAssembly to a previously loaded assembly
+MonoAssembly* assembly = MonoManager::instance().getAssembly("MyManagedAssembly");
+~~~~~~~~~~~~~ 
+
+# MonoAssembly 	{#mono_b}
+**MonoAssembly** gives you access to all the script classes in an assembly. You can retrieve all clases using @ref bs::MonoAssembly::getAllClasses "MonoAssembly::getAllClasses()", or retrieve a specific one by calling @ref bs::MonoAssembly::getClass(const String&, const String&) const "MonoAssembly::getClass(const String& namespace, const String& typename)". Both of these methods return a @ref bs::MonoClass "MonoClass" object.
+
+~~~~~~~~~~~~~{.cpp}
+// Retrieve information about a C# class MyNamespace::MyClass
+MonoClass* klass = assembly->getClass("MyNamespace", "MyClass");
+~~~~~~~~~~~~~ 
+
+# MonoClass 	{#mono_c}
+**MonoClass** gives you access to all methods, fields, properties and attributes of a specific class. It also allows you to register "internal" methods. These methods allow the managed code to call C++ code, and we'll go into them later.
+
+Classes also allow you to create object instances of their type. Use @ref bs::MonoClass::createInstance "MonoClass::createInstance()" to create a new object instance. This method returns a **MonoObject** instance, which is a C++ representation of the C# object, but more on them later. When creating an instance you may choose whether to construct it or not, and to provide constructor signature if you need a specific one.
+
+~~~~~~~~~~~~~{.cpp}
+// Create a new instance of the managed class using the parameterless constructor
+MonoObject* instance = klass->createInstance();
+
+// Create a new instance of the managed class using parameter count to differentiate between different constructors
+UINT32 paramA = 3;
+UINT32 paramB = 10;
+bool paramC = false;
+
+void* params[3] = { &paramA, &paramB, &paramC };
+
+//// Invoke a constructor accepting three parameters (Behaviour undefined if there are multiple)
+MonoObject* instance2 = klass->createInstance(params, 3);
+
+// Create a new instance of the managed class using a specific constructor signature
+MonoObject* instance3 = klass->createInstance("int,int,bool", params);
+~~~~~~~~~~~~~
+
+When passing arguments to constructors (and methods in general) you need to place the correct number of parameters in a array of *void* pointers, which you then pass to the invoking method. We'll talk more about how to pass arguments to methods later.
+
+To retrieve a method from a class call @ref bs::MonoClass::getMethod() "MonoClass::getMethod()", accepting a name (without parameter types) and a number of parameters. If your method is overloaded you can use @ref bs::MonoClass::getMethodExact "MonoClass:getMethodExact()" which accepts a method name, and a comma separated list of parameter types. You may also use @ref bs::MonoClass::getAllMethods "MonoClass::getAllMethods()" to retrieve all methods in a class. All three of these methods return a @ref bs::MonoMethod "MonoMethod" object.
+
+~~~~~~~~~~~~~{.cpp}
+// Get method on the class named "MyMethod", accepting zero parameters
+MonoMethod* myMethod = klass->getMethod("MyMethod", 0);
+
+// Get method on the class named "MyMethod" with a specific signature
+MonoMethod* myMethod2 = klass->getMethodExact("MyMethod", "single,int");
+~~~~~~~~~~~~~
+
+# MonoMethod {#mono_d}
+**MonoMethod** class provides information about about a managed method, as well as giving you multiple ways of invoking it (i.e. calling C# methods from C++).
+
+To invoke a method you may use multiple approaches:
+ - @ref bs::MonoMethod::invoke "MonoMethod::invoke()" - Invokes the exact method to exact type it was retrieved from.
+ - @ref bs::MonoMethod::invokeVirtual "MonoMethod::invokeVirtual()" - Invokes the method polymorphically, meaning it determines the actual type of the provided managed object instance and calls an overriden method if available.
+ - @ref bs::MonoMethod::getThunk "MonoMethod::getThunk()" - Returns a C++ function pointer that can be used for invoking the method, same as you would any C++ function. This is equivalent to **MonoMethod::invoke()** but is significantly faster. A helper method @ref bs::MonoUtil::invokeThunk<T, Args> "MonoUtil::invokeThunk()" is provided - it is suggested you use it instead of calling thunks manually  because it handles exceptions internally.
+
+All method invocation types follow a similar format:
+ - First parameter is always a **MonoObject** which corresponds to the instance of the class to execute the method on. If a method is static this should be null.
+ - A list of parameters in the form of an array of *void* pointers, except for thunks which accept parameters as a normal function call.
+ - A return value of the type MonoObject*. Non-class types like *int* or *float* will be boxed into objects and must be unboxed in order to retrieve their values. More about boxing/unboxing later.
+ - Thunks always output a pointer to **MonoException** as their last parameter. You do not need to handle this manually, but you need to be aware it exists when defining the function pointer signature.
+
+~~~~~~~~~~~~~{.cpp}
+// Invoke MyMethod overload with no parameters, on the class instance we created earlier
+myMethod->invoke(instance, nullptr);
+
+// Invoke MyMethod overload with float and int parameters, on the class instance we created earlier
+float paramA = 1.5f;
+UINT32 paramB = 10;
+
+void* params[2] = { &paramA, &paramB };
+myMethod2->invoke(instance, params);
+
+// Invoke some static method with no parameters
+MonoMethod* someStaticMethod = ...;
+someStaticMethod->invoke(nullptr, nullptr);
+
+// Get a method thunk for MyMethod overload with two parameters, and invoke it
+typedef void(__stdcall *MyMethodThunkDef)(float, UINT32, MonoException**);
+MyMethodThunkDef myMethodThunk = (MyMethodThunkDef)myMethod2->getThunk();
+
+MonoUtil::invokeThunk(myMethodThunk, 1.5f, 10);
+~~~~~~~~~~~~~
+ 
+# MonoField {#mono_e}
+Similar to methods, field information can be retrieved from a **MonoClass** object by calling @ref bs::MonoClass::getField "MonoClass::getField()" or @ref bs::MonoClass::getAllFields "MonoClass::getAllFields()". The returned value is a @ref bs::MonoField "MonoField" which provides information about the field and allows you to retrieve and set values in the field using @ref bs::MonoField::get "MonoField::get()" / @ref bs::MonoField::set "MonoField::set()". 
+
+~~~~~~~~~~~~~{.cpp}
+// Read field value from a specific object instance
+MonoField* myField = klass->getField("myField");
+int myFieldValue;
+myField->get(instance, &myFieldValue);
+
+// Set a static field value
+MonoField* myStaticField = klass->getField("myStaticField");
+int newStaticFieldValue = 10;
+myStaticField->set(nullptr, &newStaticFieldValue)
+~~~~~~~~~~~~~
+
+Field values are represented by their raw types if they are value types (*int*, *float* or *struct* types in C#), and as **MonoObject** pointer for reference types.
+
+# MonoProperty {#mono_f}
+Properties are very similar to fields, retrieved from a **MonoClass** object by calling @ref bs::MonoClass::getProperty "MonoClass::getProperty()". The returned value is a @ref bs::MonoProperty "MonoProperty" which provides information about the property and allows you to retrieve and set values on it. The main difference is that properties in C# can be indexed (like arrays) and therefore a two set of set/get methods are provided, one accepting an index and other one not. It's up to the user to know which one to call. The methods are @ref bs::MonoProperty::get "MonoProperty::get()" / @ref bs::MonoProperty::set "MonoProperty::set()" and @ref bs::MonoProperty::getIndexed "MonoProperty::getIndexed()" / @ref bs::MonoProperty::setIndexed "MonoProperty::setIndexed()".
+
+~~~~~~~~~~~~~{.cpp}
+// Read property value from a specific object instance
+MonoProperty* myProperty = klass->getProperty("myProperty");
+int myPropertyValue;
+myProperty->get(instance, &myPropertyValue);
+
+// Set a static property value
+MonoProperty* myStaticProperty = klass->getProperty("myStaticProperty");
+int newStaticPropertyValue = 10;
+myStaticProperty->set(nullptr, &newStaticPropertyValue)
+
+// Read property value from an indexed property
+MonoProperty* myIndexedProperty = klass->getProperty("myIndexedProperty");
+MonoObject* returnVal = myProperty->getIndexed(instance, 5);
+~~~~~~~~~~~~~
+
+Note that indexed properties always return a boxed object in the form of **MonoObject**, whether the object is a value or reference type.
+
+# Attributes {#mono_g}
+Attributes provide data about a class, method or field provided at runtime, which usually allows such objects to be specialized in some regard. Attributes don't have their own wrapper, because they are esentially normal managed objects and you can work with them as such.
+
+To retrieve a list of attributes from a class use @ref bs::MonoClass::getAllAttributes() "MonoClass::getAllAttributes()", which returns a list of **MonoClass** objects that identify the attribute types. To get the actual object instance of the attribute you may call @ref bs::MonoClass::getAttribute "MonoClass::getAttribute()" with the wanted attribute's **MonoClass**. After that you can call methods, work with field values and similar, same as you would with a normal managed object.
+
+Attributes can also be retrieved from a **MonoMethod** by using @ref bs::MonoMethod::getAttribute "MonoMethod::getAttribute()", or from **MonoField** by using @ref bs::MonoField::getAttribute "MonoField::getAttribute()".
+
+~~~~~~~~~~~~~{.cpp}
+// Retrieve class of the attribute, same as for normal classes
+MonoClass* attributeClass = ...;
+
+// Check if our class has this attribute
+MonoObject* attributeObj = klass->getAttribute(attributeClass);
+if(attributeObj != nullptr)
+{
+	// Class has the attribute. This can be enough information or we can choose to read attribute fields same as described above.
+}
+~~~~~~~~~~~~~
+
+# Managed objects {#mono_h}
+All objects (more specifically *class*%es) in C# are represented as **MonoObject** in C++, as we already mentioned. There are also two more specialized types of managed objects: **MonoArray** for managed arrays, and **MonoString** for managed strings.
+
+Be aware that all managed objects are garbage collected. This means you should not keep a reference to them in C++ code unless you are sure they are alive. Just having a pointer to a **MonoObject** will not keep the object alive and it may go out of scope as soon as the control returns to managed code. A good way to deal with this issue is:
+ - Call a C++ method in the object's finalizer (`~MyObject()`) which will notify you when the object is no longer valid. Be aware that finalizer may be called after the object is unusable.
+ - Require the user to manually destroy the object by calling a custom **Destroy** method or similar. At which point you would notify the C++ code that the object is destroyed.
+ - Force the garbage collector to keep the object alive by calling @ref bs::MonoUtil::newGCHandle "MonoUtil::newGCHandle()" which will return a handle to the object. The handle will keep the object alive until you release it by calling @ref bs::MonoUtil::freeGCHandle "MonoUtil::freeGCHandle()". Be aware if an assembly the object belongs to is unloaded all objects will be destroyed regardless of kept handles.
+ 
+~~~~~~~~~~~~~{.cpp}
+// Create to retrieve instance to some managed object
+MonoObject* instance = ...;
+ 
+UINT32 handle = MonoUtil::newGCHandle(instance);
+// We can now safely return control to managed code, without having to worry about the object being garbage collected
+ 
+// At some point you must release the handle
+MonoUtil::freeGCHandle(handle);
+~~~~~~~~~~~~~ 
+ 
+# Marshalling data {#mono_i}
+We have shown the basics of how to call methods and send them arguments, as well as receive return values. However there is more to it, as there is a specific set of rules of how values must be passed between C++/C#. These rules depend on the type of the value passed:
+ - All primitive types are passed as is. e.g. an *int* in C# will be a 4 byte integer in C++, a *float* will be a float, a *bool* will be a bool.
+ - All reference types (*class* in C#) are passed as a pointer to a **MonoObject**. Strings and arrays are handled specially, where strings are passed as pointers to **MonoString**, and arrays as pointers to **MonoArray**.
+   - If a reference type parameter in a method in managed code is prefixed with an *out* modifier, then the received parameters are a double pointer to **MonoObject**, **MonoString** and **MonoArray**.
+ - Structs (non-primitive value types, **struct** in C#) are provided as raw memory. Make sure that all structs in C# that require marshalling have a `[StructLayout(LayoutKind.Sequential)]` attribute, which ensures they have the same memory layout as C++ structs. This way you can just accept the raw C++ structure and read it with no additional conversion.
+  - It is suggested you never pass structures by value, it is known to cause problems in Mono. Instead pass all structures by prefixing them with *ref* which will give you a pointer to the structure (e.g. `MyStruct*`). If you need to output a struct use the *out* modifier which you will give you a double pointer (e.g. `MyStruct**`).
+  - In cases where it is not possible to avoid passing structures by value (e.g. when retrieving them from a field, use the @ref bs::MonoField::getBoxed "MonoField::getBoxed()" method instead **MonoField::get**, which will return a struct in the form of a **MonoObject**.
+  - Everything above applies only when managed code is calling C++. When doing the opposite, i.e. calling into managed code from C++, all structs need to be boxed (i.e. converted to **MonoObject**). 
+
+## Boxing / Unboxing  {#mono_i_a}
+Boxing is the process of "wrapping" a value-type (e.g. *int*, *float*, custom *struct* type) in a reference, so it can be represented by a **MonoObject**. Normally value types are passed around directly by value or pointer, but sometimes it is necessary to box them. When you receive a boxed value you can unbox it to its original state by calling @ref bs::MonoUtil::unbox "MonoUtil::unbox()".
+
+~~~~~~~~~~~~~{.cpp}
+// Retrieve some property, assume its static, indexed and is of type int
+MonoProperty* property = ...;
+
+// Read a value from the property
+MonoObject* boxedValue = property->getIndexed(nullptr, 0);
+
+// Unbox the object back into an integer
+UINT32 value = *(UINT32*)MonoUtil::unbox(boxedValue);
+~~~~~~~~~~~~~ 
+
+Sometimes you have an unboxed value but C# requires an object. In that case you can box a value by calling @ref bs::MonoUtil::box "MonoUtil::box()".
+~~~~~~~~~~~~~{.cpp}
+int value = 5;
+MonoObject* boxedValue = MonoUtil::box(MonoUtil::getUINT32Class(), &value);
+~~~~~~~~~~~~~ 
+
+Note that the first parameter of **MonoUtil::box()** is a **MonoClass** of the type you want to box. If this is a custom type you can retrieve it as we described above. If it is a builtin type you can check @ref bs::MonoUtil "MonoUtil" methods like @ref bs::MonoUtil::getUINT32Class "MonoUtil::getUINT32Class()" or @ref bs::MonoUtil::getFloatClass() "MonoUtil::getFloatClass()".
+  
+## Strings {#mono_i_b}
+Banshee provides a helper code to assist with marshalling strings:
+ - @ref bs::MonoUtil::monoToWString "MonoUtil::monoToWString" / @ref bs::MonoUtil::monoToString "MonoUtil::monoToString" - Converts a **MonoString** to a native string
+ - @ref bs::MonoUtil::wstringToMono "MonoUtil::wstringToMono" / @ref bs::MonoUtil::stringToMono "MonoUtil::stringToMono" - Converts a native string into a **MonoString**
+
+~~~~~~~~~~~~~{.cpp}
+// Convert a native string to managed and back
+MonoString* monoString = MonoUtil::stringToMono("My string");
+String nativeString = MonoUtil::monoToString(monoString);
+~~~~~~~~~~~~~ 
+
+## Arrays {#mono_i_c}
+@ref bs::ScriptArray "ScriptArray" is a helper class that allows you to construct new arrays and read managed arrays easily. 
+
+To create a new arrays call @ref bs::ScriptArray::create "ScriptArray<Type>::create()". Type can be a primitive type like *int*, *float*, a string or a `Script*` object (more about `Script*` objects later). You can then fill the array by calling @ref bs::ScriptArray::set "ScriptArray::set()" and retrieve the managed **MonoArray** by calling @ref bs::ScriptArray::getInternal "ScriptArray::getInternal()".
+
+~~~~~~~~~~~~~{.cpp}
+// Create a managed array of integers, with 10 elements
+ScriptArray outArray = ScriptArray::create<UINT32>(10);
+for(UINT32 i = 0; i < 10; i++)
+	outArray.set(i, 0);
+
+MonoArray* monoArray = outArray.getInternal();
+~~~~~~~~~~~~~ 
+
+You can easily read a **MonoArray** by creating a new **ScriptArray**, using the **MonoArray** in its constructor. Then you can retrieve the size of the array using @ref bs::ScriptArray::size() "ScriptArray::size()", and the value of its elements by calling @ref bs::ScriptArray::get "ScriptArray::get<Type>()". 
+
+~~~~~~~~~~~~~{.cpp}
+// Read-back the array above into a Vector
+ScriptArray inArray(monoArray);
+
+Vector<UINT32> output(inArray.size());
+for(UINT32 i = 0; i < inArray.size(); i++)
+	output[i] = inArray.get<UINT32>(i);
+~~~~~~~~~~~~~ 
+
+# Internal methods {#mono_j}
+So far we have talked about calling managed code, and retrieving information about managed types, but we have yet to show how managed code calls C++ code. This is accomplished using internal methods.
+
+The first step is to define a stub method in managed code, like so:
+~~~~~~~~~~~~~{.cs}
+[MethodImpl(MethodImplOptions.InternalCall)]
+private static extern float Internal_GetSomeValue(MyObject obj);
+~~~~~~~~~~~~~
+	
+You then hook up this method with managed code by calling @ref bs::MonoClass::addInternalCall "MonoClass::addInternalCall". In this specific case it would be:
+~~~~~~~~~~~~~{.cpp}
+float myNativeFunction(MonoObject* obj)
+{
+	// Do something
+}
+
+klass->addInternalCall("Internal_GetSomeValue", &myNativeFunction);
+~~~~~~~~~~~~~
+
+After this is done any call to the managed stub method will call the provided native function. You should take care to properly handle parameter passing as described above.
+
+> Note that internal methods cannot be overloaded and each must have a unique name.

+ 220 - 0
Documentation/Manuals/Native/scriptObjects.md

@@ -0,0 +1,220 @@
+Script objects									{#scriptObjects}
+===============
+[TOC]
+
+What we have shown in the previous manual is enough to expose an object to C# and communicate with it. However Banshee provides another API built on top of that functionality in the form of script objects. This API handles some of the boilerplate code required for exposing an object to C#, provides a common interface all script objects need to implement, handles assembly refresh (due to script hot-swap) and gracefully handles managed object lifetime and destruction.
+
+To implement the script object interface for a particular type you need two classes:
+ - A native interop class (C++)
+ - Managed wrapper class for the type (C#)
+
+# Native interop class {#scriptObjects_a}
+This class is intended as a wrapper for the C++ class you're exposing to the scripting API. It will contain all the code needed for C++/C# interop. All such native interop objects must implement the @ref bs::ScriptObject<T> "ScriptObject<T>" interface. The template parameter should be the type of the interop class itself. The implementation of the class must begin with @ref SCRIPT_OBJ macro. The macro accepts (in order): 
+ - the name of the assembly (.dll) the managed wrapper class is in, this is usually `ENGINE_ASSEMBLY` or `EDITOR_ASSEMBLY`
+ - the namespace the managed wrapper class
+ - the name of the managed wrapper class
+ 
+**ScriptObject** constructor accepts a **MonoObject** which must contain the managed instance of the object and should be provided when the script object is created. If a script object is wrapping a static class, then the constructor is of no relevance as the script object will never be constructed (but still needs to be present).
+
+~~~~~~~~~~~~~{.cpp}
+class ScriptMyObject : public ScriptObject <ScriptMyObject>
+{
+public:
+	SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "MyObject")
+
+	ScriptMyObject(MonoObject* instance)
+		:ScriptObject(instance)
+	{ }
+};
+~~~~~~~~~~~~~	
+
+**SCRIPT_OBJ** macro defines a static **initRuntimeData()** method you need to implement. In this method you want to take care of hooking up managed internal methods to C++ functions. It gets called automatically on startup and whenever the assembly containing the related managed class is loaded. 
+
+Every **ScriptObject** provides a static @ref bs::ScriptObject<Type, Base>::getMetaData "metaData" structure you can use for retrieving the **MonoClass** of the related managed class. You can use that **MonoClass** to register internal methods to it (as described earlier). 
+~~~~~~~~~~~~~{.cpp}
+class ScriptMyObject : public ScriptObject <ScriptMyObject>
+{
+	// Other code ...
+	
+	static void internal_CreateInstance(MonoObject* obj);
+	static float internal_GetSomeValue(MonoObject* obj);
+	static void internal_SetSomeObject(MonoObject* obj);
+};
+
+void ScriptMyObject::initRuntimeData()
+{
+	metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptMyObject::internal_CreateInstance);
+	metaData.scriptClass->addInternalCall("Internal_GetSomeValue", &ScriptMyObject::internal_GetSomeValue);
+	metaData.scriptClass->addInternalCall("Internal_SetSomeObject", &ScriptMyObject::internal_SetSomeObject);
+}
+~~~~~~~~~~~~~
+
+**initRuntimeData()** is also a good spot to retrieve **MonoMethod**%s (or thunks) for managed methods that needed to be called by the script interop object, if any.
+
+## Creating script object instances {#scriptObjects_a_a}	
+If your class is not static you will need to eventually create an instance of the script object. This can be done either from C# or C++, depending on what is needed. For example script interop objects for GUI will be created from managed code because user can add GUI elements himself, but a resource like **Font** will have its script interop object (and managed instance) created purely from C++ because such an object cannot be created directly in managed code.
+
+For the first case you should set up an internal method that accepts the managed object instance, and is called in the managed constructor. This way the method gets called whenever the managed object gets created and you can create the related script interop object.
+~~~~~~~~~~~~~{.cpp}
+// This method should be called from the managed object's constructor, with "this" object as the parameter
+void ScriptMyObject::internal_CreateInstance(MonoObject* obj)
+{
+	// No need to store the created value anywhere, the system will clean it up automatically when the managed object is destroyed
+	bs_new<ScriptMyObject>(obj);
+}
+~~~~~~~~~~~~~
+	
+For the second case where you want to create the interop object from C++ you can create a static *create()* method like so:
+~~~~~~~~~~~~~{.cpp}
+MonoObject* ScriptMyObject::create()
+{
+	MonoObject* managedObj = metaData.scriptClass->createInstance();
+	bs_new<ScriptMyObject>(managedObj);
+	
+	return managedObj;
+}
+~~~~~~~~~~~~~
+	
+If you ever receive a **MonoObject** of the type you know that has a **ScriptObject** implemented, you can retrieve it by calling @ref bs::ScriptObject::toNative(MonoObject*) "ScriptObject::toNative(MonoObject*)" static method. 
+~~~~~~~~~~~~~{.cpp}
+void ScriptMyObject::internal_SetSomeObject(MonoObject* obj)
+{
+	ScriptSomeObject* someObj = ScriptSomeObject::toNative(obj);
+}
+~~~~~~~~~~~~~
+
+And vice versa, you can retrieve the **MonoObject** from a **ScriptObject** by calling @ref bs::ScriptObjectBase::getManagedInstance() "ScriptObject::getManagedInstance()".
+~~~~~~~~~~~~~{.cpp}
+ScriptMyObject myObj = ...;
+MonoObject* monoObj = myObj->getManagedInstance();
+~~~~~~~~~~~~~
+
+## Destroying script object instances ### {#scripting_a_b}
+When the managed object is destroyed (e.g. goes out of scope and gets garbage collected) the system will automatically take care of freeing the related **ScriptObject**. If you need to add onto or replace that functionality you can override @ref bs::ScriptObjectBase::_onManagedInstanceDeleted "ScriptObject::_onManagedInstanceDeleted()" method. This is useful if you need to perform some additional cleanup.
+
+# Managed wrapper object ## {#scripting_b}
+Creating the script interop class is one half of the job done. You also need to create the managed counterpart, however that is significantly simpler.
+
+Every managed script object must implement the **ScriptObject** interface. For example a C# version of the class we're using in this example would look like:
+~~~~~~~~~~~~~{.cs}
+namespace BansheeEngine
+{
+	public class MyObject : ScriptObject
+	{
+		public MyObject()
+		{
+			Internal_CreateInstance(this)
+		}
+		
+		public float SomeValue
+		{
+			get { return Internal_GetSomeValue(this); }
+		}
+		
+		[MethodImpl(MethodImplOptions.InternalCall)]
+		private static extern void Internal_CreateInstance(MyObject obj);
+		
+		[MethodImpl(MethodImplOptions.InternalCall)]
+		private static extern float Internal_GetSomeValue(MyObject obj);
+		
+		[MethodImpl(MethodImplOptions.InternalCall)]
+		private static extern void internal_SetSomeObject(SomeObject obj);
+	}
+}
+~~~~~~~~~~~~~
+
+That's all that needs to be done. You can now create the object in C# and use its property to retrieve the value from C++ code.
+
+All managed **ScriptObject**%s provide a **ScriptObject::GetCachedPtr()** method which returns an **IntPtr** which points to the script interop object described in previous sections. This can be used for passing a reference to the **ScriptObject** directly, rather than passing a **MonoObject** which then needs to be converted to **ScriptObject**.
+
+For example, if we change the *Internal_GetSomeValue()* method in the example above to use this approach, it would look like so:
+~~~~~~~~~~~~~{.cs}
+namespace BansheeEngine
+{
+	public float SomeValue
+	{
+		get { return Internal_GetSomeValue(GetCachedPtr()); }
+	}
+
+	public class MyObject : ScriptObject
+	{
+		[MethodImpl(MethodImplOptions.InternalCall)]
+		private static extern float Internal_GetSomeValue(IntPtr obj);
+	}
+}
+~~~~~~~~~~~~~
+
+And the corresponding C++ function would then accept the script object directly:
+~~~~~~~~~~~~~{.cpp}
+float ScriptMyObject::internal_GetSomeValue(ScriptMyObject* obj)
+{
+	// No need to convert from MonoObject to ScriptMyObject
+}
+~~~~~~~~~~~~~
+
+# Assembly refresh {#scripting_c}
+Assembly refresh is the process that happens when managed code is recompiled and scripts need to be reloaded. This is primarily used in Banshee editor to hot-reload the scripts while the editor is still running. When assembly refresh happens all managed objects are effectively destroyed.
+
+By default any script objects of such managed objects are destroyed as well. In many cases this is okay, for example GUI elements don't persist refresh, because they're just rebuilt from the managed code every time the refresh happens. However objects like resources, scene objects and components are persistent - we don't wish to reload the entire scene and all resources every time assembly refresh happens.
+
+In order to make your script objects persist through refresh you need to inherit from a variation of **ScriptObject** that as its second template parameter takes a @ref bs::PersistentScriptObjectBase "PersistentScriptObjectBase".
+
+~~~~~~~~~~~~~{.cpp}
+class MyScriptObject : public ScriptObject<MyScriptObject, PersistentScriptObjectBase>
+{
+	...
+};
+~~~~~~~~~~~~~	
+	
+This ensures that your object is treated properly during assembly refresh. Persistent object then needs to handle four different actions, represented by overrideable methods. These methods are called in order specified, during assembly refresh.
+ - @ref bs::ScriptObjectBase::beginRefresh() "ScriptObject::beginRefresh()" - Called just before the refresh starts. The object is still alive here and you can perform needed actions (e.g. saving managed object's contents).
+ - @ref bs::ScriptObjectBase::_onManagedInstanceDeleted "ScriptObject::_onManagedInstanceDeleted()" - Called after assembly unload happened and the managed object was destroyed. You should override this to prevent the **ScriptObject** itself from being deleted if the assembly refresh is in progress. If assembly refresh is not in progress this method should delete the **ScriptObject** as it likely got called due to standard reasons (managed object went out of scope).
+ - @ref bs::ScriptObject::_createManagedInstance "ScriptObject::_createManagedInstance()" - Creates the managed instance after new assemblies are loaded. You should override this if your managed class is constructed using a constructor with parameters. By default this will call **MonoClass::createInstance()** using the parameterless constructor.
+ - @ref bs::ScriptObjectBase::endRefresh() "ScriptObject::endRefresh()" - Called after all assemblies are loaded, and after all script interop objects were either destroyed (non-persistent) or had their managed instances re-created (persistent). If you stored any data during **ScriptObject::beginRefresh()**, you should restore it here.
+ 
+# Deriving from ScriptObject {#scripting_d}
+Sometimes script objects are polymorphic. For example a **GUIElement** is derived from **ScriptObject** in managed code, and **GUIButton** is derived from **GUIElement**, however they both have script interop objects of their own.
+
+Due to the nature of how our script interop objects are defined we cannot follow the same simple chain of inheritance in C++ code. For example class definition for script interop object for **GUIElement** would be:
+~~~~~~~~~~~~~{.cpp}
+class ScriptGUIElement : public ScriptObject<ScriptGUIElement>
+{
+public:
+	SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "GUIElement")
+...
+}
+~~~~~~~~~~~~~	
+	
+But what would it be for **GUIButton**? It also needs to implement **ScriptObject** with its own **SCRIPT_OBJ** macro so we cannot just inherit from **ScriptGUIElement** directly as it would clash.
+
+The solution is to create a third class that will serve as a base for both. This third class will be a base class for **ScriptObject** (its second template parameter allows us to override its default **ScriptObjectBase** base class). The third class will need to inherit @ref bs::ScriptObjectBase "ScriptObjectBase" and can implement any functionality common to all GUI elements (e.g. it might store a pointer to a native **GUIElement**).
+
+Provided our common base class is defined as such:
+~~~~~~~~~~~~~{.cpp}
+class ScriptGUIElementBase : public ScriptObjectBase
+{
+	// Functionality common to all GUI elements
+};
+~~~~~~~~~~~~~
+
+Then we can define script interop object for **GUIElement** as:
+~~~~~~~~~~~~~{.cpp}
+class ScriptGUIElement : public ScriptObject<ScriptGUIElement, ScriptGUIElementBase>
+{
+public:
+	SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "GUIElement")
+...
+};
+~~~~~~~~~~~~~
+
+And interop object for **GUIButton** would then be:
+~~~~~~~~~~~~~{.cpp}
+class ScriptGUIButton : public ScriptObject<ScriptGUIButton, ScriptGUIElementBase>
+{
+public:
+	SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "GUIButton")
+...
+};
+~~~~~~~~~~~~~	
+	
+This ensures that all GUI elements can now be accessed through the common **ScriptGUIElementBase** interface. Which is important if **GUIElement** provides some internal method calls shared between all GUI element types, otherwise we wouldn't know what to cast the interop object held by its managed object to.

+ 0 - 332
Documentation/Manuals/Native/scripting.md

@@ -1,332 +0,0 @@
-Scripting									{#scripting}
-===============
-[TOC]
-
-In the previous chapter we talked about how to expose a C++ type to the scripting API by using the script binding generator tool. This tool ensures you can generate script bindings easily, but in some cases it is not robust enough and you must interact with the scripting API manually. This manual will explain how to interact with the scripting API and expose C++ code to it manually (without the script binding generator tool). 
-
-You can use manual generation to achieve everything as with the script binding generator tool (in fact this tool uses the same API as described in this manual), plus a lot more. It is preferred you use automatic generation whenever possible, but when working with lower level systems that closely interact with the scripting system (like serialization, script compilation, etc.) you need more direct access.
-
-# Mono {#scripting_a}
-All C# script code is executed using the Mono runtime. Mono runtime allows you to communicate with C# code and vice-versa by invoking methods and querying class/method/field information. In this section we'll focus on how to interact with Mono (and therefore the C# runtime).
-
-BansheeMono is a plugin that wraps the functionality of the Mono runtime. The main entry point of the scripting system is the @ref bs::MonoManager "MonoManager" class which allows you to start the runtime and load managed (script) assemblies. The most important method here is @ref bs::MonoManager::loadAssembly "MonoManager::loadAssembly()". It loads all the script code from the managed assembly (.dll) at the provided path, and provides meta-data for the entire assembly through the returned @ref bs::MonoAssembly "MonoAssembly" object. 
-
-## MonoAssembly 	{#scripting_a_a}
-**MonoAssembly** gives you access to all the script classes in an assembly. You can retrieve all clases using @ref bs::MonoAssembly::getAllClasses "MonoAssembly::getAllClasses()", or retrieve a specific one by calling @ref bs::MonoAssembly::getClass(const String&, const String&) const "MonoAssembly::getClass(const String& namespace, const String& typename)". Both of these methods return a @ref bs::MonoClass "MonoClass" object.
-
-## MonoClass 	{#scripting_a_b}
-**MonoClass** gives you access to all methods, fields, properties and attributes of a specific class. It also allows you to register "internal" methods. These methods allow the managed code to call C++ code, and we'll go into them later.
-
-Classes also allow you to create object instances of their type. Use @ref bs::MonoClass::createInstance "MonoClass::createInstance()" to create a new object instance. This method returns a **MonoObject** instance, which is a C++ representation of the C# object, but more on them later. When creating an instance you may choose whether to construct it or not, and to provide constructor signature if you need a specific one.
-
-To retrieve a method from a class call @ref bs::MonoClass::getMethod() "MonoClass::getMethod()", accepting a name (without parameter types) and a number of parameters. If your method is overloaded you can use @ref bs::MonoClass::getMethodExact "MonoClass:getMethodExact()" which accepts a method name, and a comma separated list of parameter types. You may also use @ref bs::MonoClass::getAllMethods "MonoClass::getAllMethods()" to retrieve all methods in a class. All three of these methods return a @ref bs::MonoMethod "MonoMethod" object.
-
-
-
-
-TODO - Example getting a method
-
-
-
-
-## MonoMethod {#scripting_a_c}
-**MonoMethod** class provides information about about a managed method, as well as giving you multiple ways of invoking it (i.e. calling C# methods from C++).
-
-To invoke a method you may use multiple approaches:
- - @ref bs::MonoMethod::invoke "MonoMethod::invoke()" - Accepts a **MonoObject** to invoke the method on (null if a static method), as well as an optional list of parameters. Invokes the exact method to exact type it was provided on.
- - @ref bs::MonoMethod::invokeVirtual "MonoMethod::invokeVirtual()" - Accepts a **MonoObject** to invoke the method on (null if a static method), as well as an optional list of parameters. Unlike **MonoMethod::invoke()** it calls the method polymorphically, meaning it determines the actual type of the provided managed object instance and calls an overriden method if available.
- - @ref bs::MonoMethod::getThunk "MonoMethod::getThunk()" - Returns a C++ function pointer accepting a **MonoObject**, zero or more parameters and an exception object. You can then call the function pointer like you would a C++ function. This is equivalent to **MonoMethod::invoke()** but is significantly faster. A helper method @ref bs::MonoUtil::invokeThunk<T, Args> "MonoUtil::invokeThunk()" is provided - it is suggested you use it instead of calling thunks manually  because it handles exceptions internally.
-
-
- 
- 
- 
- TODO - Example invoking a method
- TODO - Thunk example
- 
- 
-We'll talk more about how to pass parameters to methods later. 
- 
-## MonoField {#scripting_a_d}
-Similar to methods, field information can be retrieved from a **MonoClass** object by calling @ref bs::MonoClass::getField "MonoClass::getField()" or @ref bs::MonoClass::getAllFields "MonoClass::getAllFields()". The returned value is a @ref bs::MonoField "MonoField" which provides information about the field and allows you to retrieve and set values in the field using @ref bs::MonoField::getValue "MonoField::getValue()" / @ref bs::MonoField::setValue "MonoField::setValue()". 
-
-
-
-TODO - Example getting/setting a field
-
-
-
-
-## MonoProperty {#scripting_a_e}
-Properties are very similar to fields, retrieved from a **MonoClass** object by calling @ref bs::MonoClass::getProperty "MonoClass::getProperty()". The returned value is a @ref bs::MonoProperty "MonoProperty" which provides information about the property and allows you to retrieve and set values on it. The main difference is that properties in C# can be indexed (like arrays) and therefore a two set of set/get methods are provided, one accepting an index and other one not. It's up to the user to know which one to call. The methods are @ref bs::MonoProperty::get "MonoProperty::get()" / @ref bs::MonoProperty::set "MonoProperty::set()" and @ref bs::MonoProperty::getIndexed "MonoProperty::getIndexed()" / @ref bs::MonoProperty::setIndexed "MonoProperty::setIndexed()".
-
-
-
-TODO - Example getting/setting a property
-
-
-## Attributes {#scripting_a_f}
-Attributes provide data about a class, method or field provided at runtime, which usually allows such objects to be specialized in some regard. Attributes don't have their own wrapper, because they are esentially normal managed objects and you can work with them as such.
-
-To retrieve a list of attributes from a class use @ref bs::MonoClass::getAllAttributes() "MonoClass::getAllAttributes()", which returns a list of **MonoClass** objects that identify the attribute types. To get the actual object instance of the attribute you may call @ref bs::MonoClass::getAttribute "MonoClass::getAttribute()" with the wanted attribute's **MonoClass**. After that you can call methods, work with field values and similar, same as you would with a normal managed object.
-
-Attributes can also be retrieved from a **MonoMethod** by using @ref bs::MonoMethod::getAttribute "MonoMethod::getAttribute()", or from **MonoField** by using @ref bs::MonoField::getAttribute "MonoField::getAttribute()".
-
-
-
-
-
-
-
-
-TODO - Stopped here
-
-
-
-
-
-
-## Managed objects {#scripting_a_g}
-So far we have talked about invoking methods and retrieving field values, but we haven't yet explained how to access managed object instances in C++ code. All managed objects in Mono are represented by a `MonoObject`.
-
-For example, when calling a non-static method the first parameter provided to @ref bs::MonoMethod::invoke "MonoMethod::invoke" is a `MonoObject` pointer. Same goes for retrieving or setting values on fields, properties. Attributes are also a `MonoObject`.
-
-Mono also provides two more specialized types of managed objects: `MonoArray` for managed arrays, and `MonoString` for managed strings, but they are both still a `MonoObject`.
-
-Be aware that all managed objects are garbage collected. This means you should not keep a reference to them unless you are sure they are alive. Just having a pointer to a `MonoObject` will not keep the object alive and it may go out of scope as soon as the control returns to managed code. A good way to deal with this issue is:
- - Call a native method in the object's finalizer (`~MyObject()`) which will notify you when the object is no longer valid. Be aware that finalizer may be called after the object is unusable.
- - Require the user to manually destroy the object by calling a custom `Destroy` method or similar.
- - Force the garbage collector to keep the object alive by calling @ref bs::MonoUtil::newGCHandle "MonoUtil::newGCHandle" which will return a handle to the object. The handle will keep the object alive until you release it by calling @ref bs::MonoUtil::freeGCHandle "MonoUtil::freeGCHandle". Be aware if an assembly the object belongs to is unloaded all objects will be destroyed regardless of kept handles.
- 
-## Marshalling data {#scripting_a_h}
-Mono does not perform automatic marshalling of data when calling managed code from C++ (or vice versa). This is important when calling methods, retrieving/setting field/property values, and responding to calls from managed code, because you need to know in what format to expect the data.
-
-The rules are:
- - All primitive types are passed as is. e.g. an `int` in C# will be a 4 byte integer in C++, a `float` will be a float, a `bool` will be a bool.
- - All reference types (`class` in C#) are passed as a `MonoObject*`. Strings and arrays are handled specially, where strings are passed as `MonoString*`, and arrays as `MonoArray*`.
-   - If a reference type parameter in a method in managed code is prefixed with an `out` modifier, then the received parameters are `MonoObject**`, `MonoString**`, `MonoArray**` and your method is expected to populate those values.
- - Structs (non-primitive value types, `struct` in C#) are provided as raw memory. Make sure that all structs in C# that require marshalling have a `[StructLayout(LayoutKind.Sequential)]` attribute, which ensures they have the same memory layout as C++ structs. This way you can just accept the raw C++ structure and read it with no additional conversion.
-  - It is suggested you never pass structures by value, it is known to cause problems in Mono. Instead pass all structures by prefixing them with `ref` which will give you a pointer to the structure (e.g. `MyStruct*`). If you need to output a struct use the `out` modifier which you will give you a double pointer (e.g. `MyStruct**`).
-  - In cases where it is not possible to avoid passing structures by value (e.g. when retrieving them from a field, use the @ref bs::MonoField::getValueBoxed "MonoField::getValueBoxed" method instead @ref bs::MonoField::getValue "MonoField::getValue", which will return a struct in the form of a `MonoObject`. You can then retrieve the raw struct value by calling @ref bs::MonoUtil::unbox "MonoUtil::unbox".
-  - Everything above applies only when managed code is calling C++. When calling into managed code from C++, all structs need to be boxed (i.e. converted to `MonoObject`). Use @ref bs::MonoUtil::box "MonoUtil::box" to convert a C++ struct into a `MonoObject*`. See @ref bs::ScriptVector3 "ScriptVector3" for an example implementation.
-  
-Banshee provides a helper code to assist with marshalling strings:
- - @ref bs::MonoUtil::monoToWString "MonoUtil::monoToWString" / @ref bs::MonoUtil::monoToString "MonoUtil::monoToString" - Converts a `MonoString*` to a native string
- - @ref bs::MonoUtil::wstringToMono "MonoUtil::wstringToMono" / @ref bs::MonoUtil::stringToMono "MonoUtil::stringToMono" - Converts a native string into a `MonoString*`
-
-@ref bs::ScriptArray "ScriptArray" is a helper class that allows you to construct new arrays and read managed arrays, easily. 
-
-To create a new arrays call @ref bs::ScriptArray::create "ScriptArray<Type>::create". Type can be a primitive type like `int`, `float`, a native string or a `Script*` object (more about `Script*` objects later). You can then fill the array by calling @ref bs::ScriptArray::set "ScriptArray::set" and retrieve the managed `MonoArray*` by calling @ref bs::ScriptArray::getInternal "ScriptArray::getInternal".
-
-To more easily read existing arrays create a new @ref bs::ScriptArray "ScriptArray" by providing it with a `MonoArray*` in the constructor. Then you can easily retrieve the size of the array using @ref bs::ScriptArray::size() "ScriptArray::size()", and the value of its elements by calling @ref bs::ScriptArray::get "ScriptArray::get<Type>"". 
-
-## Internal methods {#scripting_a_i}
-So far we have talked about calling managed code, and retrieving information about managed types, but we have yet to show how managed code calls C++ code. This is accomplished using native methods.
-
-The first step is to define a stub method in managed code, like so:
-~~~~~~~~~~~~~{.cs}
-[MethodImpl(MethodImplOptions.InternalCall)]
-private static extern float Internal_GetSomeValue(MyObject obj);
-~~~~~~~~~~~~~
-	
-You then hook up this method with managed code by calling @ref bs::MonoClass::addInternalCall "MonoClass::addInternalCall". In this specific case it would be:
-~~~~~~~~~~~~~{.cpp}
-myClass->addInternalCall("Internal_GetSomeValue", &myNativeFunction);
-~~~~~~~~~~~~~
-
-Assuming `myClass` is a @ref bs::MonoClass "MonoClass" of the type that contains the stub method. After this call any call to the managed stub method will call the provided native function `myNativeFunction`. You should take care to properly handle parameter passing as described above.
-
-Take a look at @ref bs::ScriptGUISkin "ScriptGUISkin" implementation for a simple example of how exactly does this work. 
-
-# Script objects {#scripting_b}
-As you can see interaction between the two languages can get a bit cumbersome. For that reason Banshee implements a higher level system built on the functionality shown so far. It provides an universal interface all script objects must implement. It primarily ensures that native and managed code is always linked by keeping a pointer to each other's objects, as well as gracefully handling managed object destruction and handling assembly refresh (due to script hot-swap).
-
-When exposing a class to the scripting interface you need to add two things:
- - A native interop object (C++)
- - Managed wrapper for the class (C#)
-
-## Native interop object ## {#scripting_b_a}
-
-All native interop objects implement the @ref bs::ScriptObject "ScriptObject" interface. A basic implementation of such an interface can be:
-~~~~~~~~~~~~~{.cpp}
-class ScriptMyObject : public ScriptObject <ScriptMyObject>
-{
-public:
-	SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "MyObject")
-
-private:
-	ScriptMyObject(MonoObject* instance);
-	
-	static void internal_CreateInstance(MonoObject* obj);
-	static float internal_GetSomeValue(MonoObject* obj);
-};
-~~~~~~~~~~~~~	
-	
-All @ref bs::ScriptObject "ScriptObjects" must begin with a @ref SCRIPT_OBJ macro. The macro accepts (in order): 
- - the name of the assembly (.dll) the managed script object is in, this is either `ENGINE_ASSEMBLY` or `EDITOR_ASSEMBLY`
- - the namespace the type is in
- - the name of the managed type
-
-@ref SCRIPT_OBJ macro also defines a static `initRuntimeData()` method you need to implement (more on that later).
-
-When constructing a @ref bs::ScriptObject "ScriptObject" you must also provide a pointer to the managed object that wraps it (note the constructor). If the @ref bs::ScriptObject "ScriptObject" is used for a class that is static then the constructor is of no consequence as the @ref bs::ScriptObject "ScriptObject" itself never needs to be instantiated (all of its methods will be static). 
- 
-The two last method definitions in the example are called from C# (via an internal call, see the section about internal methods earlier).
-
-### initRuntimeData ### {#scripting_b_a_a}
-`initRuntimeData` is a static method that every @ref bs::ScriptObject "ScriptObject" needs to implement. It takes care of hooking up managed internal methods to C++ functions. It gets called automatically whenever the assembly containing the related managed class is loaded. 
-
-Every @ref bs::ScriptObject "ScriptObject" provides a static @ref bs::ScriptObject<Type, Base>::getMetaData "metaData" structure you can use for retrieving the @ref bs::MonoClass "MonoClass" of the related managed class. You can use that @ref bs::MonoClass "MonoClass" to register internal methods to it (as described earlier). For example a basic `initRuntimeData()` might look like so:
-~~~~~~~~~~~~~{.cpp}
-void ScriptMyObject::initRuntimeData()
-{
-	metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptFont::internal_CreateInstance);
-	metaData.scriptClass->addInternalCall("Internal_GetSomeValue", &ScriptFont::internal_GetSomeValue);
-}
-~~~~~~~~~~~~~
-
-`initRuntimeData` is also a good spot to retrieve @ref bs::MonoMethod "MonoMethods" (or thunks) for managed methods that needed to be called by the script interop object, if any.
-
-### Creating script object instances ### {#scripting_b_a_b}	
-If your class is not static you will need to eventually create an instance of the script object. This can be done either from C# or C++, depending on what is needed. For example script interop objects for GUI will be created from managed code because user can add GUI elements himself, but a resource like @ref bs::Font "Font" will have its script interop object (and managed instance) created purely from C++ because such an object cannot be created directly in managed code.
-
-For the first case you should set up an internal method that accepts the managed object instance, and is called in the managed constructor (`internal_CreateInstance` in the above example). This way the method gets called whenever the managed object gets created and you can create the related script interop object. A simple implementation would look like so:
-~~~~~~~~~~~~~{.cpp}
-void ScriptMyObject::internal_createInstance(MonoObject* obj)
-{
-	bs_new<ScriptMyObject>(obj);
-}
-~~~~~~~~~~~~~
-	
-Note that you don't actually need to store the created object anywhere. The @ref bs::ScriptObject "ScriptObject" constructor ensures that the pointer to the script interop object is stored in the managed object.
-
-For the second case where you want to create the interop object from C++ you can create a static `create()` method like so:
-~~~~~~~~~~~~~{.cpp}
-MonoObject* ScriptMyObject::create()
-{
-	MonoObject* managedObj = metaData.scriptClass->createInstance();
-	bs_new<ScriptMyObject>(managedObj);
-	
-	return managedObj;
-}
-~~~~~~~~~~~~~
-	
-In this case the method calls a parameterless constructor but you may specify parameters as needed.
-
-If you have a `MonoObject*` but need to retrieve its @ref bs::ScriptObject "ScriptObject" use @ref bs::ScriptObject::toNative(MonoObject*) "toNative(MonoObject*)" static method. Within the interop object instance you can use @ref bs::ScriptObjectBase::getManagedInstance() "ScriptObject::getManagedInstance()" to retrieve the managed object.
-
-### Destroying script object instances ### {#scripting_b_a_c}
-When the managed object is destroyed (e.g. goes out of scope and gets garbage collected) the system will automatically take care of freeing the related ScriptObject. If you need to add onto or replace that functionality you can override @ref bs::ScriptObjectBase::_onManagedInstanceDeleted "ScriptObject::_onManagedInstanceDeleted" method.
-
-## Managed wrapper object ## {#scripting_b_b}
-Creating the script interop object is one half of the job done. You also need to create the managed counterpart, however that is significantly simpler.
-
-Every managed script object must implement the ScriptObject interface. For example a C# version of the class we're using in this example would look like:
-~~~~~~~~~~~~~{.cs}
-namespace BansheeEngine
-{
-	public class MyObject : ScriptObject
-	{
-		public MyObject()
-		{
-			Internal_CreateInstance(this)
-		}
-		
-		public float SomeValue
-		{
-			get { return Internal_GetSomeValue(this); }
-		}
-		
-		[MethodImpl(MethodImplOptions.InternalCall)]
-		private static extern void Internal_CreateInstance(MyObject obj);
-		
-		[MethodImpl(MethodImplOptions.InternalCall)]
-		private static extern float Internal_GetSomeValue(MyObject obj);
-	}
-}
-~~~~~~~~~~~~~
-
-That's all that needs to be done. You can now create the object in C# and use its property to retrieve the value from C++ code. All managed `ScriptObjects` provide a `GetCachedPtr` method which returns an `IntPtr` which points to the script interop object described in previous sections.
-
-## Assembly refresh ##
-What has been shown so far is enough to create a class exposed to script, however object of such a class will not survive assembly refresh. Assembly refresh happens when scripts are recompiled and managed assemblies are unloaded and reloaded. This is something that generally happens only in the editor.
-
-If you don't care about your object surviving the refresh, you do not need to implement what is described here. For example GUI elements don't persist refresh, because they're just rebuilt from the managed code every time the refresh happens. However objects like resources, scene objects and components are persistent - we don't wish to reload the entire scene and all resources every time assembly refresh happens.
-
-A persistent script object need to inherit a variation of @ref bs::ScriptObject "ScriptObject" like so:
-~~~~~~~~~~~~~{.cpp}
-class MyScriptObject : public ScriptObject<MyScriptObject, PersistentScriptObjectBase>
-~~~~~~~~~~~~~	
-	
-This ensures that your object is treated properly during assembly refresh. Persistent object then needs to handle four different actions, represented by overrideable methods. These methods are called in order specified, during assembly refresh.
- - @ref bs::ScriptObjectBase::beginRefresh() "ScriptObject::beginRefresh()" - Called just before the refresh starts. The object is still alive here and you can perform needed actions (e.g. saving managed object's contents).
- - @ref bs::ScriptObjectBase::_onManagedInstanceDeleted "ScriptObject::_onManagedInstanceDeleted()" - Called after assembly unload happened and the managed object was destroyed. You should override this to prevent the @ref bs::ScriptObject "ScriptObject" itself from being deleted if the assembly refresh is in progress. If assembly refresh is not in progress this method should delete the @ref bs::ScriptObject "ScriptObject" as normal because it likely got called due to standard reasons (managed object went out of scope).
- - @ref bs::ScriptObject::_createManagedInstance "ScriptObject::_createManagedInstance()" - Creates the managed instance after new assemblies are loaded. You should override this if your managed class is constructed using a constructor with parameters. By default this will call @ref bs::MonoClass::createInstance "MonoClass::createInstance()" using the parameterless constructor.
- - @ref bs::ScriptObjectBase::endRefresh() "ScriptObject::endRefresh()" - Called after all assemblies are loaded, and after all script interop objects were either destroyed (non-persistent) or had their managed instances created (persistent). If you stored any data during @ref bs::ScriptObjectBase::beginRefresh() "ScriptObject::beginRefresh()", you should restore it here.
- 
-See @ref bs::ScriptSceneObject "ScriptSceneObject" and its base class @ref bs::ScriptGameObjectBase "ScriptGameObjectBase" for example implementations of these methods.
-
-## Deriving from ScriptObject ##
-Sometimes script objects are polymorphic. For example a `GUIElement` is derived from `ScriptObject` in managed code, and `GUIButton` is derived from `GUIElement`, however they both have script interop objects of their own.
-
-Due to the nature of how our script interop objects are defined we cannot follow the same simple chain of inheritance in C++ code. For example class definition script interop object for `GUIElement` would be:
-~~~~~~~~~~~~~{.cpp}
-class ScriptGUIElement : public ScriptObject<ScriptGUIElement>
-{
-public:
-	SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "GUIElement")
-...
-}
-~~~~~~~~~~~~~	
-	
-But what would it be for `GUIButton`? It also needs to implement @ref bs::ScriptObject "ScriptObject" with its own @ref SCRIPT_OBJ macro so we cannot just inherit from `ScriptGUIElement` directly as it would clash.
-
-The solution is to create a third class that will serve as a base for both. This third class will be a base class for @ref bs::ScriptObject "ScriptObject" (its second template parameter allows us to override its default `ScriptObjectBase` base class). The third class will need to inherit @ref bs::ScriptObjectBase "ScriptObjectBase" and can implement any functionality common to all GUI elements (e.g. it might store a pointer to a native `GUIElement*`).
-
-Then we can define script interop object for GUI element as:
-~~~~~~~~~~~~~{.cpp}
-class ScriptGUIElement : public ScriptObject<ScriptGUIElement, ScriptGUIElementBase>
-~~~~~~~~~~~~~
-
-Where `ScriptGUIElementBase` is our third (common) class. Interop object for `GUIButton` would then be:
-~~~~~~~~~~~~~{.cpp}
-class ScriptGUIButton : public ScriptObject<ScriptGUIButton, ScriptGUIElementBase>
-~~~~~~~~~~~~~	
-	
-This ensures that all GUI elements can now be accessed through the common `ScriptGUIElementBase` interface. Which is important if `GUIElement` provides some internal method calls shared between all GUI element types, otherwise we wouldn't know what to cast the interop object held by its managed object to.
-
-See @ref bs::ScriptGUIElement "ScriptGUIElement" and @ref bs::ScriptGUIButton "ScriptGUIButton" for an example.
-
-
-
-
-
-
-## Exposing resources to scripting {#resources_c_a}
-Once you have a custom resource you might want to expose it to the scripting API. Take a look at the [scripting interop guide](@ref scripting) to learn how to create scripting API objects. 
-
-Every resource scripting interop object must implement @ref bs::TScriptResource "TScriptResource", but other than that creating GUI interop objects is the same as the general case described in the guide above. See @ref bs::ScriptFont "ScriptFont" in `BsScriptFont.cpp` for an example.
-
-Creating managed GUI objects is again the same as the general case. Take a look at the managed `Font` implementation in `Font.cs` for an example.
-
-Resources are unlike most other scripting objects because they can be created in the native code and then used in the managed code, or vice versa. Resources are also serialized by reference, which requires some specialized code for managed serialization to properly recognize the resource. 
-
-### Native <-> managed resource conversion {#resources_c_a_a}
-When a resource is created in native code, but needs to be passed to scripting code, the system creates a script interop object and a managed object, which wrap the native resource. The system also needs to be aware if such managed representation of an object already exists, and return an existing one if so. This is the job of the @ref bs::ScriptResourceManager "ScriptResourceManager".
-
-You will need to update this manager with your custom resource type. Relevant methods are:
- - @ref bs::ScriptResourceManager::createScriptResource "ScriptResourceManager::createScriptResource" - Creates a new managed object instance from a native resource (only valid if one doesn't already exist). This method has two overloads, and is specialized for specific resource types. Make sure to add a specialization for both overloads, with your custom resource type. And also update the specialization that accepts a generic @ref bs::ResourceHandleBase "HResource" with an entry of your own resource. You can use existing resources as an example of how it should be done, only the type names need changing.
- - @ref bs::ScriptResourceManager::getScriptResource<RetType, InType> "ScriptResourceManager::getScriptResource" - Retrieves an existing managed object instance from a native resource handle. Optionally creates the managed object if one doesn't already exist. Add a specialization for your own resource type similar to methods above.
-
-### Managed resource serialization {#resources_c_a_b}
-In order for your new resource type to be properly referenced by serialized managed objects you need to make a few more additions:
- - First of append a new resource type to the @ref bs::ScriptReferenceType "ScriptReferenceType" enum.
- - Append a new entry to @ref bs::ManagedSerializableTypeInfoRef::getMonoClass "ManagedSerializableTypeInfoRef::getMonoClass" which maps the enum entry above to your resource script interop object type
- - Append a new entry to @ref bs::ManagedSerializableTypeInfoRef::isTypeLoaded "ManagedSerializableTypeInfoRef::isTypeLoaded" so it always returns true if your resource is encountered (since it's built-in, it's always loaded)
- - Append a new entry in the @ref bs::ScriptAssemblyManager::getTypeInfo "ScriptAssemblyManager::getTypeInfo" which maps the managed resource object type to the enum above
- - Append a new entry to the `getResourceFieldLookup` method in `BsManagedSerializableField.cpp` which uses the native <-> managed conversion methods to map between a native and a managed instance of a resource during serialization/deserialization
- 
-For all of these you can use examples of existing resources which already exist within the mentioned methods, it is just a matter of changing the type/enum names for your own resource. 
- 
-### Other {#resources_c_a_c}
-In order for your resources to be properly recognized by GUI drop fields, as well as the project library append new entries to @ref bs::ScriptResource::getClassFromTypeId "ScriptResource::getClassFromTypeId" and @ref bs::ScriptResource::getTypeFromTypeId "ScriptResource::getTypeFromTypeId" which map between the enum above and the RTTI type ID of the resource.

+ 3 - 3
Source/BansheeMono/Include/BsMonoField.h

@@ -31,13 +31,13 @@ namespace bs
 		 * Value will be a pointer to raw data type for value types (for example int, float), and a MonoObject* for
 		 * reference types.
 		 */
-		void getValue(MonoObject* instance, void* outValue);
+		void get(MonoObject* instance, void* outValue);
 
 		/**
 		 * Retrieves value currently set in the field on the specified object instance. If field is static object instance
 		 * can be null. If returned value is a value type it will be boxed.
 		 */
-		MonoObject* getValueBoxed(MonoObject* instance);
+		MonoObject* getBoxed(MonoObject* instance);
 
 		/**
 		 * Sets a value for the field on the specified object instance. If field is static object instance can be null. 
@@ -46,7 +46,7 @@ namespace bs
 		 * Value should be a pointer to raw data type for value types (for example int, float), and a MonoObject* for
 		 * reference types.
 		 */
-		void setValue(MonoObject* instance, void* value);
+		void set(MonoObject* instance, void* value);
 
 		/**	Checks if field has an attribute of the specified type. */
 		bool hasAttribute(MonoClass* monoClass);

+ 3 - 3
Source/BansheeMono/Source/BsMonoField.cpp

@@ -31,17 +31,17 @@ namespace bs
 		return mFieldType;
 	}
 
-	void MonoField::getValue(MonoObject* instance, void* outValue)
+	void MonoField::get(MonoObject* instance, void* outValue)
 	{
 		mono_field_get_value(instance, mField, outValue);
 	}
 
-	MonoObject* MonoField::getValueBoxed(MonoObject* instance)
+	MonoObject* MonoField::getBoxed(MonoObject* instance)
 	{
 		return mono_field_get_value_object(MonoManager::instance().getDomain(), mField, instance);
 	}
 
-	void MonoField::setValue(MonoObject* instance, void* value)
+	void MonoField::set(MonoObject* instance, void* value)
 	{
 		mono_field_set_value(instance, mField, value);
 	}

+ 4 - 4
Source/SBansheeEditor/Source/BsMenuItemManager.cpp

@@ -143,12 +143,12 @@ namespace bs
 		MonoObject* menuItemAttrib = method->getAttribute(mMenuItemAttribute);
 
 		MonoString* monoPath;
-		mPathField->getValue(menuItemAttrib, &monoPath);
+		mPathField->get(menuItemAttrib, &monoPath);
 
-		mShortcutField->getValue(menuItemAttrib, &shortcut);
+		mShortcutField->get(menuItemAttrib, &shortcut);
 		path = MonoUtil::monoToWString(monoPath);
-		mPriorityField->getValue(menuItemAttrib, &priority);
-		mSeparatorField->getValue(menuItemAttrib, &separator);
+		mPriorityField->get(menuItemAttrib, &priority);
+		mSeparatorField->get(menuItemAttrib, &separator);
 
 		return true;
 	}

+ 3 - 3
Source/SBansheeEditor/Source/BsScriptDropDownWindow.cpp

@@ -77,8 +77,8 @@ namespace bs
 		MonoObject* defaultSizeObj = windowClass->getAttribute(defaultSizeAttrib);
 		if (defaultSizeObj != nullptr)
 		{
-			defaultWidthField->getValue(defaultSizeObj, &width);
-			defaultHeightField->getValue(defaultSizeObj, &height);
+			defaultWidthField->get(defaultSizeObj, &width);
+			defaultHeightField->get(defaultSizeObj, &height);
 		}
 
 		MonoObject* instance = windowClass->createInstance(false);
@@ -181,7 +181,7 @@ namespace bs
 
 		MonoObject* guiPanel = ScriptGUIPanel::createFromExisting(mContents);
 		mContentsPanel = ScriptGUILayout::toNative(guiPanel);
-		ScriptDropDownWindow::guiPanelField->setValue(mManagedInstance, guiPanel);
+		ScriptDropDownWindow::guiPanelField->set(mManagedInstance, guiPanel);
 
 		::MonoClass* rawMonoClass = MonoUtil::getClass(mManagedInstance);
 		MonoClass* monoClass = MonoManager::instance().findClass(rawMonoClass);

+ 4 - 4
Source/SBansheeEditor/Source/BsScriptEditorWindow.cpp

@@ -343,8 +343,8 @@ namespace bs
 					MonoObject* defaultSize = curClass->getAttribute(defaultSizeAttrib);
 					if (defaultSize != nullptr)
 					{
-						defaultWidthField->getValue(defaultSize, &width);
-						defaultHeightField->getValue(defaultSize, &height);
+						defaultWidthField->get(defaultSize, &width);
+						defaultHeightField->get(defaultSize, &height);
 					}
 
 					bool hasLocalUndoRedo = curClass->getAttribute(undoRedoLocalAttrib) != nullptr;
@@ -465,12 +465,12 @@ namespace bs
 
 					MonoObject* guiPanel = ScriptGUIPanel::createFromExisting(mContent);
 					mContentsPanel = ScriptGUILayout::toNative(guiPanel);
-					ScriptEditorWindow::guiPanelField->setValue(mManagedInstance, guiPanel);
+					ScriptEditorWindow::guiPanelField->set(mManagedInstance, guiPanel);
 
 					if(mHasLocalUndoRedo)
 					{
 						MonoObject* undoRedo = ScriptUndoRedo::create();
-						ScriptEditorWindow::undoRedoField->setValue(mManagedInstance, undoRedo);
+						ScriptEditorWindow::undoRedoField->set(mManagedInstance, undoRedo);
 					}
 
 					reloadMonoTypes(editorWindowClass);

+ 1 - 1
Source/SBansheeEditor/Source/BsScriptGizmoManager.cpp

@@ -165,7 +165,7 @@ namespace bs
 		componentType = paramType;
 
 		MonoObject* drawGizmoAttrib = method->getAttribute(mDrawGizmoAttribute);
-		mFlagsField->getValue(drawGizmoAttrib, &drawGizmoFlags);
+		mFlagsField->get(drawGizmoAttrib, &drawGizmoFlags);
 
 		return true;
 	}

+ 1 - 1
Source/SBansheeEditor/Source/BsScriptHandleManager.cpp

@@ -238,7 +238,7 @@ namespace bs
 		MonoObject* customHandleAttrib = type->getAttribute(mCustomHandleAttribute);
 		MonoReflectionType* attribReflType = nullptr;
 
-		mTypeField->getValue(customHandleAttrib, &attribReflType);
+		mTypeField->get(customHandleAttrib, &attribReflType);
 
 		// Handle shown only when specific component type is selected
 		if (attribReflType != nullptr)

+ 8 - 8
Source/SBansheeEditor/Source/BsScriptImportOptions.cpp

@@ -703,13 +703,13 @@ namespace bs
 		AnimationSplitInfo output;
 
 		MonoString* monoName = nullptr;
-		nameField->getValue(instance, &monoName);
+		nameField->get(instance, &monoName);
 
 		output.name = MonoUtil::monoToString(monoName);
 
-		startFrameField->getValue(instance, &output.startFrame);
-		endFrameField->getValue(instance, &output.endFrame);
-		isAdditiveField->getValue(instance, &output.isAdditive);
+		startFrameField->get(instance, &output.startFrame);
+		endFrameField->get(instance, &output.endFrame);
+		isAdditiveField->get(instance, &output.isAdditive);
 
 		return output;
 	}
@@ -743,12 +743,12 @@ namespace bs
 		ImportedAnimationEvents output;
 
 		MonoString* monoName = nullptr;
-		nameField->getValue(instance, &monoName);
+		nameField->get(instance, &monoName);
 
 		output.name = MonoUtil::monoToString(monoName);
 
 		MonoArray* monoEvents;
-		eventsField->getValue(instance, &monoEvents);
+		eventsField->get(instance, &monoEvents);
 
 		if (monoEvents != nullptr)
 		{
@@ -779,8 +779,8 @@ namespace bs
 		}
 
 		MonoObject* instance = metaData.scriptClass->createInstance();
-		nameField->setValue(instance, monoString);
-		eventsField->setValue(instance, scriptEvents.getInternal());
+		nameField->set(instance, monoString);
+		eventsField->set(instance, scriptEvents.getInternal());
 
 		return instance;
 	}

+ 1 - 1
Source/SBansheeEditor/Source/BsScriptInspectorUtility.cpp

@@ -80,7 +80,7 @@ namespace bs
 
 				// Check if the attribute references a valid class
 				MonoReflectionType* referencedReflType = nullptr;
-				mTypeField->getValue(attrib, &referencedReflType);
+				mTypeField->get(attrib, &referencedReflType);
 
 				::MonoClass* referencedMonoClass = MonoUtil::getClass(referencedReflType);
 

+ 2 - 2
Source/SBansheeEditor/Source/BsScriptModalWindow.cpp

@@ -134,7 +134,7 @@ namespace bs
 
 		MonoObject* guiPanel = ScriptGUIPanel::createFromExisting(mContents);
 		mContentsPanel = ScriptGUILayout::toNative(guiPanel);
-		ScriptModalWindow::guiPanelField->setValue(mManagedInstance, guiPanel);
+		ScriptModalWindow::guiPanelField->set(mManagedInstance, guiPanel);
 
 		::MonoClass* rawMonoClass = MonoUtil::getClass(mManagedInstance);
 		MonoClass* monoClass = MonoManager::instance().findClass(rawMonoClass);
@@ -166,7 +166,7 @@ namespace bs
 
 				MonoObject* guiPanel = ScriptGUIPanel::createFromExisting(mContents);
 				mContentsPanel = ScriptGUILayout::toNative(guiPanel);
-				ScriptModalWindow::guiPanelField->setValue(mManagedInstance, guiPanel);
+				ScriptModalWindow::guiPanelField->set(mManagedInstance, guiPanel);
 
 				reloadMonoTypes(editorWindowClass);
 				return true;

+ 6 - 6
Source/SBansheeEditor/Source/BsToolbarItemManager.cpp

@@ -115,11 +115,11 @@ namespace bs
 		MonoObject* toolbarItemAttrib = method->getAttribute(mToolbarItemAttribute);
 
 		MonoString* monoName;
-		mNameField->getValue(toolbarItemAttrib, &monoName);
+		mNameField->get(toolbarItemAttrib, &monoName);
 		name = MonoUtil::monoToString(monoName);
 
 		int builtinIcon;
-		mBuiltinIconField->getValue(toolbarItemAttrib, &builtinIcon);
+		mBuiltinIconField->get(toolbarItemAttrib, &builtinIcon);
 
 		if (builtinIcon != -1)
 		{
@@ -128,19 +128,19 @@ namespace bs
 		else
 		{
 			MonoString* monoTexturePath;
-			mIconField->getValue(toolbarItemAttrib, &monoTexturePath);
+			mIconField->get(toolbarItemAttrib, &monoTexturePath);
 
 			Path texturePath = MonoUtil::monoToWString(monoTexturePath);
 			icon = static_resource_cast<SpriteTexture>(gProjectLibrary().load(texturePath));
 		}
 
 		MonoString* tooltipMono;
-		mTooltipField->getValue(toolbarItemAttrib, &tooltipMono);
+		mTooltipField->get(toolbarItemAttrib, &tooltipMono);
 
 		tooltip = HString(MonoUtil::monoToWString(tooltipMono));
 
-		mPriorityField->getValue(toolbarItemAttrib, &priority);
-		mSeparatorField->getValue(toolbarItemAttrib, &separator);
+		mPriorityField->get(toolbarItemAttrib, &priority);
+		mSeparatorField->get(toolbarItemAttrib, &separator);
 
 		return true;
 	}

+ 4 - 4
Source/SBansheeEngine/Include/BsScriptObject.h

@@ -97,7 +97,7 @@ namespace bs
 			Type* param = (Type*)(Base*)this; // Needed due to multiple inheritance. Safe since Type must point to an class derived from this one.
 
 			if(metaData.thisPtrField != nullptr)
-				metaData.thisPtrField->setValue(instance, &param);
+				metaData.thisPtrField->set(instance, &param);
 		}
 
 		virtual ~ScriptObject() 
@@ -110,7 +110,7 @@ namespace bs
 		void _clearManagedInstance()
 		{
 			if (metaData.thisPtrField != nullptr && this->mManagedInstance != nullptr)
-				metaData.thisPtrField->setValue(this->mManagedInstance, nullptr);
+				metaData.thisPtrField->set(this->mManagedInstance, nullptr);
 
 			this->mManagedInstance = nullptr;
 		}
@@ -123,7 +123,7 @@ namespace bs
 			Type* param = (Type*)(Base*)this; // Needed due to multiple inheritance. Safe since Type must point to an class derived from this one.
 
 			if (metaData.thisPtrField != nullptr && this->mManagedInstance != nullptr)
-				metaData.thisPtrField->setValue(this->mManagedInstance, &param);
+				metaData.thisPtrField->set(this->mManagedInstance, &param);
 		}
 
 		/**	Creates a new managed instance of the type wrapped by this interop object. */
@@ -141,7 +141,7 @@ namespace bs
 			Type* nativeInstance = nullptr;
 
 			if (metaData.thisPtrField != nullptr && managedInstance != nullptr)
-				metaData.thisPtrField->getValue(managedInstance, &nativeInstance);
+				metaData.thisPtrField->get(managedInstance, &nativeInstance);
 
 			return nativeInstance;
 		}

+ 10 - 10
Source/SBansheeEngine/Source/BsManagedSerializableObjectInfo.cpp

@@ -105,7 +105,7 @@ namespace bs
 			if (range != nullptr)
 			{
 				float min = 0;
-				ScriptRange::getMinRangeField()->getValue(mMonoField->getAttribute(range), &min);
+				ScriptRange::getMinRangeField()->get(mMonoField->getAttribute(range), &min);
 				return min;
 			}
 		}
@@ -120,7 +120,7 @@ namespace bs
 			if (range != nullptr)
 			{
 				float max = 0;
-				ScriptRange::getMaxRangeField()->getValue(mMonoField->getAttribute(range), &max);
+				ScriptRange::getMaxRangeField()->get(mMonoField->getAttribute(range), &max);
 				return max;
 			}
 		}
@@ -135,7 +135,7 @@ namespace bs
 			if (range != nullptr)
 			{
 				bool slider = false;
-				ScriptRange::getSliderField()->getValue(mMonoField->getAttribute(range), &slider);
+				ScriptRange::getSliderField()->get(mMonoField->getAttribute(range), &slider);
 				return slider;
 			}
 		}
@@ -151,7 +151,7 @@ namespace bs
 			if (step != nullptr)
 			{
 				float value = 0;
-				ScriptStep::getStepField()->getValue(mMonoField->getAttribute(step), &value);
+				ScriptStep::getStepField()->get(mMonoField->getAttribute(step), &value);
 				return value;
 			}
 		}
@@ -160,12 +160,12 @@ namespace bs
 
 	MonoObject* ManagedSerializableFieldInfo::getValue(MonoObject* instance) const
 	{
-		return mMonoField->getValueBoxed(instance);
+		return mMonoField->getBoxed(instance);
 	}
 
 	void ManagedSerializableFieldInfo::setValue(MonoObject* instance, void* value) const
 	{
-		mMonoField->setValue(instance, value);
+		mMonoField->set(instance, value);
 	}
 
 	RTTITypeBase* ManagedSerializableFieldInfo::getRTTIStatic()
@@ -192,7 +192,7 @@ namespace bs
 			if (range != nullptr)
 			{
 				float min = 0;
-				ScriptRange::getMinRangeField()->getValue(mMonoProperty->getAttribute(range), &min);
+				ScriptRange::getMinRangeField()->get(mMonoProperty->getAttribute(range), &min);
 				return min;
 			}
 		}
@@ -208,7 +208,7 @@ namespace bs
 			if (range != nullptr)
 			{
 				float max = 0;
-				ScriptRange::getMaxRangeField()->getValue(mMonoProperty->getAttribute(range), &max);
+				ScriptRange::getMaxRangeField()->get(mMonoProperty->getAttribute(range), &max);
 				return max;
 			}
 		}
@@ -224,7 +224,7 @@ namespace bs
 			if (range != nullptr)
 			{
 				bool slider = false;
-				ScriptRange::getSliderField()->getValue(mMonoProperty->getAttribute(range), &slider);
+				ScriptRange::getSliderField()->get(mMonoProperty->getAttribute(range), &slider);
 				return slider;
 			}
 		}
@@ -241,7 +241,7 @@ namespace bs
 			if (step != nullptr)
 			{
 				float value = 0;
-				ScriptStep::getStepField()->getValue(mMonoProperty->getAttribute(step), &value);
+				ScriptStep::getStepField()->get(mMonoProperty->getAttribute(step), &value);
 				return value;
 			}
 		}

+ 7 - 7
Source/SBansheeEngine/Source/BsScriptAnimation.cpp

@@ -241,14 +241,14 @@ namespace bs
 	{
 		BlendClipInfo output;
 
-		MonoObject* managedAnimClip = clipField->getValueBoxed(instance);
+		MonoObject* managedAnimClip = clipField->getBoxed(instance);
 		if(managedAnimClip)
 		{
 			ScriptAnimationClip* clip = ScriptAnimationClip::toNative(managedAnimClip);
 			output.clip = clip->getHandle();
 		}
 		
-		positionField->getValue(instance, &output.position);
+		positionField->get(instance, &output.position);
 
 		return output;
 	}
@@ -266,7 +266,7 @@ namespace bs
 
 	Blend1DInfo ScriptBlend1DInfo::fromManaged(MonoObject* instance)
 	{
-		MonoArray* managedClipsArray = (MonoArray*)clipsField->getValueBoxed(instance);
+		MonoArray* managedClipsArray = (MonoArray*)clipsField->getBoxed(instance);
 		if (managedClipsArray == nullptr)
 			return Blend1DInfo(0);
 
@@ -302,28 +302,28 @@ namespace bs
 	{
 		Blend2DInfo output;
 
-		MonoObject* managedTopLeftClip = topLeftClipField->getValueBoxed(instance);
+		MonoObject* managedTopLeftClip = topLeftClipField->getBoxed(instance);
 		if (managedTopLeftClip != nullptr)
 		{
 			ScriptAnimationClip* clip = ScriptAnimationClip::toNative(managedTopLeftClip);
 			output.topLeftClip = clip->getHandle();
 		}
 
-		MonoObject* managedTopRightClip = topRightClipField->getValueBoxed(instance);
+		MonoObject* managedTopRightClip = topRightClipField->getBoxed(instance);
 		if (managedTopRightClip != nullptr)
 		{
 			ScriptAnimationClip* clip = ScriptAnimationClip::toNative(managedTopRightClip);
 			output.topRightClip = clip->getHandle();
 		}
 
-		MonoObject* managedBotLeftClip = botLeftClipField->getValueBoxed(instance);
+		MonoObject* managedBotLeftClip = botLeftClipField->getBoxed(instance);
 		if (managedBotLeftClip != nullptr)
 		{
 			ScriptAnimationClip* clip = ScriptAnimationClip::toNative(managedBotLeftClip);
 			output.botLeftClip = clip->getHandle();
 		}
 
-		MonoObject* managedBotRightClip = botRightClipField->getValueBoxed(instance);
+		MonoObject* managedBotRightClip = botRightClipField->getBoxed(instance);
 		if (managedBotRightClip != nullptr)
 		{
 			ScriptAnimationClip* clip = ScriptAnimationClip::toNative(managedBotRightClip);

+ 2 - 2
Source/SBansheeEngine/Source/BsScriptAnimationClip.cpp

@@ -125,11 +125,11 @@ namespace bs
 		AnimationEvent output;
 
 		MonoString* monoName = nullptr;
-		sNameField->getValue(instance, &monoName);
+		sNameField->get(instance, &monoName);
 
 		output.name = MonoUtil::monoToString(monoName);
 
-		sTimeField->getValue(instance, &output.time);
+		sTimeField->get(instance, &output.time);
 
 		return output;
 	}

+ 18 - 18
Source/SBansheeEngine/Source/BsScriptAnimationCurves.cpp

@@ -37,7 +37,7 @@ namespace bs
 		SPtr<AnimationCurves> output = bs_shared_ptr_new<AnimationCurves>();
 
 		MonoArray* monoPosCurves;
-		sPositionCurvesField->getValue(instance, &monoPosCurves);
+		sPositionCurvesField->get(instance, &monoPosCurves);
 
 		if (monoPosCurves != nullptr)
 		{
@@ -50,7 +50,7 @@ namespace bs
 		}
 
 		MonoArray* monoRotCurves;
-		sRotationCurvesField->getValue(instance, &monoRotCurves);
+		sRotationCurvesField->get(instance, &monoRotCurves);
 
 		if (monoRotCurves != nullptr)
 		{
@@ -72,7 +72,7 @@ namespace bs
 		}
 
 		MonoArray* monoScaleCurves;
-		sScaleCurvesField->getValue(instance, &monoScaleCurves);
+		sScaleCurvesField->get(instance, &monoScaleCurves);
 
 		if (monoScaleCurves != nullptr)
 		{
@@ -85,7 +85,7 @@ namespace bs
 		}
 
 		MonoArray* monoFloatCurves;
-		sFloatCurvesField->getValue(instance, &monoFloatCurves);
+		sFloatCurvesField->get(instance, &monoFloatCurves);
 
 		if (monoFloatCurves != nullptr)
 		{
@@ -143,10 +143,10 @@ namespace bs
 		}
 
 		MonoObject* instance = metaData.scriptClass->createInstance();
-		sPositionCurvesField->setValue(instance, scriptPositionCurves.getInternal());
-		sRotationCurvesField->setValue(instance, scriptRotationCurves.getInternal());
-		sScaleCurvesField->setValue(instance, scriptScaleCurves.getInternal());
-		sFloatCurvesField->setValue(instance, scriptFloatCurves.getInternal());
+		sPositionCurvesField->set(instance, scriptPositionCurves.getInternal());
+		sRotationCurvesField->set(instance, scriptRotationCurves.getInternal());
+		sScaleCurvesField->set(instance, scriptScaleCurves.getInternal());
+		sFloatCurvesField->set(instance, scriptFloatCurves.getInternal());
 
 		return instance;
 	}
@@ -217,19 +217,19 @@ namespace bs
 		TNamedAnimationCurve<Vector3> output;
 
 		MonoString* monoName = nullptr;
-		sNameField->getValue(instance, &monoName);
+		sNameField->get(instance, &monoName);
 
 		output.name = MonoUtil::monoToString(monoName);
 
 		UINT32 flags;
-		sFlagsField->getValue(instance, &flags);
+		sFlagsField->get(instance, &flags);
 		output.flags = (AnimationCurveFlags)flags;
 
 		// Convert from three separate floating point curves, to a Vector3 curve
 		MonoObject* monoCurves[3];
-		sXCurveField->getValue(instance, &monoCurves[0]);
-		sYCurveField->getValue(instance, &monoCurves[1]);
-		sZCurveField->getValue(instance, &monoCurves[2]);
+		sXCurveField->get(instance, &monoCurves[0]);
+		sYCurveField->get(instance, &monoCurves[1]);
+		sZCurveField->get(instance, &monoCurves[2]);
 
 		SPtr<TAnimationCurve<float>> curves[3];
 
@@ -322,16 +322,16 @@ namespace bs
 		TNamedAnimationCurve<float> output;
 
 		MonoString* monoName = nullptr;
-		sNameField->getValue(instance, &monoName);
+		sNameField->get(instance, &monoName);
 
 		output.name = MonoUtil::monoToString(monoName);
 
 		UINT32 flags;
-		sFlagsField->getValue(instance, &flags);
+		sFlagsField->get(instance, &flags);
 		output.flags = (AnimationCurveFlags)flags;
 
 		MonoObject* monoCurve = nullptr;
-		sCurveField->getValue(instance, &monoCurve);
+		sCurveField->get(instance, &monoCurve);
 
 		if(monoCurve != nullptr)
 		{
@@ -412,8 +412,8 @@ namespace bs
 		MonoObject* monoRotationCurve = ScriptQuaternionCurve::toManaged(rootMotion->rotation);
 
 		MonoObject* instance = metaData.scriptClass->createInstance();
-		sPositionField->setValue(instance, monoPositionCurve);
-		sRotationField->setValue(instance, monoRotationCurve);
+		sPositionField->set(instance, monoPositionCurve);
+		sRotationField->set(instance, monoRotationCurve);
 
 		return instance;
 	}

+ 3 - 3
Source/SBansheeEngine/Source/BsScriptGUIContent.cpp

@@ -31,7 +31,7 @@ namespace bs
 	const HString& ScriptGUIContent::getText(MonoObject* instance)
 	{
 		MonoObject* textManaged = nullptr;
-		mTextField->getValue(instance, &textManaged);
+		mTextField->get(instance, &textManaged);
 
 		if(textManaged == nullptr)
 			return HString::dummy();
@@ -43,7 +43,7 @@ namespace bs
 	const HString& ScriptGUIContent::getTooltip(MonoObject* instance)
 	{
 		MonoObject* tooltipManaged = nullptr;
-		mTooltipField->getValue(instance, &tooltipManaged);
+		mTooltipField->get(instance, &tooltipManaged);
 
 		if(tooltipManaged == nullptr)
 			return HString::dummy();
@@ -55,7 +55,7 @@ namespace bs
 	GUIContentImages ScriptGUIContent::getImage(MonoObject* instance)
 	{
 		MonoObject* imagesManaged = nullptr;
-		mImagesField->getValue(instance, &imagesManaged);
+		mImagesField->get(instance, &imagesManaged);
 
 		if(imagesManaged == nullptr)
 			return GUIContentImages();

+ 2 - 2
Source/SBansheeEngine/Source/BsScriptGUIContentImages.cpp

@@ -60,7 +60,7 @@ namespace bs
 		for (auto& entry : entries)
 		{
 			MonoObject* managedImage;
-			entry.field->getValue(instance, &managedImage);
+			entry.field->get(instance, &managedImage);
 
 			if (managedImage != nullptr)
 				entry.outputImage = ScriptSpriteTexture::toNative(managedImage)->getHandle();
@@ -103,7 +103,7 @@ namespace bs
 				managedImage = scriptImage->getManagedInstance();
 			}
 
-			entry.field->setValue(output, managedImage);
+			entry.field->set(output, managedImage);
 		}
 
 		return output;

+ 1 - 1
Source/SBansheeEngine/Source/BsScriptGUIWidget.cpp

@@ -25,7 +25,7 @@ namespace bs
 		MonoObject* guiPanel = ScriptGUIPanel::createFromExisting(mGUIWidget->getPanel());
 		mPanel = ScriptGUILayout::toNative(guiPanel);
 
-		sGUIPanelField->setValue(managedInstance, guiPanel);
+		sGUIPanelField->set(managedInstance, guiPanel);
 	}
 
 	ScriptGUIWidget::~ScriptGUIWidget()

+ 58 - 58
Source/SBansheeEngine/Source/BsScriptPostProcessSettings.cpp

@@ -39,14 +39,14 @@ namespace bs
 	{
 		SPtr<AutoExposureSettings> output = bs_shared_ptr_new<AutoExposureSettings>();
 
-		sHistogramLog2Min->getValue(object, &output->histogramLog2Min);
-		sHistogramLog2Max->getValue(object, &output->histogramLog2Max);
-		sHistogramPctLow->getValue(object, &output->histogramPctLow);
-		sHistogramPctHigh->getValue(object, &output->histogramPctHigh);
-		sMinEyeAdaptation->getValue(object, &output->minEyeAdaptation);
-		sMaxEyeAdaptation->getValue(object, &output->maxEyeAdaptation);
-		sEyeAdaptationSpeedUp->getValue(object, &output->eyeAdaptationSpeedUp);
-		sEyeAdaptationSpeedDown->getValue(object, &output->eyeAdaptationSpeedDown);
+		sHistogramLog2Min->get(object, &output->histogramLog2Min);
+		sHistogramLog2Max->get(object, &output->histogramLog2Max);
+		sHistogramPctLow->get(object, &output->histogramPctLow);
+		sHistogramPctHigh->get(object, &output->histogramPctHigh);
+		sMinEyeAdaptation->get(object, &output->minEyeAdaptation);
+		sMaxEyeAdaptation->get(object, &output->maxEyeAdaptation);
+		sEyeAdaptationSpeedUp->get(object, &output->eyeAdaptationSpeedUp);
+		sEyeAdaptationSpeedDown->get(object, &output->eyeAdaptationSpeedDown);
 
 		return output;
 	}
@@ -55,14 +55,14 @@ namespace bs
 	{
 		MonoObject* object = metaData.scriptClass->createInstance();
 
-		sHistogramLog2Min->setValue(object, &value.histogramLog2Min);
-		sHistogramLog2Max->setValue(object, &value.histogramLog2Max);
-		sHistogramPctLow->setValue(object, &value.histogramPctLow);
-		sHistogramPctHigh->setValue(object, &value.histogramPctHigh);
-		sMinEyeAdaptation->setValue(object, &value.minEyeAdaptation);
-		sMaxEyeAdaptation->setValue(object, &value.maxEyeAdaptation);
-		sEyeAdaptationSpeedUp->setValue(object, &value.eyeAdaptationSpeedUp);
-		sEyeAdaptationSpeedDown->setValue(object, &value.eyeAdaptationSpeedDown);
+		sHistogramLog2Min->set(object, &value.histogramLog2Min);
+		sHistogramLog2Max->set(object, &value.histogramLog2Max);
+		sHistogramPctLow->set(object, &value.histogramPctLow);
+		sHistogramPctHigh->set(object, &value.histogramPctHigh);
+		sMinEyeAdaptation->set(object, &value.minEyeAdaptation);
+		sMaxEyeAdaptation->set(object, &value.maxEyeAdaptation);
+		sEyeAdaptationSpeedUp->set(object, &value.eyeAdaptationSpeedUp);
+		sEyeAdaptationSpeedDown->set(object, &value.eyeAdaptationSpeedDown);
 
 		return object;
 	}
@@ -94,13 +94,13 @@ namespace bs
 	{
 		SPtr<TonemappingSettings> output = bs_shared_ptr_new<TonemappingSettings>();
 
-		sFilmicCurveShoulderStrength->getValue(object, &output->filmicCurveShoulderStrength);
-		sFilmicCurveLinearStrength->getValue(object, &output->filmicCurveLinearStrength);
-		sFilmicCurveLinearAngle->getValue(object, &output->filmicCurveLinearAngle);
-		sFilmicCurveToeStrength->getValue(object, &output->filmicCurveToeStrength);
-		sFilmicCurveToeNumerator->getValue(object, &output->filmicCurveToeNumerator);
-		sFilmicCurveToeDenominator->getValue(object, &output->filmicCurveToeDenominator);
-		sFilmicCurveLinearWhitePoint->getValue(object, &output->filmicCurveLinearWhitePoint);
+		sFilmicCurveShoulderStrength->get(object, &output->filmicCurveShoulderStrength);
+		sFilmicCurveLinearStrength->get(object, &output->filmicCurveLinearStrength);
+		sFilmicCurveLinearAngle->get(object, &output->filmicCurveLinearAngle);
+		sFilmicCurveToeStrength->get(object, &output->filmicCurveToeStrength);
+		sFilmicCurveToeNumerator->get(object, &output->filmicCurveToeNumerator);
+		sFilmicCurveToeDenominator->get(object, &output->filmicCurveToeDenominator);
+		sFilmicCurveLinearWhitePoint->get(object, &output->filmicCurveLinearWhitePoint);
 
 		return output;
 	}
@@ -109,13 +109,13 @@ namespace bs
 	{
 		MonoObject* object = metaData.scriptClass->createInstance();
 
-		sFilmicCurveShoulderStrength->setValue(object, &value.filmicCurveShoulderStrength);
-		sFilmicCurveLinearStrength->setValue(object, &value.filmicCurveLinearStrength);
-		sFilmicCurveLinearAngle->setValue(object, &value.filmicCurveLinearAngle);
-		sFilmicCurveToeStrength->setValue(object, &value.filmicCurveToeStrength);
-		sFilmicCurveToeNumerator->setValue(object, &value.filmicCurveToeNumerator);
-		sFilmicCurveToeDenominator->setValue(object, &value.filmicCurveToeDenominator);
-		sFilmicCurveLinearWhitePoint->setValue(object, &value.filmicCurveLinearWhitePoint);
+		sFilmicCurveShoulderStrength->set(object, &value.filmicCurveShoulderStrength);
+		sFilmicCurveLinearStrength->set(object, &value.filmicCurveLinearStrength);
+		sFilmicCurveLinearAngle->set(object, &value.filmicCurveLinearAngle);
+		sFilmicCurveToeStrength->set(object, &value.filmicCurveToeStrength);
+		sFilmicCurveToeNumerator->set(object, &value.filmicCurveToeNumerator);
+		sFilmicCurveToeDenominator->set(object, &value.filmicCurveToeDenominator);
+		sFilmicCurveLinearWhitePoint->set(object, &value.filmicCurveLinearWhitePoint);
 
 		return object;
 	}
@@ -137,8 +137,8 @@ namespace bs
 	{
 		SPtr<WhiteBalanceSettings> output = bs_shared_ptr_new<WhiteBalanceSettings>();
 
-		sTemperature->getValue(object, &output->temperature);
-		sTint->getValue(object, &output->tint);
+		sTemperature->get(object, &output->temperature);
+		sTint->get(object, &output->tint);
 
 		return output;
 	}
@@ -147,8 +147,8 @@ namespace bs
 	{
 		MonoObject* object = metaData.scriptClass->createInstance();
 
-		sTemperature->setValue(object, &value.temperature);
-		sTint->setValue(object, &value.tint);
+		sTemperature->set(object, &value.temperature);
+		sTint->set(object, &value.tint);
 
 		return object;
 	}
@@ -174,10 +174,10 @@ namespace bs
 	{
 		SPtr<ColorGradingSettings> output = bs_shared_ptr_new<ColorGradingSettings>();
 
-		sSaturation->getValue(object, &output->saturation);
-		sContrast->getValue(object, &output->contrast);
-		sGain->getValue(object, &output->gain);
-		sOffset->getValue(object, &output->offset);
+		sSaturation->get(object, &output->saturation);
+		sContrast->get(object, &output->contrast);
+		sGain->get(object, &output->gain);
+		sOffset->get(object, &output->offset);
 
 		return output;
 	}
@@ -186,10 +186,10 @@ namespace bs
 	{
 		MonoObject* object = metaData.scriptClass->createInstance();
 
-		sSaturation->setValue(object, &value.saturation);
-		sContrast->setValue(object, &value.contrast);
-		sGain->setValue(object, &value.gain);
-		sOffset->setValue(object, &value.offset);
+		sSaturation->set(object, &value.saturation);
+		sContrast->set(object, &value.contrast);
+		sGain->set(object, &value.gain);
+		sOffset->set(object, &value.offset);
 
 		return object;
 	}
@@ -225,25 +225,25 @@ namespace bs
 	{
 		SPtr<StandardPostProcessSettings> output = bs_shared_ptr_new<StandardPostProcessSettings>();
 
-		sEnableAutoExposure->getValue(object, &output->enableAutoExposure);
-		sEnableTonemapping->getValue(object, &output->enableTonemapping);
-		sExposureScale->getValue(object, &output->exposureScale);
-		sGamma->getValue(object, &output->gamma);
+		sEnableAutoExposure->get(object, &output->enableAutoExposure);
+		sEnableTonemapping->get(object, &output->enableTonemapping);
+		sExposureScale->get(object, &output->exposureScale);
+		sGamma->get(object, &output->gamma);
 
 		MonoObject* autoExposureMono;
-		sAutoExposure->getValue(object, &autoExposureMono);
+		sAutoExposure->get(object, &autoExposureMono);
 		output->autoExposure = *ScriptAutoExposureSettings::toNative(autoExposureMono);
 
 		MonoObject* tonemappingMono;
-		sTonemapping->getValue(object, &tonemappingMono);
+		sTonemapping->get(object, &tonemappingMono);
 		output->tonemapping = *ScriptTonemappingSettings::toNative(tonemappingMono);
 
 		MonoObject* whiteBalanceMono;
-		sWhiteBalance->getValue(object, &whiteBalanceMono);
+		sWhiteBalance->get(object, &whiteBalanceMono);
 		output->whiteBalance = *ScriptWhiteBalanceSettings::toNative(whiteBalanceMono);
 
 		MonoObject* colorGradingMono;
-		sColorGrading->getValue(object, &colorGradingMono);
+		sColorGrading->get(object, &colorGradingMono);
 		output->colorGrading = *ScriptColorGradingSettings::toNative(colorGradingMono);
 
 		return output;
@@ -253,22 +253,22 @@ namespace bs
 	{
 		MonoObject* object = metaData.scriptClass->createInstance();
 
-		sEnableAutoExposure->setValue(object, &value->enableAutoExposure);
-		sEnableTonemapping->setValue(object, &value->enableTonemapping);
-		sExposureScale->setValue(object, &value->exposureScale);
-		sGamma->setValue(object, &value->gamma);
+		sEnableAutoExposure->set(object, &value->enableAutoExposure);
+		sEnableTonemapping->set(object, &value->enableTonemapping);
+		sExposureScale->set(object, &value->exposureScale);
+		sGamma->set(object, &value->gamma);
 
 		MonoObject* autoExposureMono = ScriptAutoExposureSettings::toManaged(value->autoExposure);
-		sAutoExposure->setValue(object, autoExposureMono);
+		sAutoExposure->set(object, autoExposureMono);
 
 		MonoObject* tonemappingMono = ScriptTonemappingSettings::toManaged(value->tonemapping);
-		sTonemapping->setValue(object, tonemappingMono);
+		sTonemapping->set(object, tonemappingMono);
 
 		MonoObject* whiteBalanceMono = ScriptWhiteBalanceSettings::toManaged(value->whiteBalance);
-		sWhiteBalance->setValue(object, whiteBalanceMono);
+		sWhiteBalance->set(object, whiteBalanceMono);
 
 		MonoObject* colorGradingMono = ScriptColorGradingSettings::toManaged(value->colorGrading);
-		sColorGrading->setValue(object, colorGradingMono);
+		sColorGrading->set(object, colorGradingMono);
 
 		return object;
 	}

+ 1 - 1
Source/SBansheeEngine/Source/BsScriptSerializableObject.cpp

@@ -93,7 +93,7 @@ namespace bs
 			i++;
 		}
 
-		FieldsField->setValue(instance, scriptArray.getInternal());
+		FieldsField->set(instance, scriptArray.getInternal());
 
 		return nativeInstance;
 	}

+ 3 - 3
Source/SBansheeEngine/Source/BsScriptSkeleton.cpp

@@ -73,9 +73,9 @@ namespace bs
 		Matrix4 monoInvBindPose = invBindPose;
 
 		MonoObject* instance = metaData.scriptClass->createInstance();
-		sNameField->setValue(instance, monoName);
-		sParentField->setValue(instance, &parentIdx);
-		sInvBindPoseField->setValue(instance, &monoInvBindPose);
+		sNameField->set(instance, monoName);
+		sParentField->set(instance, &parentIdx);
+		sInvBindPoseField->set(instance, &monoInvBindPose);
 
 		return instance;
 	}