ソースを参照

Bugfix: Selecting an item in the Library window will no longer cause the full resource to load into memory
- Still not resolved for composite resources like Material and SpriteTexture

BearishSun 7 年 前
コミット
3563dee506

+ 19 - 29
Source/Scripting/MBansheeEditor/Inspectors/AudioClipInspector.cs

@@ -26,27 +26,24 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         protected internal override void Initialize()
         protected internal override void Initialize()
         {
         {
-            if (InspectedObject != null)
-            {
-                importOptions = GetImportOptions();
+            importOptions = GetImportOptions();
 
 
-                formatField.OnSelectionChanged += x => importOptions.Format = (AudioFormat)x;
-                readModeField.OnSelectionChanged += x => importOptions.ReadMode = (AudioReadMode)x;
-                bitDepthField.OnSelectionChanged += x => importOptions.BitDepth = (AudioBitDepth)x;
-                is3DField.OnChanged += x => importOptions.Is3D = x;
+            formatField.OnSelectionChanged += x => importOptions.Format = (AudioFormat)x;
+            readModeField.OnSelectionChanged += x => importOptions.ReadMode = (AudioReadMode)x;
+            bitDepthField.OnSelectionChanged += x => importOptions.BitDepth = (AudioBitDepth)x;
+            is3DField.OnChanged += x => importOptions.Is3D = x;
 
 
-                reimportButton.OnClick += TriggerReimport;
+            reimportButton.OnClick += TriggerReimport;
 
 
-                Layout.AddElement(formatField);
-                Layout.AddElement(readModeField);
-                Layout.AddElement(bitDepthField);
-                Layout.AddElement(is3DField);
-                Layout.AddSpace(10);
+            Layout.AddElement(formatField);
+            Layout.AddElement(readModeField);
+            Layout.AddElement(bitDepthField);
+            Layout.AddElement(is3DField);
+            Layout.AddSpace(10);
 
 
-                GUILayout reimportButtonLayout = Layout.AddLayoutX();
-                reimportButtonLayout.AddFlexibleSpace();
-                reimportButtonLayout.AddElement(reimportButton);
-            }
+            GUILayout reimportButtonLayout = Layout.AddLayoutX();
+            reimportButtonLayout.AddFlexibleSpace();
+            reimportButtonLayout.AddElement(reimportButton);
         }
         }
 
 
         /// <inheritdoc/>
         /// <inheritdoc/>
@@ -70,17 +67,13 @@ namespace BansheeEditor
         /// <returns>Audio clip import options object.</returns>
         /// <returns>Audio clip import options object.</returns>
         private AudioClipImportOptions GetImportOptions()
         private AudioClipImportOptions GetImportOptions()
         {
         {
-            AudioClip audioClip = InspectedObject as AudioClip;
             AudioClipImportOptions output = null;
             AudioClipImportOptions output = null;
 
 
-            if (audioClip != null)
+            LibraryEntry meshEntry = ProjectLibrary.GetEntry(InspectedResourcePath);
+            if (meshEntry != null && meshEntry.Type == LibraryEntryType.File)
             {
             {
-                LibraryEntry meshEntry = ProjectLibrary.GetEntry(ProjectLibrary.GetPath(audioClip));
-                if (meshEntry != null && meshEntry.Type == LibraryEntryType.File)
-                {
-                    FileEntry meshFileEntry = (FileEntry)meshEntry;
-                    output = meshFileEntry.Options as AudioClipImportOptions;
-                }
+                FileEntry meshFileEntry = (FileEntry)meshEntry;
+                output = meshFileEntry.Options as AudioClipImportOptions;
             }
             }
 
 
             if (output == null)
             if (output == null)
@@ -99,10 +92,7 @@ namespace BansheeEditor
         /// </summary>
         /// </summary>
         private void TriggerReimport()
         private void TriggerReimport()
         {
         {
-            AudioClip audioClip = (AudioClip)InspectedObject;
-            string resourcePath = ProjectLibrary.GetPath(audioClip);
-
-            ProjectLibrary.Reimport(resourcePath, importOptions, true);
+            ProjectLibrary.Reimport(InspectedResourcePath, importOptions, true);
         }
         }
     }
     }
 
 

+ 6 - 13
Source/Scripting/MBansheeEditor/Inspectors/FontInspector.cs

@@ -29,11 +29,8 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         protected internal override void Initialize()
         protected internal override void Initialize()
         {
         {
-            if (InspectedObject != null)
-            {
-                importOptions = GetImportOptions();
-                BuildGUI();
-            }
+            importOptions = GetImportOptions();
+            BuildGUI();
         }
         }
 
 
         /// <inheritdoc/>
         /// <inheritdoc/>
@@ -131,17 +128,13 @@ namespace BansheeEditor
         /// <returns>Font import options object.</returns>
         /// <returns>Font import options object.</returns>
         private FontImportOptions GetImportOptions()
         private FontImportOptions GetImportOptions()
         {
         {
-            Font font = InspectedObject as Font;
             FontImportOptions output = null;
             FontImportOptions output = null;
 
 
-            if (font != null)
+            LibraryEntry texEntry = ProjectLibrary.GetEntry(InspectedResourcePath);
+            if (texEntry != null && texEntry.Type == LibraryEntryType.File)
             {
             {
-                LibraryEntry texEntry = ProjectLibrary.GetEntry(ProjectLibrary.GetPath(font));
-                if (texEntry != null && texEntry.Type == LibraryEntryType.File)
-                {
-                    FileEntry texFileEntry = (FileEntry)texEntry;
-                    output = texFileEntry.Options as FontImportOptions;
-                }
+                FileEntry texFileEntry = (FileEntry)texEntry;
+                output = texFileEntry.Options as FontImportOptions;
             }
             }
 
 
             if (output == null)
             if (output == null)

+ 1 - 0
Source/Scripting/MBansheeEditor/Inspectors/GUISkinInspector.cs

@@ -23,6 +23,7 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         protected internal override void Initialize()
         protected internal override void Initialize()
         {
         {
+            LoadResource();
             BuildGUI();
             BuildGUI();
         }
         }
 
 

+ 2 - 0
Source/Scripting/MBansheeEditor/Inspectors/MaterialInspector.cs

@@ -22,6 +22,8 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         protected internal override void Initialize()
         protected internal override void Initialize()
         {
         {
+            LoadResource();
+
             Material material = InspectedObject as Material;
             Material material = InspectedObject as Material;
             if (material == null)
             if (material == null)
                 return;
                 return;

+ 7 - 17
Source/Scripting/MBansheeEditor/Inspectors/MeshInspector.cs

@@ -34,11 +34,8 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         protected internal override void Initialize()
         protected internal override void Initialize()
         {
         {
-            if (InspectedObject != null)
-            {
-                importOptions = GetImportOptions();
-                BuildGUI();
-            }
+            importOptions = GetImportOptions();
+            BuildGUI();
         }
         }
 
 
         /// <inheritdoc/>
         /// <inheritdoc/>
@@ -128,17 +125,13 @@ namespace BansheeEditor
         /// <returns>Mesh import options object.</returns>
         /// <returns>Mesh import options object.</returns>
         private MeshImportOptions GetImportOptions()
         private MeshImportOptions GetImportOptions()
         {
         {
-            Mesh mesh = InspectedObject as Mesh;
             MeshImportOptions output = null;
             MeshImportOptions output = null;
 
 
-            if (mesh != null)
+            LibraryEntry meshEntry = ProjectLibrary.GetEntry(InspectedResourcePath);
+            if (meshEntry != null && meshEntry.Type == LibraryEntryType.File)
             {
             {
-                LibraryEntry meshEntry = ProjectLibrary.GetEntry(ProjectLibrary.GetPath(mesh));
-                if (meshEntry != null && meshEntry.Type == LibraryEntryType.File)
-                {
-                    FileEntry meshFileEntry = (FileEntry)meshEntry;
-                    output = meshFileEntry.Options as MeshImportOptions;
-                }
+                FileEntry meshFileEntry = (FileEntry)meshEntry;
+                output = meshFileEntry.Options as MeshImportOptions;
             }
             }
 
 
             if (output == null)
             if (output == null)
@@ -157,12 +150,9 @@ namespace BansheeEditor
         /// </summary>
         /// </summary>
         private void TriggerReimport()
         private void TriggerReimport()
         {
         {
-            Mesh mesh = (Mesh)InspectedObject;
-            string resourcePath = ProjectLibrary.GetPath(mesh);
-
             importOptions.AnimationClipSplits = splitInfos;
             importOptions.AnimationClipSplits = splitInfos;
 
 
-            ProjectLibrary.Reimport(resourcePath, importOptions, true);
+            ProjectLibrary.Reimport(InspectedResourcePath, importOptions, true);
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 1 - 0
Source/Scripting/MBansheeEditor/Inspectors/PhysicsMaterialInspector.cs

@@ -22,6 +22,7 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         protected internal override void Initialize()
         protected internal override void Initialize()
         {
         {
+            LoadResource();
             BuildGUI();
             BuildGUI();
         }
         }
 
 

+ 2 - 0
Source/Scripting/MBansheeEditor/Inspectors/PlainTextInspector.cs

@@ -25,6 +25,8 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         protected internal override void Initialize()
         protected internal override void Initialize()
         {
         {
+            LoadResource();
+
             PlainText plainText = InspectedObject as PlainText;
             PlainText plainText = InspectedObject as PlainText;
             if (plainText == null)
             if (plainText == null)
                 return;
                 return;

+ 2 - 0
Source/Scripting/MBansheeEditor/Inspectors/ScriptCodeInspector.cs

@@ -27,6 +27,8 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         protected internal override void Initialize()
         protected internal override void Initialize()
         {
         {
+            LoadResource();
+
             ScriptCode scriptCode = InspectedObject as ScriptCode;
             ScriptCode scriptCode = InspectedObject as ScriptCode;
             if (scriptCode == null)
             if (scriptCode == null)
                 return;
                 return;

+ 2 - 0
Source/Scripting/MBansheeEditor/Inspectors/SpriteTextureInspector.cs

@@ -22,6 +22,8 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         protected internal override void Initialize()
         protected internal override void Initialize()
         {
         {
+            LoadResource();
+
             SpriteTexture spriteTexture = InspectedObject as SpriteTexture;
             SpriteTexture spriteTexture = InspectedObject as SpriteTexture;
             if (spriteTexture == null)
             if (spriteTexture == null)
                 return;
                 return;

+ 1 - 0
Source/Scripting/MBansheeEditor/Inspectors/StringTableInspector.cs

@@ -24,6 +24,7 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         protected internal override void Initialize()
         protected internal override void Initialize()
         {
         {
+            LoadResource();
             BuildGUI();
             BuildGUI();
         }
         }
 
 

+ 29 - 39
Source/Scripting/MBansheeEditor/Inspectors/TextureInspector.cs

@@ -31,33 +31,30 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         protected internal override void Initialize()
         protected internal override void Initialize()
         {
         {
-            if (InspectedObject != null)
-            {
-                importOptions = GetImportOptions();
-
-                formatField.OnSelectionChanged += x => importOptions.Format = (PixelFormat)x;
-                generateMipsField.OnChanged += x => importOptions.GenerateMipmaps = x;
-                maximumMipsField.OnChanged += x => importOptions.MaxMipmapLevel = x;
-                srgbField.OnChanged += x => importOptions.IsSRGB = x;
-                cpuCachedField.OnChanged += x => importOptions.CPUCached = x;
-                isCubemapField.OnChanged += x => importOptions.IsCubemap = x;
-                cubemapSourceTypeField.OnSelectionChanged += x => importOptions.CubemapSourceType = (CubemapSourceType)x;
-                reimportButton.OnClick += TriggerReimport;
-
-                Layout.AddElement(formatField);
-                Layout.AddElement(generateMipsField);
-                Layout.AddElement(maximumMipsField);
-                Layout.AddElement(srgbField);
-                Layout.AddElement(cpuCachedField);
-                Layout.AddElement(isCubemapField);
-                Layout.AddElement(cubemapSourceTypeField);
-                Layout.AddSpace(10);
-
-                GUILayout reimportButtonLayout = Layout.AddLayoutX();
-                reimportButtonLayout.AddFlexibleSpace();
-                reimportButtonLayout.AddElement(reimportButton);
-            }
-        }
+            importOptions = GetImportOptions();
+
+            formatField.OnSelectionChanged += x => importOptions.Format = (PixelFormat)x;
+            generateMipsField.OnChanged += x => importOptions.GenerateMipmaps = x;
+            maximumMipsField.OnChanged += x => importOptions.MaxMipmapLevel = x;
+            srgbField.OnChanged += x => importOptions.IsSRGB = x;
+            cpuCachedField.OnChanged += x => importOptions.CPUCached = x;
+            isCubemapField.OnChanged += x => importOptions.IsCubemap = x;
+            cubemapSourceTypeField.OnSelectionChanged += x => importOptions.CubemapSourceType = (CubemapSourceType)x;
+            reimportButton.OnClick += TriggerReimport;
+
+            Layout.AddElement(formatField);
+            Layout.AddElement(generateMipsField);
+            Layout.AddElement(maximumMipsField);
+            Layout.AddElement(srgbField);
+            Layout.AddElement(cpuCachedField);
+            Layout.AddElement(isCubemapField);
+            Layout.AddElement(cubemapSourceTypeField);
+            Layout.AddSpace(10);
+
+            GUILayout reimportButtonLayout = Layout.AddLayoutX();
+            reimportButtonLayout.AddFlexibleSpace();
+            reimportButtonLayout.AddElement(reimportButton);
+    }
 
 
         /// <inheritdoc/>
         /// <inheritdoc/>
         protected internal override InspectableState Refresh()
         protected internal override InspectableState Refresh()
@@ -85,17 +82,13 @@ namespace BansheeEditor
         /// <returns>Texture import options object.</returns>
         /// <returns>Texture import options object.</returns>
         private TextureImportOptions GetImportOptions()
         private TextureImportOptions GetImportOptions()
         {
         {
-            Texture texture = InspectedObject as Texture;
             TextureImportOptions output = null;
             TextureImportOptions output = null;
 
 
-            if (texture != null)
+            LibraryEntry texEntry = ProjectLibrary.GetEntry(InspectedResourcePath);
+            if (texEntry != null && texEntry.Type == LibraryEntryType.File)
             {
             {
-                LibraryEntry texEntry = ProjectLibrary.GetEntry(ProjectLibrary.GetPath(texture));
-                if (texEntry != null && texEntry.Type == LibraryEntryType.File)
-                {
-                    FileEntry texFileEntry = (FileEntry)texEntry;
-                    output = texFileEntry.Options as TextureImportOptions;
-                }
+                FileEntry texFileEntry = (FileEntry)texEntry;
+                output = texFileEntry.Options as TextureImportOptions;
             }
             }
 
 
             if (output == null)
             if (output == null)
@@ -114,10 +107,7 @@ namespace BansheeEditor
         /// </summary>
         /// </summary>
         private void TriggerReimport()
         private void TriggerReimport()
         {
         {
-            Texture texture = (Texture)InspectedObject;
-            string resourcePath = ProjectLibrary.GetPath(texture);
-
-            ProjectLibrary.Reimport(resourcePath, importOptions, true);
+            ProjectLibrary.Reimport(InspectedResourcePath, importOptions, true);
         }
         }
     }
     }
 
 

+ 3 - 0
Source/Scripting/MBansheeEditor/Windows/Inspector/GenericInspector.cs

@@ -21,6 +21,9 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         protected internal override void Initialize()
         protected internal override void Initialize()
         {
         {
+            if (InspectedObject == null)
+                LoadResource();
+
             if (InspectedObject != null)
             if (InspectedObject != null)
             {
             {
                 int currentIndex = 0;
                 int currentIndex = 0;

+ 53 - 4
Source/Scripting/MBansheeEditor/Windows/Inspector/Inspector.cs

@@ -33,13 +33,22 @@ namespace BansheeEditor
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Returns the object the inspector is currently displaying.
+        /// Returns the object the inspector is currently displaying. If the current object is a resource use
+        /// <see cref="InspectedResourcePath"/> instead;
         /// </summary>
         /// </summary>
         protected object InspectedObject
         protected object InspectedObject
         {
         {
             get { return inspectedObject; }
             get { return inspectedObject; }
         }
         }
 
 
+        /// <summary>
+        /// Returns the path to the resource the inspector is currently displaying.
+        /// </summary>
+        protected string InspectedResourcePath
+        {
+            get { return inspectedResourcePath; }
+        }
+
         /// <summary>
         /// <summary>
         /// A set of properties that the inspector can read/write. They will be persisted even after the inspector is closed
         /// A set of properties that the inspector can read/write. They will be persisted even after the inspector is closed
         /// and restored when it is re-opened.
         /// and restored when it is re-opened.
@@ -53,16 +62,16 @@ namespace BansheeEditor
         private GUIPanel mainPanel;
         private GUIPanel mainPanel;
         private GUILayoutY layout;
         private GUILayoutY layout;
         private object inspectedObject;
         private object inspectedObject;
+        private string inspectedResourcePath;
         private SerializableProperties persistent;
         private SerializableProperties persistent;
 
 
         /// <summary>
         /// <summary>
-        /// Initializes the inspector. Must be called after construction.
+        /// Common code called by both Initialize() overloads.
         /// </summary>
         /// </summary>
         /// <param name="gui">GUI panel to add the GUI elements to.</param>
         /// <param name="gui">GUI panel to add the GUI elements to.</param>
-        /// <param name="instance">Instance of the object whose fields to display GUI for.</param>
         /// <param name="persistent">A set of properties that the inspector can read/write. They will be persisted even 
         /// <param name="persistent">A set of properties that the inspector can read/write. They will be persisted even 
         ///                          after the inspector is closed and restored when it is re-opened.</param>
         ///                          after the inspector is closed and restored when it is re-opened.</param>
-        internal virtual void Initialize(GUIPanel gui, object instance, SerializableProperties persistent)
+        private void InitializeBase(GUIPanel gui, SerializableProperties persistent)
         {
         {
             rootGUI = gui;
             rootGUI = gui;
             this.persistent = persistent;
             this.persistent = persistent;
@@ -81,12 +90,52 @@ namespace BansheeEditor
 
 
             mainPanel = contentPanel;
             mainPanel = contentPanel;
             layout = GUI.AddLayoutY();
             layout = GUI.AddLayoutY();
+        }
+
+        /// <summary>
+        /// Initializes the inspector using an object instance. Must be called after construction.
+        /// </summary>
+        /// <param name="gui">GUI panel to add the GUI elements to.</param>
+        /// <param name="instance">Instance of the object whose fields to display GUI for.</param>
+        /// <param name="persistent">A set of properties that the inspector can read/write. They will be persisted even 
+        ///                          after the inspector is closed and restored when it is re-opened.</param>
+        internal virtual void Initialize(GUIPanel gui, object instance, SerializableProperties persistent)
+        {
+            InitializeBase(gui, persistent);
+
             inspectedObject = instance;
             inspectedObject = instance;
 
 
             Initialize();
             Initialize();
             Refresh();
             Refresh();
         }
         }
 
 
+        /// <summary>
+        /// Initializes the inspector using a resource path. Must be called after construction.
+        /// </summary>
+        /// <param name="gui">GUI panel to add the GUI elements to.</param>
+        /// <param name="path">Path to the resource for which to display GUI for.</param>
+        /// <param name="persistent">A set of properties that the inspector can read/write. They will be persisted even 
+        ///                          after the inspector is closed and restored when it is re-opened.</param>
+        internal virtual void Initialize(GUIPanel gui, string path, SerializableProperties persistent)
+        {
+            InitializeBase(gui, persistent);
+
+            inspectedResourcePath = path;
+
+            Initialize();
+            Refresh();
+        }
+
+        /// <summary>
+        /// Loads the currently inspected resource into the <see cref="InspectedObject"/> field. By default resources
+        /// are not loaded and you can only retrieve their path through <see cref="InspectedResourcePath"/>.
+        /// </summary>
+        protected void LoadResource()
+        {
+            if(!string.IsNullOrEmpty(inspectedResourcePath))
+                inspectedObject = ProjectLibrary.Load<Resource>(inspectedResourcePath);
+        }
+
         /// <summary>
         /// <summary>
         /// Hides or shows the inspector GUI elements.
         /// Hides or shows the inspector GUI elements.
         /// </summary>
         /// </summary>

+ 11 - 9
Source/Scripting/MBansheeEditor/Windows/Inspector/InspectorWindow.cs

@@ -85,7 +85,7 @@ namespace BansheeEditor
         private Rect2I[] dropAreas = new Rect2I[0];
         private Rect2I[] dropAreas = new Rect2I[0];
 
 
         private InspectorType currentType = InspectorType.None;
         private InspectorType currentType = InspectorType.None;
-        private Resource activeResource;
+        private string activeResourcePath;
 
 
         /// <summary>
         /// <summary>
         /// Opens the inspector window from the menu bar.
         /// Opens the inspector window from the menu bar.
@@ -111,11 +111,13 @@ namespace BansheeEditor
         /// <param name="resourcePath">Resource path relative to the project of the resource to inspect.</param>
         /// <param name="resourcePath">Resource path relative to the project of the resource to inspect.</param>
         private void SetObjectToInspect(String resourcePath)
         private void SetObjectToInspect(String resourcePath)
         {
         {
-            activeResource = ProjectLibrary.Load<Resource>(resourcePath);
-
-            if (activeResource == null)
+            activeResourcePath = resourcePath;
+            if (!ProjectLibrary.Exists(resourcePath))
                 return;
                 return;
 
 
+            ResourceMeta meta = ProjectLibrary.GetMeta(resourcePath);
+            Type resourceType = meta.Type;
+
             currentType = InspectorType.Resource;
             currentType = InspectorType.Resource;
 
 
             inspectorScrollArea = new GUIScrollArea();
             inspectorScrollArea = new GUIScrollArea();
@@ -129,7 +131,7 @@ namespace BansheeEditor
             titleLayout.SetPosition(PADDING, PADDING);
             titleLayout.SetPosition(PADDING, PADDING);
 
 
             string name = Path.GetFileNameWithoutExtension(resourcePath);
             string name = Path.GetFileNameWithoutExtension(resourcePath);
-            string type = activeResource.GetType().Name;
+            string type = resourceType.Name;
 
 
             LocString title = new LocEdString(name + " (" + type + ")");
             LocString title = new LocEdString(name + " (" + type + ")");
             GUILabel titleLabel = new GUILabel(title);
             GUILabel titleLabel = new GUILabel(title);
@@ -149,10 +151,10 @@ namespace BansheeEditor
             inspectorResource = new InspectorResource();
             inspectorResource = new InspectorResource();
             inspectorResource.panel = inspectorLayout.AddPanel();
             inspectorResource.panel = inspectorLayout.AddPanel();
 
 
-            var persistentProperties = persistentData.GetProperties(activeResource.UUID.ToString());
+            var persistentProperties = persistentData.GetProperties(meta.UUID.ToString());
 
 
-            inspectorResource.inspector = InspectorUtility.GetInspector(activeResource.GetType());
-            inspectorResource.inspector.Initialize(inspectorResource.panel, activeResource, persistentProperties);
+            inspectorResource.inspector = InspectorUtility.GetInspector(resourceType);
+            inspectorResource.inspector.Initialize(inspectorResource.panel, activeResourcePath, persistentProperties);
 
 
             inspectorLayout.AddFlexibleSpace();
             inspectorLayout.AddFlexibleSpace();
         }
         }
@@ -753,7 +755,7 @@ namespace BansheeEditor
             soScaleZ = null;
             soScaleZ = null;
             dropAreas = new Rect2I[0];
             dropAreas = new Rect2I[0];
 
 
-            activeResource = null;
+            activeResourcePath = null;
             currentType = InspectorType.None;
             currentType = InspectorType.None;
         }
         }
 
 

+ 8 - 0
Source/Scripting/MBansheeEditor/Windows/Library/ProjectLibrary.cs

@@ -584,6 +584,11 @@ namespace BansheeEditor
         /// </summary>
         /// </summary>
         public ResourceType ResType { get { return Internal_GetResourceType(mCachedPtr); } }
         public ResourceType ResType { get { return Internal_GetResourceType(mCachedPtr); } }
 
 
+        /// <summary>
+        /// Type information of the resource referenced by this entry.
+        /// </summary>
+        public Type Type { get { return Internal_GetType(mCachedPtr); } }
+
         /// <summary>
         /// <summary>
         /// Non-specific data assigned to the resource, available in editor only.
         /// Non-specific data assigned to the resource, available in editor only.
         /// </summary>
         /// </summary>
@@ -601,6 +606,9 @@ namespace BansheeEditor
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern ResourceType Internal_GetResourceType(IntPtr thisPtr);
         private static extern ResourceType Internal_GetResourceType(IntPtr thisPtr);
 
 
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Type Internal_GetType(IntPtr thisPtr);
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern object Internal_GetEditorData(IntPtr thisPtr);
         private static extern object Internal_GetEditorData(IntPtr thisPtr);
     }
     }

+ 28 - 0
Source/Scripting/SBansheeEditor/Wrappers/BsScriptProjectLibrary.cpp

@@ -14,6 +14,7 @@
 #include "BsEditorApplication.h"
 #include "BsEditorApplication.h"
 #include "Serialization/BsManagedSerializableObject.h"
 #include "Serialization/BsManagedSerializableObject.h"
 #include "Reflection/BsRTTIType.h"
 #include "Reflection/BsRTTIType.h"
+#include "BsManagedResourceMetaData.h"
 
 
 using namespace std::placeholders;
 using namespace std::placeholders;
 
 
@@ -515,6 +516,7 @@ namespace bs
 		metaData.scriptClass->addInternalCall("Internal_GetSubresourceName", (void*)&ScriptResourceMeta::internal_GetSubresourceName);
 		metaData.scriptClass->addInternalCall("Internal_GetSubresourceName", (void*)&ScriptResourceMeta::internal_GetSubresourceName);
 		metaData.scriptClass->addInternalCall("Internal_GetIcon", (void*)&ScriptResourceMeta::internal_GetIcon);
 		metaData.scriptClass->addInternalCall("Internal_GetIcon", (void*)&ScriptResourceMeta::internal_GetIcon);
 		metaData.scriptClass->addInternalCall("Internal_GetResourceType", (void*)&ScriptResourceMeta::internal_GetResourceType);
 		metaData.scriptClass->addInternalCall("Internal_GetResourceType", (void*)&ScriptResourceMeta::internal_GetResourceType);
+		metaData.scriptClass->addInternalCall("Internal_GetType", (void*)&ScriptResourceMeta::internal_GetType);
 		metaData.scriptClass->addInternalCall("Internal_GetEditorData", (void*)&ScriptResourceMeta::internal_GetEditorData);
 		metaData.scriptClass->addInternalCall("Internal_GetEditorData", (void*)&ScriptResourceMeta::internal_GetEditorData);
 	}
 	}
 
 
@@ -543,6 +545,32 @@ namespace bs
 		return resInfo->resType;
 		return resInfo->resType;
 	}
 	}
 
 
+	MonoReflectionType* ScriptResourceMeta::internal_GetType(ScriptResourceMeta* thisPtr)
+	{
+		const UINT32 typeId = thisPtr->mMeta->getTypeID();
+		if(typeId == TID_ManagedResource)
+		{
+			const auto metaData = std::static_pointer_cast<ManagedResourceMetaData>(thisPtr->mMeta->getResourceMetaData());
+
+			if(metaData)
+			{
+				MonoClass* providedClass = MonoManager::instance().findClass(metaData->typeNamespace, metaData->typeName);
+
+				if(providedClass)
+					return MonoUtil::getType(providedClass->_getInternalClass());
+			}
+		}
+		else
+		{
+			BuiltinResourceInfo* resInfo = ScriptAssemblyManager::instance().getBuiltinResourceInfo(thisPtr->mMeta->getTypeID());
+
+			if (resInfo)
+				return MonoUtil::getType(resInfo->metaData->scriptClass->_getInternalClass());
+		}
+
+		return nullptr;
+	}
+
 	MonoObject* ScriptResourceMeta::internal_GetEditorData(ScriptResourceMeta* thisPtr)
 	MonoObject* ScriptResourceMeta::internal_GetEditorData(ScriptResourceMeta* thisPtr)
 	{
 	{
 		SPtr<IReflectable> userData = thisPtr->mMeta->getUserData();
 		SPtr<IReflectable> userData = thisPtr->mMeta->getUserData();

+ 1 - 0
Source/Scripting/SBansheeEditor/Wrappers/BsScriptProjectLibrary.h

@@ -175,6 +175,7 @@ namespace bs
 		static MonoString* internal_GetSubresourceName(ScriptResourceMeta* thisPtr);
 		static MonoString* internal_GetSubresourceName(ScriptResourceMeta* thisPtr);
 		static MonoObject* internal_GetIcon(ScriptResourceMeta* thisPtr);
 		static MonoObject* internal_GetIcon(ScriptResourceMeta* thisPtr);
 		static ScriptResourceType internal_GetResourceType(ScriptResourceMeta* thisPtr);
 		static ScriptResourceType internal_GetResourceType(ScriptResourceMeta* thisPtr);
+		static MonoReflectionType* internal_GetType(ScriptResourceMeta* thisPtr);
 		static MonoObject* internal_GetEditorData(ScriptResourceMeta* thisPtr);
 		static MonoObject* internal_GetEditorData(ScriptResourceMeta* thisPtr);
 	};
 	};
 
 

+ 1 - 1
Source/Scripting/SBansheeEngine/BsManagedResourceMetaData.h

@@ -24,7 +24,7 @@ namespace bs
 	public:
 	public:
 		friend class ManagedResourceMetaDataRTTI;
 		friend class ManagedResourceMetaDataRTTI;
 		static RTTITypeBase* getRTTIStatic();
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
+		RTTITypeBase* getRTTI() const override;
 	};
 	};
 
 
 	/** @} */
 	/** @} */