Browse Source

Documentation

Marko Pintera 10 years ago
parent
commit
eb562f23fc

+ 72 - 7
SBansheeEngine/Include/BsManagedComponent.h

@@ -8,24 +8,79 @@ namespace BansheeEngine
 {
 	struct ComponentBackupData;
 
+	/**
+	 * @brief	Component that internally wraps a managed component object
+	 *			that can be of user-defined type.
+	 */
 	class BS_SCR_BE_EXPORT ManagedComponent : public Component
 	{
 	public:
 		~ManagedComponent();
 
+		/**
+		 * @brief	Returns managed component object instance.
+		 */
 		MonoObject* getManagedInstance() const { return mManagedInstance; }
+
+		/**
+		 * @brief	Returns managed type of the component.
+		 */
 		MonoReflectionType* getRuntimeType() const { return mRuntimeType; }
 
+		/**
+		 * @brief	Returns namespace of the managed component.
+		 */
 		const String& getManagedNamespace() const { return mNamespace; }
+
+		/**
+		 * @brief	Returns type name of the managed component.
+		 */
 		const String& getManagedTypeName() const { return mTypeName; }
+
+		/**
+		 * @brief	Returns namespace and type name of the component in format "namespace.typename".
+		 */
 		const String& getManagedFullTypeName() const { return mFullTypeName; }
 
+		/**
+		 * @brief	Serializes the internal managed component.
+		 *
+		 * @param	clearExisting	Should the managed component handle be released. (Will trigger a finalizer
+		 *							if this is the last reference to it)
+		 * 
+		 * @return	An object containing the serialized component. You can provide this to ::restore
+		 *			method to re-create the original component.
+		 */
 		ComponentBackupData backup(bool clearExisting = true);
+
+		/**
+		 * @brief	Restores a component from previously serialized data.
+		 *
+		 * @param	instance	New instance of the managed component. Must be of the valid component type
+		 *						or of BansheeEngine.MissingComponent type if the original type is missing.
+		 * @param	data		Serialized managed component data that will be used for initializing
+		 *						the new managed instance.
+		 * @param	missingType	Is the component's type missing (can happen after assembly reload).
+		 *						If true then the serialized data will be stored internally until later
+		 *						date when user perhaps restores the type with another refresh.
+		 *						/p instance must be null if this is true.
+		 */
 		void restore(MonoObject* instance, const ComponentBackupData& data, bool missingType);
 
+		/**
+		 * @brief	Triggers the managed OnReset callback.
+		 */
 		void triggerOnReset();
 
 	private:
+		/**
+		 * @brief	Finalizes construction of the object. Must be called before use or when
+		 *			the managed component instance changes.
+		 *
+		 * @param	object	Managed component instance.
+		 */
+		void initialize(MonoObject* object);
+
 		typedef void(__stdcall *OnInitializedThunkDef) (MonoObject*, MonoException**);
 		typedef void(__stdcall *UpdateThunkDef) (MonoObject*, MonoException**);
 		typedef void(__stdcall *OnDestroyedThunkDef) (MonoObject*, MonoException**);
@@ -57,16 +112,23 @@ namespace BansheeEngine
 		friend class SceneObject;
 		friend class ScriptComponent;
 
-		/** Standard constructor.
-        */
 		ManagedComponent(const HSceneObject& parent, MonoReflectionType* runtimeType);
-		void initialize(MonoObject* object);
 
-		void onInitialized();
-		void onDestroyed();
+		/**
+		 * @copydoc	Component::onInitialized
+		 */
+		void onInitialized() override;
+
+		/**
+		 * @copydoc	Component::onDestroyed
+		 */
+		void onDestroyed() override;
 
 	public:
-		virtual void update();
+		/**
+		 * @copydoc	Component::update
+		 */
+		virtual void update() override;
 
 		/************************************************************************/
 		/* 								RTTI		                     		*/
@@ -74,12 +136,15 @@ namespace BansheeEngine
 	public:
 		friend class ManagedComponentRTTI;
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
+		virtual RTTITypeBase* getRTTI() const override;
 
 	protected:
 		ManagedComponent(); // Serialization only
 	};
 
+	/**
+	 * @brief	Contains serialized component data buffer.
+	 */
 	struct ComponentBackupData
 	{
 		UINT8* data;

+ 54 - 4
SBansheeEngine/Include/BsManagedResource.h

@@ -9,24 +9,71 @@ namespace BansheeEngine
 {
 	struct ResourceBackupData;
 
+	/**
+	 * @brief	Resource that internally wraps a managed resource object
+	 *			that can be of user-defined type.
+	 */
 	class BS_SCR_BE_EXPORT ManagedResource : public Resource
 	{
 	public:
-		void construct(MonoObject* object, const HManagedResource& myHandle);
-
+		/**
+		 * @brief	Returns the internal managed resource object.
+		 */
 		MonoObject* getManagedInstance() const { return mManagedInstance; }
 
+		/**
+		 * @brief	Serializes the internal managed resource.
+		 *
+		 * @param	clearExisting	Should the managed resource handle be released. (Will trigger a finalizer
+		 *							if this is the last reference to it)
+		 * 
+		 * @return	An object containing the serialized resource. You can provide this to ::restore
+		 *			method to re-create the original resource.
+		 */
 		ResourceBackupData backup(bool clearExisting = true);
+
+		/**
+		 * @brief	Restores a resource from previously serialized data.
+		 *
+		 * @param	instance	New instance of the managed resource. Must be of the valid resource type
+		 *						this object was originally created from. Can be null if the type cannot
+		 *						be found (can happen after an assembly refresh).
+		 * @param	data		Serialized managed resource data that will be used for initializing
+		 *						the new managed instance.
+		 */
 		void restore(MonoObject* instance, const ResourceBackupData& data);
 
+		/**
+		 * @brief	Creates a new managed resource wrapper from an actual managed
+		 *			resource object. Caller must ensure the provided instance
+		 *			actually derives from Resource class.
+		 */
 		static HManagedResource create(MonoObject* managedResource);
+
+		/**
+		 * @brief	Creates an empty managed resource wrapper pointing to no
+		 *			managed instance. You must call ::setHandle before use manually.
+		 */
 		static ManagedResourcePtr createEmpty();
 
 	private:
 		friend class ScriptManagedResource;
 
 		ManagedResource(MonoObject* managedInstance);
-		void destroy();
+
+		/**
+		 * @brief	Finalizes construction of the object. Must be called before use or when
+		 *			the managed resource instance changes.
+		 *
+		 * @param	object		Managed resource instance.
+		 * @param	myHandle	Handle to myself.
+		 */
+		void setHandle(MonoObject* object, const HManagedResource& myHandle);
+
+		/**
+		 * @copydoc	Resource::destroy
+		 */
+		void destroy() override;
 
 		MonoObject* mManagedInstance;
 		uint32_t mManagedHandle;
@@ -38,12 +85,15 @@ namespace BansheeEngine
 	public:
 		friend class ManagedResourceRTTI;
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
+		virtual RTTITypeBase* getRTTI() const override;
 
 	protected:
 		ManagedResource(); // Serialization only
 	};
 
+	/**
+	 * @brief	Contains serialized resource data buffer.
+	 */
 	struct ResourceBackupData
 	{
 		UINT8* data;

+ 10 - 0
SBansheeEngine/Include/BsManagedResourceManager.h

@@ -5,13 +5,23 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Keeps track of all loaded managed resources.
+	 */
 	class BS_SCR_BE_EXPORT ManagedResourceManager : public Module <ManagedResourceManager>
 	{
 	public:
 		ManagedResourceManager();
 		~ManagedResourceManager();
 
+		/**
+		 * @brief	Register a newly created managed resource.
+		 */
 		void registerManagedResource(const HManagedResource& resource);
+
+		/**
+		 * @brief	Unregister a managed resource that's about to be destroyed.
+		 */
 		void unregisterManagedResource(const HManagedResource& resource);
 
 	private:

+ 1 - 1
SBansheeEngine/Include/BsManagedResourceRTTI.h

@@ -44,7 +44,7 @@ namespace BansheeEngine
 
 			ResourcePtr mrPtr = std::static_pointer_cast<Resource>(mr->getThisPtr());
 			HManagedResource handle = static_resource_cast<ManagedResource>(gResources()._createResourceHandle(mrPtr));
-			mr->construct(serializableObject->getManagedInstance(), handle);
+			mr->setHandle(serializableObject->getManagedInstance(), handle);
 			mr->mRTTIData = nullptr;
 		}
 

+ 152 - 34
SBansheeEngine/Include/BsManagedSerializableObjectInfo.h

@@ -6,6 +6,9 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Valid serializable script types.
+	 */
 	enum class ScriptPrimitiveType
 	{
 		Bool,
@@ -38,20 +41,41 @@ namespace BansheeEngine
 		ComponentRef
 	};
 
+	/**
+	 * @brief	Flags that are used to further define
+	 *			a field in a managed serializable object.
+	 */
 	enum class ScriptFieldFlags
 	{
 		Serializable = 0x01,
 		Inspectable = 0x02
 	};
 
+	/**
+	 * @brief	Contains information about a type of a managed serializable object.
+	 */
 	class BS_SCR_BE_EXPORT ManagedSerializableTypeInfo : public IReflectable
 	{
 	public:
 		virtual ~ManagedSerializableTypeInfo() {}
 
+		/**
+		 * @brief	Checks if the current type matches the provided type.
+		 */
 		virtual bool matches(const ManagedSerializableTypeInfoPtr& typeInfo) const = 0;
+
+		/**
+		 * @brief	Checks does the managed type this object represents still exists.
+		 *
+		 * @note	e.g. If assemblies get refreshed user could have renamed or removed
+		 *			some types.
+		 */
 		virtual bool isTypeLoaded() const = 0;
 
+		/**
+		 * @brief	Returns the internal managed class of the type this object represents.
+		 *			Returns null if the type doesn't exist.
+		 */
 		virtual ::MonoClass* getMonoClass() const = 0;
 
 		/************************************************************************/
@@ -60,18 +84,31 @@ namespace BansheeEngine
 	public:
 		friend class ManagedSerializableTypeInfoRTTI;
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
+		virtual RTTITypeBase* getRTTI() const override;
 	};
 
+	/**
+	 * @brief	Contains information about a type of a managed serializable primitive (e.g. int, float, etc.).
+	 */
 	class BS_SCR_BE_EXPORT ManagedSerializableTypeInfoPrimitive : public ManagedSerializableTypeInfo
 	{
 	public:
-		ScriptPrimitiveType mType;
+		/**
+		 * @copydoc	ManagedSerializableTypeInfo::matches
+		 */
+		bool matches(const ManagedSerializableTypeInfoPtr& typeInfo) const override;
 
-		bool matches(const ManagedSerializableTypeInfoPtr& typeInfo) const;
-		bool isTypeLoaded() const;
+		/**
+		 * @copydoc	ManagedSerializableTypeInfo::isTypeLoaded
+		 */
+		bool isTypeLoaded() const override;
 
-		::MonoClass* getMonoClass() const;
+		/**
+		 * @copydoc	ManagedSerializableTypeInfo::getMonoClass
+		 */
+		::MonoClass* getMonoClass() const override;
+
+		ScriptPrimitiveType mType;
 
 		/************************************************************************/
 		/* 								RTTI		                     		*/
@@ -79,41 +116,67 @@ namespace BansheeEngine
 	public:
 		friend class ManagedSerializableTypeInfoPrimitiveRTTI;
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
+		virtual RTTITypeBase* getRTTI() const override;
 	};
 
+	/**
+	 * @brief	Contains information about a type of a managed serializable complex object (e.g. struct or class).
+	 */
 	class BS_SCR_BE_EXPORT ManagedSerializableTypeInfoObject : public ManagedSerializableTypeInfo
 	{
 	public:
+		/**
+		 * @copydoc	ManagedSerializableTypeInfo::matches
+		 */
+		bool matches(const ManagedSerializableTypeInfoPtr& typeInfo) const override;
+
+		/**
+		 * @copydoc	ManagedSerializableTypeInfo::isTypeLoaded
+		 */
+		bool isTypeLoaded() const override;
+
+		/**
+		 * @copydoc	ManagedSerializableTypeInfo::getMonoClass
+		 */
+		::MonoClass* getMonoClass() const override;
+
 		String mTypeNamespace;
 		String mTypeName;
 		bool mValueType;
 		UINT32 mTypeId;
 
-		bool matches(const ManagedSerializableTypeInfoPtr& typeInfo) const;
-		bool isTypeLoaded() const;
-
-		::MonoClass* getMonoClass() const;
-
 		/************************************************************************/
 		/* 								RTTI		                     		*/
 		/************************************************************************/
 	public:
 		friend class ManagedSerializableTypeInfoObjectRTTI;
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
+		virtual RTTITypeBase* getRTTI() const override;
 	};
 
+	/**
+	 * @brief	Contains information about a type of a managed serializable Array.
+	 */
 	class BS_SCR_BE_EXPORT ManagedSerializableTypeInfoArray : public ManagedSerializableTypeInfo
 	{
 	public:
-		ManagedSerializableTypeInfoPtr mElementType;
-		UINT32 mRank;
+		/**
+		 * @copydoc	ManagedSerializableTypeInfo::matches
+		 */
+		bool matches(const ManagedSerializableTypeInfoPtr& typeInfo) const override;
 
-		bool matches(const ManagedSerializableTypeInfoPtr& typeInfo) const;
-		bool isTypeLoaded() const;
+		/**
+		 * @copydoc	ManagedSerializableTypeInfo::isTypeLoaded
+		 */
+		bool isTypeLoaded() const override;
 
-		::MonoClass* getMonoClass() const;
+		/**
+		 * @copydoc	ManagedSerializableTypeInfo::getMonoClass
+		 */
+		::MonoClass* getMonoClass() const override;
+
+		ManagedSerializableTypeInfoPtr mElementType;
+		UINT32 mRank;
 
 		/************************************************************************/
 		/* 								RTTI		                     		*/
@@ -121,18 +184,31 @@ namespace BansheeEngine
 	public:
 		friend class ManagedSerializableTypeInfoArrayRTTI;
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
+		virtual RTTITypeBase* getRTTI() const override;
 	};
 
+	/**
+	 * @brief	Contains information about a type of a managed serializable List.
+	 */
 	class BS_SCR_BE_EXPORT ManagedSerializableTypeInfoList : public ManagedSerializableTypeInfo
 	{
 	public:
-		ManagedSerializableTypeInfoPtr mElementType;
+		/**
+		 * @copydoc	ManagedSerializableTypeInfo::matches
+		 */
+		bool matches(const ManagedSerializableTypeInfoPtr& typeInfo) const override;
+
+		/**
+		 * @copydoc	ManagedSerializableTypeInfo::isTypeLoaded
+		 */
+		bool isTypeLoaded() const override;
 
-		bool matches(const ManagedSerializableTypeInfoPtr& typeInfo) const;
-		bool isTypeLoaded() const;
+		/**
+		 * @copydoc	ManagedSerializableTypeInfo::getMonoClass
+		 */
+		::MonoClass* getMonoClass() const override;
 
-		::MonoClass* getMonoClass() const;
+		ManagedSerializableTypeInfoPtr mElementType;
 
 		/************************************************************************/
 		/* 								RTTI		                     		*/
@@ -140,19 +216,32 @@ namespace BansheeEngine
 	public:
 		friend class ManagedSerializableTypeInfoListRTTI;
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
+		virtual RTTITypeBase* getRTTI() const override;
 	};
 
+	/**
+	 * @brief	Contains information about a type of a managed serializable Dictionary.
+	 */
 	class BS_SCR_BE_EXPORT ManagedSerializableTypeInfoDictionary : public ManagedSerializableTypeInfo
 	{
 	public:
-		ManagedSerializableTypeInfoPtr mKeyType;
-		ManagedSerializableTypeInfoPtr mValueType;
+		/**
+		 * @copydoc	ManagedSerializableTypeInfo::matches
+		 */
+		bool matches(const ManagedSerializableTypeInfoPtr& typeInfo) const override;
 
-		bool matches(const ManagedSerializableTypeInfoPtr& typeInfo) const;
-		bool isTypeLoaded() const;
+		/**
+		 * @copydoc	ManagedSerializableTypeInfo::isTypeLoaded
+		 */
+		bool isTypeLoaded() const override;
 
-		::MonoClass* getMonoClass() const;
+		/**
+		 * @copydoc	ManagedSerializableTypeInfo::getMonoClass
+		 */
+		::MonoClass* getMonoClass() const override;
+
+		ManagedSerializableTypeInfoPtr mKeyType;
+		ManagedSerializableTypeInfoPtr mValueType;
 
 		/************************************************************************/
 		/* 								RTTI		                     		*/
@@ -160,14 +249,22 @@ namespace BansheeEngine
 	public:
 		friend class ManagedSerializableTypeInfoDictionaryRTTI;
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
+		virtual RTTITypeBase* getRTTI() const override;
 	};
 
+	/**
+	 * @brief	Contains data about a single field in a managed complex object.
+	 */
 	class BS_SCR_BE_EXPORT ManagedSerializableFieldInfo : public IReflectable
 	{
 	public:
 		ManagedSerializableFieldInfo();
 
+		/**
+		 * @brief	Determines should the field be serialized when serializing the parent object.
+		 */
+		bool isSerializable() const { return ((UINT32)mFlags & (UINT32)ScriptFieldFlags::Serializable) != 0; }
+
 		String mName;
 		UINT32 mFieldId;
 		UINT32 mParentTypeId;
@@ -177,23 +274,41 @@ namespace BansheeEngine
 
 		MonoField* mMonoField;
 
-		bool isSerializable() const { return ((UINT32)mFlags & (UINT32)ScriptFieldFlags::Serializable) != 0; }
-
 		/************************************************************************/
 		/* 								RTTI		                     		*/
 		/************************************************************************/
 	public:
 		friend class ManagedSerializableFieldInfoRTTI;
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
+		virtual RTTITypeBase* getRTTI() const override;
 	};
 
+	/**
+	 * @brief	Contains data about fields of a complex object, and the object's
+	 *			class hierarchy if it belongs to one.
+	 */
 	class BS_SCR_BE_EXPORT ManagedSerializableObjectInfo : public IReflectable
 	{
 	public:
 		ManagedSerializableObjectInfo();
 
+		/**
+		 * @brief	Returns the managed type name of the object's type, including the namespace in format
+		 *			"namespace.typename".
+		 */
 		String getFullTypeName() const { return mTypeInfo->mTypeNamespace + "." + mTypeInfo->mTypeName; }
+
+		/**
+		 * @brief	Attempts to find a field part of this object that matches the provided parameters.
+		 *
+		 * @param	fieldInfo		Object describing the managed field. Normally this will be a field
+		 *							that was deserialized and you need to ensure it still exists in
+		 *							its parent type, while retrieving the new field info.
+		 * @param	fieldTypeInfo	Type information about the type containing the object. Used for
+		 *							debug purposes to ensure the current object's type matches.
+		 *
+		 * @return	Found field info within this object, or null if not found.
+		 */
 		ManagedSerializableFieldInfoPtr findMatchingField(const ManagedSerializableFieldInfoPtr& fieldInfo,
 			const ManagedSerializableTypeInfoPtr& fieldTypeInfo) const;
 
@@ -212,9 +327,12 @@ namespace BansheeEngine
 	public:
 		friend class ManagedSerializableObjectInfoRTTI;
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
+		virtual RTTITypeBase* getRTTI() const override;
 	};
 
+	/**
+	 * @brief	Contains information about all managed serializable objects in a specific managed assembly.
+	 */
 	class BS_SCR_BE_EXPORT ManagedSerializableAssemblyInfo : public IReflectable
 	{
 	public:
@@ -229,6 +347,6 @@ namespace BansheeEngine
 	public:
 		friend class ManagedSerializableAssemblyInfoRTTI;
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
+		virtual RTTITypeBase* getRTTI() const override;
 	};
 }

+ 75 - 4
SBansheeEngine/Include/BsScriptAssemblyManager.h

@@ -7,28 +7,103 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Stores data about managed serializable objects in specified assemblies.
+	 */
 	class BS_SCR_BE_EXPORT ScriptAssemblyManager : public Module<ScriptAssemblyManager>
 	{
 	public:
 		ScriptAssemblyManager();
 		~ScriptAssemblyManager();
 
+		/**
+		 * @brief	Loads all information about managed serializable objects in an assembly with the specified name.
+		 *			Assembly must be currently loaded. Once the data has been loaded you will be able to call
+		 *			::getSerializableObjectInfo and ::hasSerializableObjectInfo to retrieve information about
+		 *			those objects. If an assembly already had data loaded it will be rebuilt.
+		 */
 		void loadAssemblyInfo(const String& assemblyName);
+
+		/**
+		 * @brief	Reloads assembly data for all assemblies that were previously loaded using
+		 *			::loadAssemblyInfo. Useful for quickly updating all data after an assembly reload.
+		 */
 		void refreshAssemblyInfo();
+
+		/**
+		 * @brief	Returns managed serializable object info for a specific managed type.
+		 *
+		 * @param	ns			Namespace of the type.
+		 * @param	typeName	Name of the type.
+		 * @param	outInfo		Output object containing information about the type if the type was found, unmodified otherwise.
+		 *
+		 * @return	True if the type was found, false otherwise.
+		 */
 		bool getSerializableObjectInfo(const String& ns, const String& typeName, std::shared_ptr<ManagedSerializableObjectInfo>& outInfo);
+
+		/**
+		 * @brief	Checks if the managed serializable object info for the specified type exists.
+		 *
+		 * @param	ns			Namespace of the type.
+		 * @param	typeName	Name of the type.
+		 *
+		 * @return	True if the object info was found, false otherwise.
+		 */
 		bool hasSerializableObjectInfo(const String& ns, const String& typeName);
 
+		/**
+		 * @brief	Returns names of all assemblies that currently have managed serializable object
+		 *			data loaded.
+		 */
 		Vector<String> getScriptAssemblies() const;
 
+		/**
+		 * @brief	Gets the managed class for System.Array type.
+		 */
 		MonoClass* getSystemArrayClass() const { return mSystemArrayClass; }
+
+		/**
+		 * @brief	Gets the managed class for System.Collections.Generic.List<T> type.
+		 */
 		MonoClass* getSystemGenericListClass() const { return mSystemGenericListClass; }
+
+		/**
+		 * @brief	Gets the managed class for System.Collections.Generic.Dictionary<T,U> type.
+		 */
 		MonoClass* getSystemGenericDictionaryClass() const { return mSystemGenericDictionaryClass; }
+
+		/**
+		 * @brief	Gets the managed class for BansheeEngine.Component type.
+		 */
 		MonoClass* getComponentClass() const { return mComponentClass; }
+
+		/**
+		 * @brief	Gets the managed class for BansheeEngine.MissingComponent type.
+		 */
 		MonoClass* getMissingComponentClass() const { return mMissingComponentClass; }
+
+		/**
+		 * @brief	Gets the managed class for BansheeEngine.SceneObject type.
+		 */
 		MonoClass* getSceneObjectClass() const { return mSceneObjectClass; }
 
+		/**
+		 * @brief	Generates or retrieves a type info object for the specified managed class,
+		 *			if the class is serializable.
+		 */
 		ManagedSerializableTypeInfoPtr determineType(MonoClass* monoClass);
 	private:
+		/**
+		 * @brief	Deletes all stored managed serializable object infos for all assemblies.
+		 */
+		void clearScriptObjects();
+
+		/**
+		 * @brief	Initializes the base managed types. These are the types we expect must
+		 *			exist in loaded assemblies as they're used for various common operations.
+		 */
+		void initializeBaseTypes();
+
 		UnorderedMap<String, std::shared_ptr<ManagedSerializableAssemblyInfo>> mAssemblyInfos;
 		bool mBaseTypesInitialized;
 
@@ -44,9 +119,5 @@ namespace BansheeEngine
 		MonoClass* mDontSerializeFieldAttribute;
 		MonoClass* mSerializeFieldAttribute;
 		MonoClass* mHideInInspectorAttribute;
-
-		void clearScriptObjects();
-
-		void initializeBaseTypes();
 	};
 }

+ 2 - 2
SBansheeEngine/Source/BsManagedResource.cpp

@@ -95,7 +95,7 @@ namespace BansheeEngine
 		newRes->initialize();
 
 		HManagedResource handle = static_resource_cast<ManagedResource>(gResources()._createResourceHandle(newRes));
-		newRes->construct(managedResource, handle);
+		newRes->setHandle(managedResource, handle);
 
 		return handle;
 	}
@@ -109,7 +109,7 @@ namespace BansheeEngine
 		return newRes;
 	}
 
-	void ManagedResource::construct(MonoObject* object, const HManagedResource& myHandle)
+	void ManagedResource::setHandle(MonoObject* object, const HManagedResource& myHandle)
 	{
 		mManagedInstance = object;
 		mManagedHandle = mono_gchandle_new(mManagedInstance, false);

+ 77 - 70
TODO.txt

@@ -39,9 +39,6 @@ Add "dirty object" system to C#. Each ScriptResource and ScriptGameObject should
  - Record all portions where objects & components get modified so I can mark them dirty, will likely need
     to use those some points for undo/redo
 
-TODO - Later - When building level for release make sure to clear all prefab diffs (possibly store them elsewhere in the first place)
-       - And all prefab instances should have updateFromPrefab called on them.
-
  Test (likely later once I have more editor functionality working):
   - If level save/load works
   - If drag and drop works, both ways, plus double-click to load level
@@ -55,78 +52,93 @@ Code quality improvements:
    but they're identical)
 
 ----------------------------------------------------------------------
-Polish stage 1
-
-Fix inspector crashes:
- - Try expanding/collapsing foldouts
- - Had one with invalid index in Layout.InsertElement called from InspectableObject.Update
-
-Test inspector selection, selecting a resource and adding/removing component updates
-Handle seems to lag behind the selected mesh
-ProjectLibrary seems to import some files on every start-up
-Crash on shutdown in mono_gchandle_free
-Material/Shader has no color type so I cannot know when to display normal vector and when color in inspector
-
-First screenshot work:
-- Additional menu bar items: 
- - File: Exit, Save Project, New Project, Open Project, Save Scene As
- - Edit: Undo/Redo, Cut/Copy/Paste/Duplicate/Delete(need to make sure it works in Hierarchy, with shortcuts), Frame Selected, Preferences, Play/Pause/Step
- - Assets (also add to context): Create(Folder, Material, Shader, Script, Prefab, GUI Skin), Show in explorer
- - Game Object (also add to context): Create(Empty, Empty Child, Camera, Renderable, Point/Spot/Directional Light), Apply prefab, Break prefab, Revert prefab
+Polish
+
+Ribek use:
+ - Camera, Renderable, Material, Texture inspector
+  - Material/Shader has no color type so I cannot know when to display normal vector and when color in inspector
+ - Project create/open window
+ - Load default layout on initial start
+ - Test release mode
+ - Test inspector selection, selecting a resource and adding/removing component updates
+ - Test level save/load (also test hidden & non-saveable scene objects)
+ - Ability to create assets in Project view (At least Material)
+ - Need a way to add scene objects and components (and remove them)
+  - Components adding should be only done by drag and dropping scripts to inspector (undoable)
+  - COmponent removal should be done by clicking X in inspector (undoable)
+  - Adding scene objects should be doable from context menu in Hierarchy, by dropping a Prefab or by main Menu (undoable)
+  - Deleting them should be doable by context menu in Hierarchy and Del keystroke (undoable)
+ - Hook up color picker to guicolor field
+ - (Optionally, needed for GUI editing) GUISkin resource inspector & a way to inspect and save the default editor skin
+   - Will need C# wrapper for GUISkin (and a way to assign the current skin to a window)
+
+First screenshot:
+ - Inspectors for array & list don't display headers for objects neatly
+ - Additional menu bar items: 
+  - File: Exit, Save Project, New Project, Open Project, Save Scene As
+  - Edit: Undo/Redo, Cut/Copy/Paste/Duplicate/Delete(need to make sure it works in Hierarchy, with shortcuts), Frame Selected, Preferences, Play/Pause/Step
+  - Assets (also add to context): Create(Folder, Material, Shader, Script, Prefab, GUI Skin), Show in explorer
+  - Game Object (also add to context): Create(Empty, Empty Child, Camera, Renderable, Point/Spot/Directional Light), Apply prefab, Break prefab, Revert prefab
    - Possibly create helper objects: Cube, Sphere, Plane, Quad, Capsule, Cylinder
- - Component (also add to inspector context): Camera, Renderable, Point/Spot/Directional light, all other components from scripts
- - Help - About, API Reference (link to site)
-- Camera & Renderable inspector
-- Normalize colors between project and hierarchy windows (both blue or both orange selection + same ping color)
-- (Optionally) New UI look (tabs, component/array containers, better buttons)
-- (Optionally) Console window
-
------------
-
-SceneTreeView
- - Hook up ping effect so it triggers when I select a resource or sceneobject
+  - Component (also add to inspector context): Camera, Renderable, Point/Spot/Directional light, all other components from scripts
+  - Help - About, API Reference (link to site)
+ - Normalize colors between project and hierarchy windows (both blue or both orange selection + same ping color)
+ - (Optionally) New UI look (tabs, component/array containers, better buttons)
+ - (Optionally) Console window
+
+Other polish:
+ - C# inspectors for Point/Spot/Directional light
+ - C# interface for Font
+ - SceneTreeView
+  - Hook up ping effect so it triggers when I select a resource or sceneobject
    - Add Selection::ping method to both C++ and C# and an Event that triggers when its called
- - See if it needs other enhancements (rename, delete all work properly? etc.)
- - Add copy/cut/paste/duplicate (with context menu)
- - Cannot deselect element by clicking on empty space
-
-Need a way to add scene objects and components (and remove them)
- - Components adding should be only done by drag and dropping scripts to inspector (undoable)
- - COmponent removal should be done by context menu in inspector (undoable)
- - Adding scene objects should be doable from context menu in Hierarchy, by dropping a Prefab or by main Menu (undoable)
- - Deleting them should be doable by context menu in Hierarchy and Del keystroke (undoable)
-
-Hook up color picker to guicolor field
-Add shortcut keys for view/move/rotate/scale
-Add "focus on object" key (F) - animate it: rotate camera towards then speed towards while zooming in
-Ortographic camera views (+ gizmo in scene view corner that shows camera orientation)
-Drag to select in scene view
-Update GUISlider so it works with the new style (and to have min/max limits, plus step size)
-
-Replace "minimize" button in tabbed title bar with maximize and make sure it works
-When I expand inspector elements and them come back to that object it should remember the previous state
- - Add a chaching mechanism to inspector (likely based on instance ID & property names)
-
-Make sure to persist EditorSettings
-Add copyright notices in all files & change license to GPL
-
-Later:
+  - See if it needs other enhancements (rename, delete all work properly? etc.)
+  - Add copy/cut/paste/duplicate (with context menu)
+  - Cannot deselect element by clicking on empty space
+  - Clicking on an already selected element should start rename
+ - Handle seems to lag behind the selected mesh
+ - ProjectLibrary seems to import some files on every start-up
+ - Crash on shutdown in mono_gchandle_free
+ - Add shortcut keys for view/move/rotate/scale
+ - Add "focus on object" key (F) - animate it: rotate camera towards then speed towards while zooming in
+ - Ortographic camera views (+ gizmo in scene view corner that shows camera orientation)
+ - Drag to select in scene view
+ - Update GUISlider so it works with the new style (and to have min/max limits, plus step size)
+ - Replace "minimize" button in tabbed title bar with maximize and make sure it works
+ - When I expand inspector elements and them come back to that object it should remember the previous state
+   - Add a chaching mechanism to inspector (likely based on instance ID & property names)
+ - Make sure to persist EditorSettings
+ - Import option inspectors for Texture, Mesh, Font
+ - DOck manager maximize doesn't work'
+
+Stage 2 polish:
+ - Inject an icon into an .exe (Win32 specific)
+ - Implement C# Resources system (described below)
+ - Prefabs
+ - Game window
+ - Game play/pause/step (+ save/restore objects on play/pause switch)
+ - Resource hotswap
+ - C# script compiling in editor
+ - VS integration
+ - When managed exception happens log an error and continue execution
+ - Game publishing (Build window, collect resources, output exe, default viewport)
+
+Finalizing:
+ - Add copyright notices in all files & change license to GPL
  - I could record undo/redo per-property using the new diff system
  - When building game make sure to go over texture resources and ensure they are saved in the valid format
    as we don't want to do format conversion at runtime (Not cruical, but it should be done eventually)
    - This should something similar to Unity where when changing the platform all resources get reimported
+ - When building level for release make sure to clear all prefab diffs (possibly store them elsewhere in the first place)
+   - And all prefab instances should have updateFromPrefab called on them.
  - Save the default editor layout somewhere and make sure its used on initial startup when no layout exists
- - Undo/Redo when breaking or reverting a scene object
-
-----------------------------------------------------------------------
-Simple stuff
- - Inject an icon into an .exe (Win32 specific)
- - C# wrapper for GUISkin (and a way to assign the current skin to a window)
+ - Undo/Redo when breaking or reverting a scene object (and in general test & finalize undo/redo system)
  - Move all the code files into subfolders so their hierarchy is similar to VS filters
- - Font doesn't have a C# interface
  - Get rid of PoolAlloc and other unused allocators (plus fix bs_new and others which have weird overloads)
- - Get rid of event callback from HString and figure out a better way
  - Splash screen
+ - Settings/Preferences window
+ - Documentation
+ - (Optionally) GUI tabbing to switch between elements
 
 ----------------------------------------------------------------------
 Resources
@@ -206,11 +218,6 @@ Got a crash on shutdown that was caused by locking a mutex in an Event destructo
 Issue happened when I closed the app via the X button (if that's relevant). It doesn't seem to happen always.
  - This is likely due to some other error. When VS finds an exception it triggers a dialog box which triggers the msg loop in-engine and causes another exception.
 
-Create a stack allocatable custom vector implementation and make getResourceDependencies and getCoreDependencies use it.
- - These methods are called often and cause allocations whenever they are.
-
-I shouldn't crash the app when a managed exception happens
-
 /*********************************************************************/
 /************************ LESS IMPORTANT *****************************/
 /*********************************************************************/