Просмотр исходного кода

Removed different texture types from managed code, and replaced everything with a single Texture class, so it better matches C++

BearishSun 8 лет назад
Родитель
Сommit
a2da2fe804
48 измененных файлов с 399 добавлено и 1136 удалено
  1. 1 1
      Source/MBansheeEditor/Inspectors/FontInspector.cs
  2. 3 23
      Source/MBansheeEditor/Inspectors/MaterialInspector.cs
  3. 1 1
      Source/MBansheeEditor/Inspectors/SpriteTextureInspector.cs
  4. 5 5
      Source/MBansheeEditor/Inspectors/TextureInspector.cs
  5. 2 2
      Source/MBansheeEditor/MBansheeEditor.csproj
  6. 6 6
      Source/MBansheeEditor/Windows/ColorPicker.cs
  7. 2 2
      Source/MBansheeEditor/Windows/Library/ProjectLibrary.cs
  8. 0 1
      Source/MBansheeEditor/Windows/Scene/SceneCamera.cs
  9. 2 2
      Source/MBansheeEditor/Windows/Scene/SceneWindow.cs
  10. 2 2
      Source/MBansheeEngine/GUI/Font.cs
  11. 5 5
      Source/MBansheeEngine/GUI/SpriteTexture.cs
  12. 0 3
      Source/MBansheeEngine/MBansheeEngine.csproj
  13. 10 70
      Source/MBansheeEngine/Rendering/Material.cs
  14. 10 10
      Source/MBansheeEngine/Rendering/RenderTexture2D.cs
  15. 172 0
      Source/MBansheeEngine/Rendering/Texture.cs
  16. 0 115
      Source/MBansheeEngine/Rendering/Texture2D.cs
  17. 0 110
      Source/MBansheeEngine/Rendering/Texture3D.cs
  18. 0 111
      Source/MBansheeEngine/Rendering/TextureCube.cs
  19. 2 3
      Source/SBansheeEditor/Source/BsScriptGUITextureField.cpp
  20. 1 3
      Source/SBansheeEditor/Source/BsScriptPlatformInfo.cpp
  21. 0 1
      Source/SBansheeEditor/Source/BsScriptProjectLibrary.cpp
  22. 0 6
      Source/SBansheeEngine/CMakeSources.cmake
  23. 1 3
      Source/SBansheeEngine/Include/BsManagedSerializableObjectInfo.h
  24. 1 4
      Source/SBansheeEngine/Include/BsScriptEnginePrerequisites.h
  25. 2 6
      Source/SBansheeEngine/Include/BsScriptMaterial.h
  26. 1 1
      Source/SBansheeEngine/Include/BsScriptRenderTexture2D.h
  27. 0 4
      Source/SBansheeEngine/Include/BsScriptResourceManager.h
  28. 0 8
      Source/SBansheeEngine/Include/BsScriptResourceRef.h
  29. 1 1
      Source/SBansheeEngine/Include/BsScriptSpriteTexture.h
  30. 14 15
      Source/SBansheeEngine/Include/BsScriptTexture.h
  31. 0 42
      Source/SBansheeEngine/Include/BsScriptTexture2D.h
  32. 0 41
      Source/SBansheeEngine/Include/BsScriptTexture3D.h
  33. 0 41
      Source/SBansheeEngine/Include/BsScriptTextureCube.h
  34. 3 11
      Source/SBansheeEngine/Source/BsManagedSerializableField.cpp
  35. 4 12
      Source/SBansheeEngine/Source/BsManagedSerializableObjectInfo.cpp
  36. 3 9
      Source/SBansheeEngine/Source/BsScriptAssemblyManager.cpp
  37. 1 1
      Source/SBansheeEngine/Source/BsScriptCamera.cpp
  38. 3 3
      Source/SBansheeEngine/Source/BsScriptFontBitmap.cpp
  39. 6 64
      Source/SBansheeEngine/Source/BsScriptMaterial.cpp
  40. 6 6
      Source/SBansheeEngine/Source/BsScriptRenderTexture2D.cpp
  41. 2 5
      Source/SBansheeEngine/Source/BsScriptResource.cpp
  42. 5 38
      Source/SBansheeEngine/Source/BsScriptResourceManager.cpp
  43. 1 18
      Source/SBansheeEngine/Source/BsScriptResourceRef.cpp
  44. 4 4
      Source/SBansheeEngine/Source/BsScriptSpriteTexture.cpp
  45. 117 2
      Source/SBansheeEngine/Source/BsScriptTexture.cpp
  46. 0 117
      Source/SBansheeEngine/Source/BsScriptTexture2D.cpp
  47. 0 100
      Source/SBansheeEngine/Source/BsScriptTexture3D.cpp
  48. 0 98
      Source/SBansheeEngine/Source/BsScriptTextureCube.cpp

+ 1 - 1
Source/MBansheeEditor/Inspectors/FontInspector.cs

@@ -160,7 +160,7 @@ namespace BansheeEditor
         /// </summary>
         private void TriggerReimport()
         {
-            Texture2D texture = (Texture2D)InspectedObject;
+            Texture texture = (Texture)InspectedObject;
             string resourcePath = ProjectLibrary.GetPath(texture);
 
             ProjectLibrary.Reimport(resourcePath, importOptions, true);

+ 3 - 23
Source/MBansheeEditor/Inspectors/MaterialInspector.cs

@@ -592,29 +592,13 @@ namespace BansheeEditor
             switch (shaderParam.Type)
             {
                 case ShaderParameterType.Texture2D:
-                    guiElem.OnChanged += (x) =>
-                    {
-                        Texture2D texture = Resources.Load<Texture2D>(x);
-
-                        material.SetTexture2D(shaderParam.Name, texture);
-                        EditorApplication.SetDirty(material);
-                    };
-                    break;
                 case ShaderParameterType.Texture3D:
-                    guiElem.OnChanged += (x) =>
-                    {
-                        Texture3D texture = Resources.Load<Texture3D>(x);
-
-                        material.SetTexture3D(shaderParam.Name, texture);
-                        EditorApplication.SetDirty(material);
-                    };
-                    break;
                 case ShaderParameterType.TextureCube:
                     guiElem.OnChanged += (x) =>
                     {
-                        TextureCube texture = Resources.Load<TextureCube>(x);
+                        Texture texture = Resources.Load<Texture>(x);
 
-                        material.SetTextureCube(shaderParam.Name, texture);
+                        material.SetTexture(shaderParam.Name, texture);
                         EditorApplication.SetDirty(material);
                     };
                     break;
@@ -630,13 +614,9 @@ namespace BansheeEditor
             switch (shaderParam.Type)
             {
                 case ShaderParameterType.Texture2D:
-                    value = material.GetTexture2D(shaderParam.Name);
-                    break;
                 case ShaderParameterType.Texture3D:
-                    value = material.GetTexture3D(shaderParam.Name);
-                    break;
                 case ShaderParameterType.TextureCube:
-                    value = material.GetTextureCube(shaderParam.Name);
+                    value = material.GetTexture(shaderParam.Name);
                     break;
             }
 

+ 1 - 1
Source/MBansheeEditor/Inspectors/SpriteTextureInspector.cs

@@ -28,7 +28,7 @@ namespace BansheeEditor
 
             textureField.OnChanged += (x) =>
             {
-                Texture2D texture = Resources.Load<Texture2D>(x);
+                Texture texture = Resources.Load<Texture>(x);
                 spriteTexture.Texture = texture;
                 EditorApplication.SetDirty(spriteTexture);
             };

+ 5 - 5
Source/MBansheeEditor/Inspectors/Texture2DInspector.cs → Source/MBansheeEditor/Inspectors/TextureInspector.cs

@@ -10,10 +10,10 @@ namespace BansheeEditor
      */
 
     /// <summary>
-    /// Renders an inspector for the <see cref="Texture2D"/> resource.
+    /// Renders an inspector for the <see cref="Texture"/> resource.
     /// </summary>
-    [CustomInspector(typeof(Texture2D))]
-    internal class Texture2DInspector : Inspector
+    [CustomInspector(typeof(Texture))]
+    internal class TextureInspector : Inspector
     {
         private GUIEnumField formatField = new GUIEnumField(typeof(PixelFormat), new LocEdString("Format"));
         private GUIToggleField generateMipsField = new GUIToggleField(new LocEdString("Generate mipmaps"));
@@ -85,7 +85,7 @@ namespace BansheeEditor
         /// <returns>Texture import options object.</returns>
         private TextureImportOptions GetImportOptions()
         {
-            Texture2D texture = InspectedObject as Texture2D;
+            Texture texture = InspectedObject as Texture;
             TextureImportOptions output = null;
 
             if (texture != null)
@@ -114,7 +114,7 @@ namespace BansheeEditor
         /// </summary>
         private void TriggerReimport()
         {
-            Texture2D texture = (Texture2D)InspectedObject;
+            Texture texture = (Texture)InspectedObject;
             string resourcePath = ProjectLibrary.GetPath(texture);
 
             ProjectLibrary.Reimport(resourcePath, importOptions, true);

+ 2 - 2
Source/MBansheeEditor/MBansheeEditor.csproj

@@ -129,7 +129,7 @@
     <Compile Include="Inspectors\ShaderInspector.cs" />
     <Compile Include="Inspectors\SpriteTextureInspector.cs" />
     <Compile Include="Inspectors\StringTableInspector.cs" />
-    <Compile Include="Inspectors\Texture2DInspector.cs" />
+    <Compile Include="Inspectors\TextureInspector.cs" />
     <Compile Include="Windows\Inspector\InspectableDictionary.cs" />
     <Compile Include="Windows\Inspector\InspectorPersistentData.cs" />
     <Compile Include="Windows\Inspector\InspectorUtility.cs" />
@@ -224,7 +224,7 @@
     <Compile Include="Tests\UnitTests.cs" />
     <Compile Include="Tests\UnitTestTypes.cs" />
     <Compile Include="Window\UndoRedoLocal.cs" />
-	<Compile Include="Generated\*.cs"/>
+    <Compile Include="Generated\*.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\MBansheeEngine\MBansheeEngine.csproj">

+ 6 - 6
Source/MBansheeEditor/Windows/ColorPicker.cs

@@ -912,7 +912,7 @@ namespace BansheeEditor
             private const int SLIDER_Y_OFFSET = 5;
 
             private int width, height;
-            private Texture2D texture;
+            private Texture texture;
             private SpriteTexture spriteTexture;
 
             private GUITexture guiTexture;
@@ -933,7 +933,7 @@ namespace BansheeEditor
                 this.guiTexture = guiTexture;
                 this.guiSlider = guiSlider;
 
-                texture = new Texture2D(width, height);
+                texture = Texture.Create2D(width, height);
                 spriteTexture = new SpriteTexture(texture);
             }
 
@@ -976,7 +976,7 @@ namespace BansheeEditor
             private const int SLIDER_Y_OFFSET = 3;
 
             private int width, height;
-            private Texture2D texture;
+            private Texture texture;
             private SpriteTexture spriteTexture;
 
             private GUITexture guiTexture;
@@ -997,7 +997,7 @@ namespace BansheeEditor
                 this.guiTexture = guiTexture;
                 this.guiSlider = guiSlider;
 
-                texture = new Texture2D(width, height);
+                texture = Texture.Create2D(width, height);
                 spriteTexture = new SpriteTexture(texture);
             }
 
@@ -1038,7 +1038,7 @@ namespace BansheeEditor
         public class ColorSlider2D
         {
             private int width, height;
-            private Texture2D texture;
+            private Texture texture;
             private SpriteTexture spriteTexture;
 
             private GUITexture guiTexture;
@@ -1065,7 +1065,7 @@ namespace BansheeEditor
                 this.guiTexture = guiTexture;
                 this.guiSliderHandle = guiSliderHandle;
 
-                texture = new Texture2D(width, height);
+                texture = Texture.Create2D(width, height);
                 spriteTexture = new SpriteTexture(texture);
             }
 

+ 2 - 2
Source/MBansheeEditor/Windows/Library/ProjectLibrary.cs

@@ -570,7 +570,7 @@ namespace BansheeEditor
         /// <summary>
         /// Custom icon for the resource to display in the editor, if the resource has one.
         /// </summary>
-        public Texture2D Icon { get { return Internal_GetIcon(mCachedPtr); } }
+        public Texture Icon { get { return Internal_GetIcon(mCachedPtr); } }
 
         /// <summary>
         /// Type of the resource referenced by this entry.
@@ -589,7 +589,7 @@ namespace BansheeEditor
         private static extern string Internal_GetSubresourceName(IntPtr thisPtr);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern Texture2D Internal_GetIcon(IntPtr thisPtr);
+        private static extern Texture Internal_GetIcon(IntPtr thisPtr);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern ResourceType Internal_GetResourceType(IntPtr thisPtr);

+ 0 - 1
Source/MBansheeEditor/Windows/Scene/SceneCamera.cs

@@ -136,7 +136,6 @@ namespace BansheeEditor
         private void OnReset()
         {
             camera = SceneObject.GetComponent<Camera>();
-            camera.NoLighting = true;
 
             moveForwardBtn = new VirtualButton(MoveForwardBinding);
             moveLeftBtn = new VirtualButton(MoveLeftBinding);

+ 2 - 2
Source/MBansheeEditor/Windows/Scene/SceneWindow.cs

@@ -854,8 +854,8 @@ namespace BansheeEditor
             height = MathEx.Max(20, height);
 
             // Note: Depth buffer and readable flags are required because ScenePicking uses it
-            Texture2D colorTex = new Texture2D(width, height, PixelFormat.R8G8B8A8, TextureUsage.Render | TextureUsage.CPUReadable);
-            Texture2D depthTex = new Texture2D(width, height, PixelFormat.D32_S8X24, TextureUsage.DepthStencil | TextureUsage.CPUReadable);
+            Texture colorTex = Texture.Create2D(width, height, PixelFormat.R8G8B8A8, TextureUsage.Render | TextureUsage.CPUReadable);
+            Texture depthTex = Texture.Create2D(width, height, PixelFormat.D32_S8X24, TextureUsage.DepthStencil | TextureUsage.CPUReadable);
 
             renderTexture = new RenderTexture2D(colorTex, depthTex);
             renderTexture.Priority = 1;

+ 2 - 2
Source/MBansheeEngine/GUI/Font.cs

@@ -88,7 +88,7 @@ namespace BansheeEngine
         /// <summary>
         /// Textures in which the character's pixels are stored.
         /// </summary>
-        public Texture2D[] Pages { get { return Internal_GetPages(mCachedPtr); } }
+        public Texture[] Pages { get { return Internal_GetPages(mCachedPtr); } }
 
         /// <summary>
         /// Returns a description of the character in the bitmap.
@@ -130,7 +130,7 @@ namespace BansheeEngine
         private static extern void Internal_GetMissingChar(IntPtr instance, out CharDesc output);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern Texture2D[] Internal_GetPages(IntPtr instance);
+        private static extern Texture[] Internal_GetPages(IntPtr instance);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_GetChar(IntPtr instance, int id, out CharDesc output);

+ 5 - 5
Source/MBansheeEngine/GUI/SpriteTexture.cs

@@ -25,7 +25,7 @@ namespace BansheeEngine
         /// Creates a new sprite texture that references the entire area of the provided texture.
         /// </summary>
         /// <param name="texture">Texture to wrap by the sprite texture.</param>
-        public SpriteTexture(Texture2D texture)
+        public SpriteTexture(Texture texture)
         {
             Vector2 offset = Vector2.Zero;
             Vector2 scale = Vector2.One;
@@ -40,7 +40,7 @@ namespace BansheeEngine
         /// <param name="uvOffset">Top-left position of the area used by the sprite texture, in normalized coordinates.
         ///                        </param>
         /// <param name="uvScale">Size of the area used by the sprite texture, in normalized coordinates.</param>
-        public SpriteTexture(Texture2D texture, Vector2 uvOffset, Vector2 uvScale)
+        public SpriteTexture(Texture texture, Vector2 uvOffset, Vector2 uvScale)
         {
             Internal_CreateInstance(this, texture, ref uvOffset, ref uvScale);
         }
@@ -48,7 +48,7 @@ namespace BansheeEngine
         /// <summary>
         /// Texture that the sprite texture references.
         /// </summary>
-        public Texture2D Texture
+        public Texture Texture
         {
             get { return Internal_GetTexture(mCachedPtr); }
             set
@@ -97,10 +97,10 @@ namespace BansheeEngine
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_CreateInstance(SpriteTexture instance, 
-            Texture2D texture, ref Vector2 offset, ref Vector2 scale);
+            Texture texture, ref Vector2 offset, ref Vector2 scale);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern Texture2D Internal_GetTexture(IntPtr thisPtr);
+        private static extern Texture Internal_GetTexture(IntPtr thisPtr);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_SetTexture(IntPtr thisPtr, IntPtr value);

+ 0 - 3
Source/MBansheeEngine/MBansheeEngine.csproj

@@ -204,12 +204,9 @@
     <Compile Include="GUI\StringTable.cs" />
     <Compile Include="GUI\StringTables.cs" />
     <Compile Include="Rendering\Texture.cs" />
-    <Compile Include="Rendering\Texture2D.cs" />
     <Compile Include="Math\Vector2.cs" />
     <Compile Include="Math\Vector3.cs" />
     <Compile Include="Math\Vector4.cs" />
-    <Compile Include="Rendering\Texture3D.cs" />
-    <Compile Include="Rendering\TextureCube.cs" />
     <Compile Include="Utility\Time.cs" />
     <Compile Include="Input\VirtualInput.cs" />
     <Compile Include="Generated\*.cs" />

+ 10 - 70
Source/MBansheeEngine/Rendering/Material.cs

@@ -131,47 +131,19 @@ namespace BansheeEngine
         }
 
         /// <summary>
-        /// Assigns a 2D texture to the shader parameter with the specified name.
+        /// Assigns a texture to the shader parameter with the specified name.
         /// </summary>
         /// <param name="name">Name of the shader parameter.</param>
         /// <param name="value">Value of the parameter.</param>
-        public void SetTexture2D(string name, Texture2D value)
+        public void SetTexture(string name, Texture value)
         {
             IntPtr texturePtr = IntPtr.Zero;
             if (value != null)
                 texturePtr = value.GetCachedPtr();
 
-            Internal_SetTexture2D(mCachedPtr, name, texturePtr);
+            Internal_SetTexture(mCachedPtr, name, texturePtr);
         }
-
-        /// <summary>
-        /// Assigns a 3D texture to the shader parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <param name="value">Value of the parameter.</param>
-        public void SetTexture3D(string name, Texture3D value)
-        {
-            IntPtr texturePtr = IntPtr.Zero;
-            if (value != null)
-                texturePtr = value.GetCachedPtr();
-
-            Internal_SetTexture3D(mCachedPtr, name, texturePtr);
-        }
-
-        /// <summary>
-        /// Assigns a cube texture to the shader parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <param name="value">Value of the parameter.</param>
-        public void SetTextureCube(string name, TextureCube value)
-        {
-            IntPtr texturePtr = IntPtr.Zero;
-            if (value != null)
-                texturePtr = value.GetCachedPtr();
-
-            Internal_SetTextureCube(mCachedPtr, name, texturePtr);
-        }
-
+        
         /// <summary>
         /// Returns a float value assigned with the parameter with the specified name.
         /// </summary>
@@ -255,35 +227,15 @@ namespace BansheeEngine
         }
 
         /// <summary>
-        /// Returns a 2D texture assigned with the parameter with the specified name.
+        /// Returns a texture assigned with the parameter with the specified name.
         /// </summary>
         /// <param name="name">Name of the shader parameter.</param>
         /// <returns>Value of the parameter.</returns>
-        public Texture2D GetTexture2D(string name)
+        public Texture GetTexture(string name)
         {
-            return Internal_GetTexture2D(mCachedPtr, name);
+            return Internal_GetTexture(mCachedPtr, name);
         }
-
-        /// <summary>
-        /// Returns a 3D texture assigned with the parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <returns>Value of the parameter.</returns>
-        public Texture3D GetTexture3D(string name)
-        {
-            return Internal_GetTexture3D(mCachedPtr, name);
-        }
-
-        /// <summary>
-        /// Returns a cube texture assigned with the parameter with the specified name.
-        /// </summary>
-        /// <param name="name">Name of the shader parameter.</param>
-        /// <returns>Value of the parameter.</returns>
-        public TextureCube GetTextureCube(string name)
-        {
-            return Internal_GetTextureCube(mCachedPtr, name);
-        }
-
+        
         /// <summary>
         /// Creates a deep copy of the material.
         /// </summary>
@@ -324,13 +276,7 @@ namespace BansheeEngine
         private static extern void Internal_SetColor(IntPtr nativeInstance, string name, ref Color value);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetTexture2D(IntPtr nativeInstance, string name, IntPtr value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetTexture3D(IntPtr nativeInstance, string name, IntPtr value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetTextureCube(IntPtr nativeInstance, string name, IntPtr value);
+        private static extern void Internal_SetTexture(IntPtr nativeInstance, string name, IntPtr value);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern float Internal_GetFloat(IntPtr nativeInstance, string name);
@@ -354,13 +300,7 @@ namespace BansheeEngine
         private static extern void Internal_GetColor(IntPtr nativeInstance, string name, out Color value);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern Texture2D Internal_GetTexture2D(IntPtr nativeInstance, string name);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern Texture3D Internal_GetTexture3D(IntPtr nativeInstance, string name);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern TextureCube Internal_GetTextureCube(IntPtr nativeInstance, string name);
+        private static extern Texture Internal_GetTexture(IntPtr nativeInstance, string name);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern Material Internal_Clone(IntPtr nativeInstance);

+ 10 - 10
Source/MBansheeEngine/Rendering/RenderTexture2D.cs

@@ -37,7 +37,7 @@ namespace BansheeEngine
         /// </summary>
         /// <param name="colorSurface">Color texture to render color data to.</param>
         /// <param name="depthStencilSurface">Optional depth/stencil texture to render depth/stencil data to.</param>
-        public RenderTexture2D(Texture2D colorSurface, Texture2D depthStencilSurface = null)
+        public RenderTexture2D(Texture colorSurface, Texture depthStencilSurface = null)
         {
             IntPtr[] colorSurfaceInstances = new IntPtr[1];
             colorSurfaceInstances[0] = colorSurface.GetCachedPtr();
@@ -54,7 +54,7 @@ namespace BansheeEngine
         /// </summary>
         /// <param name="colorSurfaces">Color texture(s) to render color data to. </param>
         /// <param name="depthStencilSurface">>Optional depth/stencil texture to render depth/stencil data to.</param>
-        public RenderTexture2D(Texture2D[] colorSurfaces, Texture2D depthStencilSurface = null)
+        public RenderTexture2D(Texture[] colorSurfaces, Texture depthStencilSurface = null)
         {
             IntPtr[] colorSurfaceInstances = new IntPtr[colorSurfaces.Length];
 
@@ -71,11 +71,11 @@ namespace BansheeEngine
         /// <summary>
         /// Returns the primary color surface that contains rendered color data.
         /// </summary>
-        public Texture2D colorSurface
+        public Texture colorSurface
         {
             get
             {
-                Texture2D[] surfaces;
+                Texture[] surfaces;
                 Internal_GetColorSurfaces(mCachedPtr, out surfaces);
                 return surfaces[0];
             }
@@ -84,11 +84,11 @@ namespace BansheeEngine
         /// <summary>
         /// Returns all of the color surfaces.
         /// </summary>
-        public Texture2D[] colorSurfaces
+        public Texture[] colorSurfaces
         {
             get
             {
-                Texture2D[] surfaces;
+                Texture[] surfaces;
                 Internal_GetColorSurfaces(mCachedPtr, out surfaces);
                 return surfaces;
             }
@@ -97,11 +97,11 @@ namespace BansheeEngine
         /// <summary>
         /// Returns the depth/stencil surface that contains rendered depth and stencil data.
         /// </summary>
-        public Texture2D depthStencilSurface
+        public Texture depthStencilSurface
         {
             get
             {
-                Texture2D surface;
+                Texture surface;
                 Internal_GetDepthStencilSurface(mCachedPtr, out surface);
                 return surface;
             }
@@ -115,10 +115,10 @@ namespace BansheeEngine
         private static extern void Internal_Create(RenderTexture2D instance, IntPtr[] colorSurfaces, IntPtr depthStencilSurface);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetColorSurfaces(IntPtr thisPtr, out Texture2D[] surfaces);
+        private static extern void Internal_GetColorSurfaces(IntPtr thisPtr, out Texture[] surfaces);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetDepthStencilSurface(IntPtr thisPtr, out Texture2D surface);
+        private static extern void Internal_GetDepthStencilSurface(IntPtr thisPtr, out Texture surface);
     }
 
     /** @} */

+ 172 - 0
Source/MBansheeEngine/Rendering/Texture.cs

@@ -108,6 +108,138 @@ namespace BansheeEngine
             }
         }
 
+        /// <summary>
+        /// Constructor for the internal use by the runtime.
+        /// </summary>
+        private Texture()
+        { }
+
+        /// <summary>
+        /// Creates a new blank 2D texture.
+        /// </summary>
+        /// <param name="width">Width of the texture in pixels.</param>
+        /// <param name="height">Height of the texture in pixels.</param>
+        /// <param name="format">Format of the pixels.</param>
+        /// <param name="usage">Describes planned texture use.</param>
+        /// <param name="numSamples">If higher than 1, texture containing multiple samples per pixel is created.</param>
+        /// <param name="hasMipmaps">Should the texture allocate memory for the entire mip-map chain or only the top level.
+        ///                          </param>
+        /// <param name="gammaCorrection">If true the texture data is assumed to have be gamma corrected and will be
+        ///                               converted back to linear space when sampled on GPU, and converted to gamma space
+        ///                               before being written by the GPU.</param>
+        public static Texture Create2D(int width, int height, PixelFormat format = PixelFormat.R8G8B8A8, 
+            TextureUsage usage = TextureUsage.Default, int numSamples = 1, bool hasMipmaps = false, 
+            bool gammaCorrection = false)
+        {
+            Texture texture = new Texture();
+            Internal_CreateInstance(texture, format, width, height, 1, TextureType.Texture2D, usage, numSamples,
+                hasMipmaps, gammaCorrection);
+
+            return texture;
+        }
+
+        /// <summary>
+        /// Creates a new blank 3D texture.
+        /// </summary>
+        /// <param name="width">Width of the texture in pixels.</param>
+        /// <param name="height">Height of the texture in pixels.</param>
+        /// <param name="depth">Depth of the texture in pixels.</param>
+        /// <param name="format">Format of the pixels.</param>
+        /// <param name="usage">Describes planned texture use.</param>
+        /// <param name="hasMipmaps">Should the texture allocate memory for the entire mip-map chain or only the top level.
+        ///                          </param>
+        public static Texture Create3D(int width, int height, int depth, PixelFormat format = PixelFormat.R8G8B8A8,
+            TextureUsage usage = TextureUsage.Default, bool hasMipmaps = false)
+        {
+            Texture texture = new Texture();
+            Internal_CreateInstance(texture, format, width, height, depth, TextureType.Texture3D, usage, 1,
+                hasMipmaps, false);
+
+            return texture;
+        }
+
+        /// <summary>
+        /// Creates a new blank cubemap texture.
+        /// </summary>
+        /// <param name="size">Width & height of a single cubemap face in pixels.</param>
+        /// <param name="format">Format of the pixels.</param>
+        /// <param name="usage">Describes planned texture use.</param>
+        /// <param name="hasMipmaps">Should the texture allocate memory for the entire mip-map chain or only the top level.
+        ///                          </param>
+        /// <param name="gammaCorrection">If true the texture data is assumed to have be gamma corrected and will be
+        ///                               converted back to linear space when sampled on GPU, and converted to gamma space
+        ///                               before being written by the GPU.</param>
+        public static Texture CreateCube(int size, PixelFormat format = PixelFormat.R8G8B8A8,
+            TextureUsage usage = TextureUsage.Default, bool hasMipmaps = false, bool gammaCorrection = false)
+        {
+            Texture texture = new Texture();
+            Internal_CreateInstance(texture, format, size, size, 1, TextureType.TextureCube, usage, 1,
+                hasMipmaps, gammaCorrection);
+
+            return texture;
+        }
+
+        /// <summary>
+        /// Returns pixels for the specified mip level & face. Pixels will be read from system memory, which means the
+        /// texture has to be created with <see cref="TextureUsage.CPUCached"/>. If the texture was updated from the GPU the
+        /// pixels retrieved from this method will not reflect that, and you should use <see cref="GetGPUPixels"/> instead.
+        /// </summary>
+        /// <param name="mipLevel">Mip level to retrieve pixels for. Top level (0) is the highest quality.</param>
+        /// <param name="face">Face to read the pixels from. Cubemap textures have six faces whose face indices are as
+        ///                    specified in the <see cref="CubeFace"/> enum. Array textures can have an arbitrary number
+        ///                    of faces (if it's a cubemap array it has to be a multiple of 6).</param>
+        /// <returns>A set of pixels for the specified mip level.</returns>
+        public PixelData GetPixels(int mipLevel = 0, int face = 0)
+        {
+            return Internal_GetPixels(mCachedPtr, face, mipLevel);
+        }
+
+        /// <summary>
+        /// Sets pixels for the specified mip level and face.
+        /// </summary>
+        /// <param name="data">Pixels to assign to the specified mip level. Pixel data must match the mip level size
+        ///                    and texture pixel format.</param>
+        /// <param name="mipLevel">Mip level to set pixels for. Top level (0) is the highest quality.</param>
+        /// <param name="face">Face to set pixels for. Cubemap textures have six faces whose face indices are as
+        ///                    specified in the <see cref="CubeFace"/> enum. Array textures can have an arbitrary number
+        ///                    of faces (if it's a cubemap array it has to be a multiple of 6).</param>
+        public void SetPixels(PixelData data, int mipLevel = 0, int face = 0)
+        {
+            Internal_SetPixels(mCachedPtr, data, face, mipLevel);
+        }
+
+        /// <summary>
+        /// Sets pixels for the specified mip level and face.
+        /// </summary>
+        /// <param name="data">Pixels to assign to the specified mip level. Size of the array must match the mip level
+        ///                    dimensions. Data is expected to be laid out row by row. Pixels will be automatically
+        ///                    converted to the valid pixel format.</param>
+        /// <param name="mipLevel">Mip level to set pixels for. Top level (0) is the highest quality.</param>
+        /// <param name="face">Face to set pixels for. Cubemap textures have six faces whose face indices are as
+        ///                    specified in the <see cref="CubeFace"/> enum. Array textures can have an arbitrary number
+        ///                    of faces (if it's a cubemap array it has to be a multiple of 6).</param>
+        public void SetPixels(Color[] data, int mipLevel = 0, int face = 0)
+        {
+            Internal_SetPixelsArray(mCachedPtr, data, face, mipLevel);
+        }
+
+        /// <summary>
+        /// Reads texture pixels directly from the GPU. This is similar to <see cref="GetPixels"/> but the texture doesn't
+        /// need to be created with <see cref="TextureUsage.CPUCached"/>, and the data will contain any updates performed by
+        /// the GPU. This method can be potentially slow as it introduces a CPU-GPU synchronization point. Additionally
+        /// this method is asynchronous which means the data is not available immediately.
+        /// </summary>
+        /// <param name="mipLevel">Mip level to retrieve pixels for. Top level (0) is the highest quality.</param>
+        /// <param name="face">Face to read the pixels from. Cubemap textures have six faces whose face indices are as
+        ///                    specified in the <see cref="CubeFace"/> enum. Array textures can have an arbitrary number
+        ///                    of faces (if it's a cubemap array it has to be a multiple of 6).</param>
+        /// <returns><see cref="AsyncOp"/> object that will contain <see cref="PixelData"/> object when the operation 
+        ///          completes.</returns>
+        public AsyncOp GetGPUPixels(int mipLevel = 0, int face = 0)
+        {
+            return Internal_GetGPUPixels(mCachedPtr, face, mipLevel);
+        }
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_GetPixelFormat(IntPtr thisPtr, out PixelFormat value);
 
@@ -128,6 +260,23 @@ namespace BansheeEngine
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_GetMipmapCount(IntPtr thisPtr, out int value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_CreateInstance(Texture instance, PixelFormat format, int width,
+            int height, int depth, TextureType texType, TextureUsage usage, int numSamples, bool hasMipmaps, 
+            bool gammaCorrection);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern PixelData Internal_GetPixels(IntPtr thisPtr, int face, int mipLevel);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern AsyncOp Internal_GetGPUPixels(IntPtr thisPtr, int face, int mipLevel);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetPixels(IntPtr thisPtr, PixelData data, int face, int mipLevel);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetPixelsArray(IntPtr thisPtr, Color[] data, int face, int mipLevel);
     }
 
     /// <summary>
@@ -171,5 +320,28 @@ namespace BansheeEngine
         CPUReadable = 0x2000,
     }
 
+    /// <summary>
+    /// Indices for the faces of a cube texture.
+    /// </summary>
+    public enum CubeFace
+    {
+        PositiveX = 0,
+        NegativeX = 1,
+        PositiveY = 2,
+        NegativeY = 3,
+        PositiveZ = 4,
+        NegativeZ = 5,
+    }
+
+    /// <summary>
+    /// Supported texture types.
+    /// </summary>
+    internal enum TextureType // Note: Must match C++ enum TextureType
+    {
+        Texture2D = 2,
+        Texture3D = 3,
+        TextureCube = 4
+    }
+
     /** @} */
 }

+ 0 - 115
Source/MBansheeEngine/Rendering/Texture2D.cs

@@ -1,115 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-using System;
-using System.Runtime.CompilerServices;
-
-namespace BansheeEngine
-{
-    /** @addtogroup Rendering
-     *  @{
-     */
-
-    /// <summary>
-    /// A two dimensional texture.
-    /// </summary>
-    public sealed class Texture2D : Texture
-    {
-        /// <summary>
-        /// Constructor for the internal use by the runtime.
-        /// </summary>
-        private Texture2D()
-        { }
-
-        /// <summary>
-        /// Creates a new blank 2D texture.
-        /// </summary>
-        /// <param name="width">Width of the texture in pixels.</param>
-        /// <param name="height">Height of the texture in pixels.</param>
-        /// <param name="format">Format of the pixels.</param>
-        /// <param name="usage">Describes planned texture use.</param>
-        /// <param name="numSamples">If higher than 1, texture containing multiple samples per pixel is created.</param>
-        /// <param name="hasMipmaps">Should the texture allocate memory for the entire mip-map chain or only the top level.
-        ///                          </param>
-        /// <param name="gammaCorrection">If true the texture data is assumed to have be gamma corrected and will be
-        ///                               converted back to linear space when sampled on GPU, and converted to gamma space
-        ///                               before being written by the GPU.</param>
-        public Texture2D(int width, int height, PixelFormat format = PixelFormat.R8G8B8A8, TextureUsage usage = TextureUsage.Default, 
-            int numSamples = 1, bool hasMipmaps = false, bool gammaCorrection = false)
-        {
-            Internal_CreateInstance(this, format, width, height, usage, numSamples, hasMipmaps, gammaCorrection);
-        }
-
-        /// <summary>
-        /// Returns pixels for the specified mip level. Pixels will be read from system memory, which means the texture has
-        /// to be created with <see cref="TextureUsage.CPUCached"/>. If the texture was updated from the GPU the pixels
-        /// retrieved from this method will not reflect that, and you should use <see cref="GetGPUPixels"/> instead.
-        /// </summary>
-        /// <param name="mipLevel">Mip level to retrieve pixels for. Top level (0) is the highest quality.</param>
-        /// <returns>A set of pixels for the specified mip level.</returns>
-        public PixelData GetPixels(int mipLevel = 0)
-        {
-            return Internal_GetPixels(mCachedPtr, mipLevel);
-        }
-
-        /// <summary>
-        /// Sets pixels for the specified mip level.
-        /// </summary>
-        /// <param name="data">Pixels to assign to the specified mip level. Pixel data must match the mip level size
-        ///                    and texture pixel format.</param>
-        /// <param name="mipLevel">Mip level to set pixels for. Top level (0) is the highest quality.</param>
-        public void SetPixels(PixelData data, int mipLevel = 0)
-        {
-            Internal_SetPixels(mCachedPtr, data, mipLevel);
-        }
-
-        /// <summary>
-        /// Sets pixels for the specified mip level.
-        /// </summary>
-        /// <param name="data">Pixels to assign to the specified mip level. Size of the array must match texture width
-        ///                    multiplied by height. Data is expected to be laid out row by row. Pixels will be
-        ///                    automatically converted to the valid pixel format.</param>
-        /// <param name="mipLevel">Mip level to set pixels for. Top level (0) is the highest quality.</param>
-        public void SetPixels(Color[] data, int mipLevel = 0)
-        {
-            if (data == null || data.Length != (Width*Height))
-            {
-                int size = data == null ? 0 : data.Length;
-                Debug.LogError("SetPixels called with incorrect size: " + size);
-            }
-
-            Internal_SetPixelsArray(mCachedPtr, data, mipLevel);
-        }
-
-        /// <summary>
-        /// Reads texture pixels directly from the GPU. This is similar to <see cref="GetPixels"/> but the texture doesn't
-        /// need to be created with <see cref="TextureUsage.CPUCached"/>, and the data will contain any updates performed by
-        /// the GPU. This method can be potentially slow as it introduces a CPU-GPU synchronization point. Additionally
-        /// this method is asynchronous which means the data is not available immediately.
-        /// </summary>
-        /// <param name="mipLevel">Mip level to retrieve pixels for. Top level (0) is the highest quality.</param>
-        /// <returns><see cref="AsyncOp"/> object that will contain <see cref="PixelData"/> object when the operation 
-        ///          completes.</returns>
-        public AsyncOp GetGPUPixels(int mipLevel = 0)
-        {
-            return Internal_GetGPUPixels(mCachedPtr, mipLevel);
-        }
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateInstance(Texture2D instance, PixelFormat format, int width, 
-            int height, TextureUsage usage, int numSamples, bool hasMipmaps, bool gammaCorrection);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern PixelData Internal_GetPixels(IntPtr thisPtr, int mipLevel);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern AsyncOp Internal_GetGPUPixels(IntPtr thisPtr, int mipLevel);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetPixels(IntPtr thisPtr, PixelData data, int mipLevel);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetPixelsArray(IntPtr thisPtr, Color[] data, int mipLevel);
-    }
-
-    /** @} */
-}

+ 0 - 110
Source/MBansheeEngine/Rendering/Texture3D.cs

@@ -1,110 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-using System;
-using System.Runtime.CompilerServices;
-
-namespace BansheeEngine
-{
-    /** @addtogroup Rendering
-     *  @{
-     */
-
-    /// <summary>
-    /// A three dimensional texture.
-    /// </summary>
-    public sealed class Texture3D : Texture
-    {
-        /// <summary>
-        /// Depth of the texture in pixels.
-        /// </summary>
-        public int Depth
-        {
-            get
-            {
-                int value;
-                Internal_GetDepth(mCachedPtr, out value);
-                return value;
-            }
-        }
-
-        /// <summary>
-        /// Constructor for internal use by the runtime.
-        /// </summary>
-        private Texture3D()
-        { }
-
-        /// <summary>
-        /// Creates a new blank 3D texture.
-        /// </summary>
-        /// <param name="width">Width of the texture in pixels.</param>
-        /// <param name="height">Height of the texture in pixels.</param>
-        /// <param name="depth">Depth of the texture in pixels.</param>
-        /// <param name="format">Format of the pixels.</param>
-        /// <param name="usage">Describes planned texture use.</param>
-        /// <param name="hasMipmaps">Should the texture allocate memory for the entire mip-map chain or only the top level.
-        ///                          </param>
-        /// <param name="gammaCorrection">If true the texture data is assumed to have be gamma corrected and will be
-        ///                               converted back to linear space when sampled on GPU, and converted to gamma space
-        ///                               before being written by the GPU.</param>
-        public Texture3D(PixelFormat format, int width, int height, int depth, TextureUsage usage = TextureUsage.Default, 
-            bool hasMipmaps = false, bool gammaCorrection = false)
-        {
-            Internal_CreateInstance(this, format, width, height, depth, usage, hasMipmaps, gammaCorrection);
-        }
-
-        /// <summary>
-        /// Returns pixels for the specified mip level. Pixels will be read from system memory, which means the texture has
-        /// to be created with <see cref="TextureUsage.CPUCached"/>. If the texture was updated from the GPU the pixels
-        /// retrieved from this method will not reflect that, and you should use <see cref="GetGPUPixels"/> instead.
-        /// </summary>
-        /// <param name="mipLevel">Mip level to retrieve pixels for. Top level (0) is the highest quality.</param>
-        /// <returns>A set of pixels for the specified mip level.</returns>
-        public PixelData GetPixels(int mipLevel = 0)
-        {
-            return Internal_GetPixels(mCachedPtr, mipLevel);
-        }
-
-        /// <summary>
-        /// Sets pixels for the specified mip level.
-        /// </summary>
-        /// <param name="data">Pixels to assign to the specified mip level. Pixel data must match the mip level size
-        ///                    and texture pixel format.</param>
-        /// <param name="mipLevel">Mip level to set pixels for. Top level (0) is the highest quality.</param>
-        public void SetPixels(PixelData data, int mipLevel = 0)
-        {
-            Internal_SetPixels(mCachedPtr, data, mipLevel);
-        }
-
-        /// <summary>
-        /// Reads texture pixels directly from the GPU. This is similar to <see cref="GetPixels"/> but the texture doesn't
-        /// need to be created with <see cref="TextureUsage.CPUCached"/>, and the data will contain any updates performed by
-        /// the GPU. This method can be potentially slow as it introduces a CPU-GPU synchronization point. Additionally
-        /// this method is asynchronous which means the data is not available immediately.
-        /// </summary>
-        /// <param name="mipLevel">Mip level to retrieve pixels for. Top level (0) is the highest quality.</param>
-        /// <returns><see cref="AsyncOp"/> object that will contain <see cref="PixelData"/> object when the operation 
-        ///          completes.</returns>
-        public AsyncOp GetGPUPixels(int mipLevel = 0)
-        {
-            return Internal_GetGPUPixels(mCachedPtr, mipLevel);
-        }
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateInstance(Texture3D instance, PixelFormat format, int width,
-            int height, int depth, TextureUsage usage, bool hasMipmaps, bool gammaCorrection);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetDepth(IntPtr thisPtr, out int value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern PixelData Internal_GetPixels(IntPtr thisPtr, int mipLevel);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern AsyncOp Internal_GetGPUPixels(IntPtr thisPtr, int mipLevel);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetPixels(IntPtr thisPtr, PixelData data, int mipLevel);
-    }
-
-    /** @} */
-}

+ 0 - 111
Source/MBansheeEngine/Rendering/TextureCube.cs

@@ -1,111 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-using System;
-using System.Runtime.CompilerServices;
-
-namespace BansheeEngine
-{
-    /** @addtogroup Rendering
-     *  @{
-     */
-
-    /// <summary>
-    /// A cube texture. Cube texture consists of six two dimensional texture faces that can be accessed separately.
-    /// </summary>
-    public sealed class TextureCube : Texture
-    {
-        /// <summary>
-        /// Constructor for internal use by the runtime.
-        /// </summary>
-        private TextureCube()
-        { }
-
-        /// <summary>
-        /// Creates a new blank cube texture.
-        /// </summary>
-        /// <param name="width">Width of a single face of the texture in pixels.</param>
-        /// <param name="height">Height of a single face of the texture in pixels.</param>
-        /// <param name="format">Format of the pixels.</param>
-        /// <param name="usage">Describes planned texture use.</param>
-        /// <param name="numSamples">If higher than 1, texture containing multiple samples per pixel is created.</param>
-        /// <param name="hasMipmaps">Should the texture allocate memory for the entire mip-map chain or only the top level.
-        ///                          </param>
-        /// <param name="gammaCorrection">If true the texture data is assumed to have be gamma corrected and will be
-        ///                               converted back to linear space when sampled on GPU, and converted to gamma space
-        ///                               before being written by the GPU.</param>
-        public TextureCube(PixelFormat format, int width, int height, TextureUsage usage = TextureUsage.Default,
-            int numSamples = 1, bool hasMipmaps = false, bool gammaCorrection = false)
-        {
-            Internal_CreateInstance(this, format, width, height, usage, numSamples, hasMipmaps, gammaCorrection);
-        }
-
-        /// <summary>
-        /// Returns pixels for the specified mip level of the specified face. Pixels will be read from system memory, 
-        /// which means the texture has to be created with <see cref="TextureUsage.CPUCached"/>. If the texture was updated 
-        /// from the GPU the pixels retrieved from this method will not reflect that, and you should use 
-        /// <see cref="GetGPUPixels"/> instead.
-        /// </summary>
-        /// <param name="face">Face of the cube to access.</param>
-        /// <param name="mipLevel">Mip level to retrieve pixels for. Top level (0) is the highest quality.</param>
-        /// <returns>A set of pixels for the specified mip level.</returns>
-        public PixelData GetPixels(CubeFace face = CubeFace.PositiveX, int mipLevel = 0)
-        {
-            return Internal_GetPixels(mCachedPtr, face, mipLevel);
-        }
-
-        /// <summary>
-        /// Sets pixels for the specified mip level of the specified face.
-        /// </summary>
-        /// <param name="data">Pixels to assign to the specified mip level. Pixel data must match the mip level size
-        ///                    and texture pixel format.</param>
-        /// <param name="face">Face of the cube to access.</param>
-        /// <param name="mipLevel">Mip level to set pixels for. Top level (0) is the highest quality.</param>
-        public void SetPixels(PixelData data, CubeFace face = CubeFace.PositiveX, int mipLevel = 0)
-        {
-            Internal_SetPixels(mCachedPtr, data, face, mipLevel);
-        }
-
-        /// <summary>
-        /// Reads texture pixels directly from the GPU. This is similar to <see cref="GetPixels"/> but the texture doesn't
-        /// need to be created with <see cref="TextureUsage.CPUCached"/>, and the data will contain any updates performed by
-        /// the GPU. This method can be potentially slow as it introduces a CPU-GPU synchronization point. Additionally
-        /// this method is asynchronous which means the data is not available immediately.
-        /// </summary>
-        /// <param name="face">Face of the cube to access.</param>
-        /// <param name="mipLevel">Mip level to retrieve pixels for. Top level (0) is the highest quality.</param>
-        /// <returns><see cref="AsyncOp"/> object that will contain <see cref="PixelData"/> object when the operation 
-        ///          completes.</returns>
-        public AsyncOp GetGPUPixels(CubeFace face = CubeFace.PositiveX, int mipLevel = 0)
-        {
-            return Internal_GetGPUPixels(mCachedPtr, face, mipLevel);
-        }
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateInstance(TextureCube instance, PixelFormat format, int width,
-            int height, TextureUsage usage, int numSamples, bool hasMipmaps, bool gammaCorrection);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern PixelData Internal_GetPixels(IntPtr thisPtr, CubeFace face, int mipLevel);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern AsyncOp Internal_GetGPUPixels(IntPtr thisPtr, CubeFace face, int mipLevel);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetPixels(IntPtr thisPtr, PixelData data, CubeFace face, int mipLevel);
-    }
-
-    /// <summary>
-    /// Indices for the faces of a cube texture.
-    /// </summary>
-    public enum CubeFace
-    {
-        PositiveX = 0,
-        NegativeX = 1,
-        PositiveY = 2,
-        NegativeY = 3,
-        PositiveZ = 4,
-        NegativeZ = 5,
-    }
-
-    /** @} */
-}

+ 2 - 3
Source/SBansheeEditor/Source/BsScriptGUITextureField.cpp

@@ -82,7 +82,7 @@ namespace bs
 			textureField->setValue(HTexture());
 		else
 		{
-			ScriptTextureBase* scriptTexture = ScriptTexture::toNative(value);
+			ScriptTexture* scriptTexture = ScriptTexture::toNative(value);
 			textureField->setValue(static_resource_cast<Texture>(scriptTexture->getGenericHandle()));
 		}
 	}
@@ -116,7 +116,6 @@ namespace bs
 
 	void ScriptGUITextureField::onChanged(MonoObject* instance, const WeakResourceHandle<Texture>& newHandle)
 	{
-		// TODO - Always returning a 2D texture, will not work for 3D/cube textures
 		MonoObject* managedObj = ScriptResourceRef::create(newHandle);
 		MonoUtil::invokeThunk(onChangedThunk, instance, managedObj);
 	}
@@ -126,7 +125,7 @@ namespace bs
 		if (instance == nullptr)
 			return nullptr;
 
-		ScriptTextureBase* scriptResource = nullptr;
+		ScriptTexture* scriptResource = nullptr;
 		ScriptResourceManager::instance().getScriptResource(instance, &scriptResource, true);
 
 		return scriptResource->getManagedInstance();

+ 1 - 3
Source/SBansheeEditor/Source/BsScriptPlatformInfo.cpp

@@ -7,8 +7,6 @@
 #include "BsMonoManager.h"
 #include "BsMonoMethod.h"
 #include "BsMonoUtil.h"
-#include "BsScriptTexture2D.h"
-#include "BsScriptResourceManager.h"
 #include "BsScriptPrefab.h"
 #include "BsScriptResourceRef.h"
 
@@ -152,7 +150,7 @@ namespace bs
 		WeakResourceHandle<Texture> icon = thisPtr->getWinPlatformInfo()->icon;
 
 		if (icon != nullptr)
-			return ScriptResourceRef::create(icon, TEX_TYPE_2D);
+			return ScriptResourceRef::create(icon);
 
 		return nullptr;
 	}

+ 0 - 1
Source/SBansheeEditor/Source/BsScriptProjectLibrary.cpp

@@ -9,7 +9,6 @@
 #include "BsResources.h"
 #include "BsProjectResourceMeta.h"
 #include "BsScriptResourceManager.h"
-#include "BsScriptTexture2D.h"
 #include "BsScriptImportOptions.h"
 #include "BsEditorApplication.h"
 #include "BsManagedSerializableObject.h"

+ 0 - 6
Source/SBansheeEngine/CMakeSources.cmake

@@ -115,9 +115,6 @@ set(BS_SBANSHEEENGINE_INC_WRAPPERS
 	"Include/BsScriptVector2I.h"
 	"Include/BsScriptVector.h"
 	"Include/BsScriptTime.h"
-	"Include/BsScriptTextureCube.h"
-	"Include/BsScriptTexture3D.h"
-	"Include/BsScriptTexture2D.h"
 	"Include/BsScriptTexture.h"
 	"Include/BsScriptStringTable.h"
 	"Include/BsScriptSpriteTexture.h"
@@ -247,9 +244,6 @@ set(BS_SBANSHEEENGINE_SRC_WRAPPERS
 	"Source/BsScriptVector2I.cpp"
 	"Source/BsScriptVector.cpp"
 	"Source/BsScriptTime.cpp"
-	"Source/BsScriptTextureCube.cpp"
-	"Source/BsScriptTexture3D.cpp"
-	"Source/BsScriptTexture2D.cpp"
 	"Source/BsScriptTexture.cpp"
 	"Source/BsScriptStringTable.cpp"
 	"Source/BsScriptSpriteTexture.cpp"

+ 1 - 3
Source/SBansheeEngine/Include/BsManagedSerializableObjectInfo.h

@@ -33,9 +33,7 @@ namespace bs
 	/** Valid reference script types. */
 	enum class ScriptReferenceType
 	{
-		Texture2D,
-		Texture3D,
-		TextureCube,
+		Texture,
 		SpriteTexture,
 		ManagedResource,
 		PlainText,

+ 1 - 4
Source/SBansheeEngine/Include/BsScriptEnginePrerequisites.h

@@ -63,9 +63,7 @@ namespace bs
 	class ScriptFont;
 	class ScriptSpriteTexture;
 	class ScriptShaderInclude;
-	class ScriptTexture2D;
-	class ScriptTexture3D;
-	class ScriptTextureCube;
+	class ScriptTexture;
 	class ScriptPlainText;
 	class ScriptScriptCode;
 	class ScriptShader;
@@ -88,7 +86,6 @@ namespace bs
 	class ScriptRenderTarget;
 	class ScriptRenderTexture2D;
 	class ScriptCamera;
-	class ScriptTextureBase;
 	class ScriptMeshData;
 	class ManagedComponent;
 	class ManagedSerializableFieldData;

+ 2 - 6
Source/SBansheeEngine/Include/BsScriptMaterial.h

@@ -51,9 +51,7 @@ namespace bs
 		static void internal_SetMatrix3(ScriptMaterial* nativeInstance, MonoString* name, Matrix3* value);
 		static void internal_SetMatrix4(ScriptMaterial* nativeInstance, MonoString* name, Matrix4* value);
 		static void internal_SetColor(ScriptMaterial* nativeInstance, MonoString* name, Color* value);
-		static void internal_SetTexture2D(ScriptMaterial* nativeInstance, MonoString* name, ScriptTexture2D* value);
-		static void internal_SetTexture3D(ScriptMaterial* nativeInstance, MonoString* name, ScriptTexture3D* value);
-		static void internal_SetTextureCube(ScriptMaterial* nativeInstance, MonoString* name, ScriptTextureCube* value);
+		static void internal_SetTexture(ScriptMaterial* nativeInstance, MonoString* name, ScriptTexture* value);
 
 		static float internal_GetFloat(ScriptMaterial* nativeInstance, MonoString* name);
 		static void internal_GetVector2(ScriptMaterial* nativeInstance, MonoString* name, Vector2* value);
@@ -62,9 +60,7 @@ namespace bs
 		static void internal_GetMatrix3(ScriptMaterial* nativeInstance, MonoString* name, Matrix3* value);
 		static void internal_GetMatrix4(ScriptMaterial* nativeInstance, MonoString* name, Matrix4* value);
 		static void internal_GetColor(ScriptMaterial* nativeInstance, MonoString* name, Color* value);
-		static MonoObject* internal_GetTexture2D(ScriptMaterial* nativeInstance, MonoString* name);
-		static MonoObject* internal_GetTexture3D(ScriptMaterial* nativeInstance, MonoString* name);
-		static MonoObject* internal_GetTextureCube(ScriptMaterial* nativeInstance, MonoString* name);
+		static MonoObject* internal_GetTexture(ScriptMaterial* nativeInstance, MonoString* name);
 	};
 
 	/** @} */

+ 1 - 1
Source/SBansheeEngine/Include/BsScriptRenderTexture2D.h

@@ -34,7 +34,7 @@ namespace bs
 		/************************************************************************/
 		static void internal_createDetailed(MonoObject* instance, PixelFormat format, UINT32 width, UINT32 height,
 			UINT32 numSamples, bool gammaCorrection, bool createDepth, PixelFormat depthStencilFormat);
-		static void internal_create(MonoObject* instance, MonoArray* colorSurfaces, ScriptTexture2D* depthStencilSurface);
+		static void internal_create(MonoObject* instance, MonoArray* colorSurfaces, ScriptTexture* depthStencilSurface);
 
 		static void internal_getColorSurfaces(ScriptRenderTexture2D* thisPtr, MonoArray** value);
 		static void internal_getDepthStencilSurface(ScriptRenderTexture2D* thisPtr, MonoObject** value);

+ 0 - 4
Source/SBansheeEngine/Include/BsScriptResourceManager.h

@@ -99,10 +99,6 @@ namespace bs
 		void BS_SCR_BE_EXPORT ScriptResourceManager_createScriptResource(ScriptResourceManager* thisPtr,
 			const ResourceHandle<StringTable>& resourceHandle, ScriptStringTable** out);
 
-		template<>
-		void BS_SCR_BE_EXPORT ScriptResourceManager_createScriptResource(ScriptResourceManager* thisPtr,
-			const ResourceHandle<Texture>& resourceHandle, ScriptTextureBase** out);
-
 		template<>
 		void BS_SCR_BE_EXPORT ScriptResourceManager_createScriptResource(ScriptResourceManager* thisPtr,
 			const HResource& resourceHandle, ScriptResourceBase** out);

+ 0 - 8
Source/SBansheeEngine/Include/BsScriptResourceRef.h

@@ -32,14 +32,6 @@ namespace bs
 			return createInternal(handle);
 		}
 
-		/**
-		 * Creates a new managed ResourceRef for the provided texture.
-		 *
-		 * @param[in]	handle	Handle to the texture to wrap.
-		 * @param[in]	type	Type of texture the handle holds.
-		 */
-		static MonoObject* create(const WeakResourceHandle<Texture>& handle, TextureType type = TEX_TYPE_2D);
-
 		/**	Returns a weak handle to the resource referenced by this object. */
 		WeakResourceHandle<Resource> getHandle() const { return mResource; }
 

+ 1 - 1
Source/SBansheeEngine/Include/BsScriptSpriteTexture.h

@@ -34,7 +34,7 @@ namespace bs
 		/************************************************************************/
 		static void internal_createInstance(MonoObject* instance, MonoObject* texture, Vector2* offset, Vector2* scale);
 		static MonoObject* internal_GetTexture(ScriptSpriteTexture* thisPtr);
-		static void internal_SetTexture(ScriptSpriteTexture* thisPtr, ScriptTexture2D* value);
+		static void internal_SetTexture(ScriptSpriteTexture* thisPtr, ScriptTexture* value);
 		static void internal_GetOffset(ScriptSpriteTexture* thisPtr, Vector2* value);
 		static void internal_SetOffset(ScriptSpriteTexture* thisPtr, Vector2* value);
 		static void internal_GetScale(ScriptSpriteTexture* thisPtr, Vector2* value);

+ 14 - 15
Source/SBansheeEngine/Include/BsScriptTexture.h

@@ -13,31 +13,26 @@ namespace bs
 	 *  @{
 	 */
 
-	/**	Base class for all interop objects referencing textures. */
-	class BS_SCR_BE_EXPORT ScriptTextureBase : public ScriptResourceBase
-	{
-	protected:
-		friend class ScriptResourceManager;
-
-		ScriptTextureBase(MonoObject* instance)
-			:ScriptResourceBase(instance)
-		{ }
-
-		virtual ~ScriptTextureBase() {}
-	};
-
 	/**	Interop class between C++ & CLR for Texture. */
-	class BS_SCR_BE_EXPORT ScriptTexture : public ScriptObject <ScriptTexture, ScriptTextureBase>
+	class BS_SCR_BE_EXPORT ScriptTexture : public TScriptResource <ScriptTexture, Texture>
 	{
 	public:
 		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "Texture")
 
+		/**	Creates an empty, uninitialized managed instance of the resource interop object. */
+		static MonoObject* createInstance();
+
 	private:
-		ScriptTexture(MonoObject* instance);
+		friend class ScriptResourceManager;
+
+		ScriptTexture(MonoObject* instance, const HTexture& texture);
 
 		/************************************************************************/
 		/* 								CLR HOOKS						   		*/
 		/************************************************************************/
+		static void internal_createInstance(MonoObject* instance, PixelFormat format, UINT32 width,
+			UINT32 height, UINT32 depth, TextureType texType, TextureUsage usage, UINT32 numSamples, bool hasMipmaps, 
+			bool gammaCorrection);
 		static void internal_getPixelFormat(ScriptTexture* thisPtr, PixelFormat* value);
 		static void internal_getUsage(ScriptTexture* thisPtr, TextureUsage* value);
 		static void internal_getWidth(ScriptTexture* thisPtr, int* value);
@@ -45,6 +40,10 @@ namespace bs
 		static void internal_getGammaCorrection(ScriptTexture* thisPtr, bool* value);
 		static void internal_getSampleCount(ScriptTexture* thisPtr, int* value);
 		static void internal_getMipmapCount(ScriptTexture* thisPtr, int* value);
+		static MonoObject* internal_getPixels(ScriptTexture* thisPtr, UINT32 face, UINT32 mipLevel);
+		static MonoObject* internal_getGPUPixels(ScriptTexture* thisPtr, UINT32 face, UINT32 mipLevel);
+		static void internal_setPixels(ScriptTexture* thisPtr, MonoObject* data, UINT32 face, UINT32 mipLevel);
+		static void internal_setPixelsArray(ScriptTexture* thisPtr, MonoArray* colors, UINT32 face, UINT32 mipLevel);
 	};
 
 	/** @} */

+ 0 - 42
Source/SBansheeEngine/Include/BsScriptTexture2D.h

@@ -1,42 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsScriptEnginePrerequisites.h"
-#include "BsScriptTexture.h"
-#include "BsScriptObject.h"
-#include "BsTexture.h"
-
-namespace bs
-{
-	/** @addtogroup ScriptInteropEngine
-	 *  @{
-	 */
-
-	/**	Interop class between C++ & CLR for a 2D Texture. */
-	class BS_SCR_BE_EXPORT ScriptTexture2D : public TScriptResource<ScriptTexture2D, Texture>
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "Texture2D")
-
-		/**	Creates an empty, uninitialized managed instance of the resource interop object. */
-		static MonoObject* createInstance();
-
-	private:
-		friend class ScriptResourceManager;
-
-		ScriptTexture2D(MonoObject* instance, const HTexture& texture);
-
-		/************************************************************************/
-		/* 								CLR HOOKS						   		*/
-		/************************************************************************/
-		static void internal_createInstance(MonoObject* instance, PixelFormat format, UINT32 width,
-			UINT32 height, TextureUsage usage, UINT32 numSamples, bool hasMipmaps, bool gammaCorrection);
-		static MonoObject* internal_getPixels(ScriptTexture2D* thisPtr, UINT32 mipLevel);
-		static MonoObject* internal_getGPUPixels(ScriptTexture2D* thisPtr, UINT32 mipLevel);
-		static void internal_setPixels(ScriptTexture2D* thisPtr, MonoObject* data, UINT32 mipLevel);
-		static void internal_setPixelsArray(ScriptTexture2D* thisPtr, MonoArray* colors, UINT32 mipLevel);
-	};
-
-	/** @} */
-}

+ 0 - 41
Source/SBansheeEngine/Include/BsScriptTexture3D.h

@@ -1,41 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsScriptEnginePrerequisites.h"
-#include "BsScriptTexture.h"
-#include "BsScriptObject.h"
-#include "BsTexture.h"
-
-namespace bs
-{
-	/** @addtogroup ScriptInteropEngine
-	 *  @{
-	 */
-
-	/**	Interop class between C++ & CLR for 3D Texture. */
-	class BS_SCR_BE_EXPORT ScriptTexture3D : public TScriptResource <ScriptTexture3D, Texture>
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "Texture3D")
-
-		/**	Creates an empty, uninitialized managed instance of the resource interop object. */
-		static MonoObject* createInstance();
-
-	private:
-		friend class ScriptResourceManager;
-
-		ScriptTexture3D(MonoObject* instance, const HTexture& texture);
-
-		/************************************************************************/
-		/* 								CLR HOOKS						   		*/
-		/************************************************************************/
-		static void internal_createInstance(MonoObject* instance, PixelFormat format, UINT32 width,
-			UINT32 height, UINT32 depth, TextureUsage usage, bool hasMipmaps, bool gammaCorrection);
-		static MonoObject* internal_getPixels(ScriptTexture3D* thisPtr, UINT32 mipLevel);
-		static MonoObject* internal_getGPUPixels(ScriptTexture3D* thisPtr, UINT32 mipLevel);
-		static void internal_setPixels(ScriptTexture3D* thisPtr, MonoObject* data, UINT32 mipLevel);
-	};
-
-	/** @} */
-}

+ 0 - 41
Source/SBansheeEngine/Include/BsScriptTextureCube.h

@@ -1,41 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsScriptEnginePrerequisites.h"
-#include "BsScriptTexture.h"
-#include "BsScriptObject.h"
-#include "BsTexture.h"
-
-namespace bs
-{
-	/** @addtogroup ScriptInteropEngine
-	 *  @{
-	 */
-
-	/**	Interop class between C++ & CLR for a cube Texture. */
-	class BS_SCR_BE_EXPORT ScriptTextureCube : public TScriptResource <ScriptTextureCube, Texture>
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "TextureCube")
-
-		/**	Creates an empty, uninitialized managed instance of the resource interop object. */
-		static MonoObject* createInstance();
-
-	private:
-		friend class ScriptResourceManager;
-
-		ScriptTextureCube(MonoObject* instance, const HTexture& texture);
-
-		/************************************************************************/
-		/* 								CLR HOOKS						   		*/
-		/************************************************************************/
-		static void internal_createInstance(MonoObject* instance, PixelFormat format, UINT32 width,
-			UINT32 height, TextureUsage usage, UINT32 numSamples, bool hasMipmaps, bool gammaCorrection);
-		static MonoObject* internal_getPixels(ScriptTextureCube* thisPtr, UINT32 face, UINT32 mipLevel);
-		static MonoObject* internal_getGPUPixels(ScriptTextureCube* thisPtr, UINT32 face, UINT32 mipLevel);
-		static void internal_setPixels(ScriptTextureCube* thisPtr, MonoObject* data, UINT32 face, UINT32 mipLevel);
-	};
-
-	/** @} */
-}

+ 3 - 11
Source/SBansheeEngine/Source/BsManagedSerializableField.cpp

@@ -7,9 +7,7 @@
 #include "BsMonoManager.h"
 #include "BsScriptResourceManager.h"
 #include "BsScriptGameObjectManager.h"
-#include "BsScriptTexture2D.h"
-#include "BsScriptTexture3D.h"
-#include "BsScriptTextureCube.h"
+#include "BsScriptTexture.h"
 #include "BsScriptSpriteTexture.h"
 #include "BsScriptManagedResource.h"
 #include "BsScriptPlainText.h"
@@ -141,14 +139,8 @@ namespace bs
 			lookup[(int)ScriptReferenceType::Resource] =
 				{ &getScriptResource<Resource, ScriptResourceBase>, &setScriptResource<ScriptResourceBase> };
 
-			lookup[(int)ScriptReferenceType::Texture2D] =
-				{ &getScriptResource<Texture, ScriptTexture2D>, &setScriptResource<ScriptTexture2D> };
-
-			lookup[(int)ScriptReferenceType::Texture3D] =
-				{ &getScriptResource<Texture, ScriptTexture3D>, &setScriptResource<ScriptTexture3D> };
-
-			lookup[(int)ScriptReferenceType::TextureCube] =
-				{ &getScriptResource<Texture, ScriptTextureCube>, &setScriptResource<ScriptTextureCube> };
+			lookup[(int)ScriptReferenceType::Texture] =
+				{ &getScriptResource<Texture, ScriptTexture>, &setScriptResource<ScriptTexture> };
 
 			lookup[(int)ScriptReferenceType::SpriteTexture] =
 				{ &getScriptResource<SpriteTexture, ScriptSpriteTexture>, &setScriptResource<ScriptSpriteTexture> };

+ 4 - 12
Source/SBansheeEngine/Source/BsManagedSerializableObjectInfo.cpp

@@ -8,11 +8,9 @@
 #include "BsMonoManager.h"
 #include "BsMonoField.h"
 #include "BsMonoProperty.h"
-#include "BsScriptTexture2D.h"
+#include "BsScriptTexture.h"
 #include "BsScriptSpriteTexture.h"
 #include "BsScriptAssemblyManager.h"
-#include "BsScriptTexture3D.h"
-#include "BsScriptTextureCube.h"
 #include "BsScriptMaterial.h"
 #include "BsScriptMesh.h"
 #include "BsScriptFont.h"
@@ -374,9 +372,7 @@ namespace bs
 		switch (mType)
 		{
 		case ScriptReferenceType::Resource:
-		case ScriptReferenceType::Texture2D:
-		case ScriptReferenceType::Texture3D:
-		case ScriptReferenceType::TextureCube:
+		case ScriptReferenceType::Texture:
 		case ScriptReferenceType::SpriteTexture:
 		case ScriptReferenceType::Shader:
 		case ScriptReferenceType::ShaderInclude:
@@ -410,12 +406,8 @@ namespace bs
 		{
 		case ScriptReferenceType::Resource:
 			return ScriptResource::getMetaData()->scriptClass->_getInternalClass();
-		case ScriptReferenceType::Texture2D:
-			return ScriptTexture2D::getMetaData()->scriptClass->_getInternalClass();
-		case ScriptReferenceType::Texture3D:
-			return ScriptTexture3D::getMetaData()->scriptClass->_getInternalClass();
-		case ScriptReferenceType::TextureCube:
-			return ScriptTextureCube::getMetaData()->scriptClass->_getInternalClass();
+		case ScriptReferenceType::Texture:
+			return ScriptTexture::getMetaData()->scriptClass->_getInternalClass();
 		case ScriptReferenceType::SpriteTexture:
 			return ScriptSpriteTexture::getMetaData()->scriptClass->_getInternalClass();
 		case ScriptReferenceType::Shader:

+ 3 - 9
Source/SBansheeEngine/Source/BsScriptAssemblyManager.cpp

@@ -10,9 +10,7 @@
 #include "BsMonoProperty.h"
 #include "BsScriptManagedResource.h"
 #include "BsScriptComponent.h"
-#include "BsScriptTexture2D.h"
-#include "BsScriptTexture3D.h"
-#include "BsScriptTextureCube.h"
+#include "BsScriptTexture.h"
 #include "BsScriptSpriteTexture.h"
 #include "BsScriptMaterial.h"
 #include "BsScriptMesh.h"
@@ -328,12 +326,8 @@ namespace bs
 
 				if(monoClass == ScriptResource::getMetaData()->scriptClass)
 					typeInfo->mType = ScriptReferenceType::Resource;
-				else if (monoClass->isSubClassOf(ScriptTexture2D::getMetaData()->scriptClass))
-					typeInfo->mType = ScriptReferenceType::Texture2D;
-				else if (monoClass->isSubClassOf(ScriptTexture3D::getMetaData()->scriptClass))
-					typeInfo->mType = ScriptReferenceType::Texture3D;
-				else if (monoClass->isSubClassOf(ScriptTextureCube::getMetaData()->scriptClass))
-					typeInfo->mType = ScriptReferenceType::TextureCube;
+				else if (monoClass->isSubClassOf(ScriptTexture::getMetaData()->scriptClass))
+					typeInfo->mType = ScriptReferenceType::Texture;
 				else if (monoClass->isSubClassOf(ScriptSpriteTexture::getMetaData()->scriptClass))
 					typeInfo->mType = ScriptReferenceType::SpriteTexture;
 				else if (monoClass->isSubClassOf(ScriptManagedResource::getMetaData()->scriptClass))

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

@@ -17,7 +17,7 @@
 #include "BsGUIManager.h"
 #include "BsStandardPostProcessSettings.h"
 #include "BsScriptPostProcessSettings.h"
-#include "BsScriptTextureCube.h"
+#include "BsScriptTexture.h"
 #include "BsScriptResourceManager.h"
 
 namespace bs

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

@@ -6,7 +6,7 @@
 #include "BsMonoClass.h"
 #include "BsMonoManager.h"
 #include "BsScriptResourceManager.h"
-#include "BsScriptTexture2D.h"
+#include "BsScriptTexture.h"
 #include "BsMonoUtil.h"
 
 namespace bs
@@ -87,10 +87,10 @@ namespace bs
 		const Vector<HTexture>& texturePages = instance->mBitmap->texturePages;
 
 		UINT32 numPages = (UINT32)texturePages.size();
-		ScriptArray output = ScriptArray::create<ScriptTexture2D>(numPages);
+		ScriptArray output = ScriptArray::create<ScriptTexture>(numPages);
 		for (UINT32 i = 0; i < numPages; i++)
 		{
-			ScriptTexture2D* scriptTexture = nullptr;
+			ScriptTexture* scriptTexture = nullptr;
 			ScriptResourceManager::instance().getScriptResource(texturePages[i], &scriptTexture, true);
 
 			output.set(i, scriptTexture->getManagedInstance());

+ 6 - 64
Source/SBansheeEngine/Source/BsScriptMaterial.cpp

@@ -8,9 +8,7 @@
 #include "BsMonoManager.h"
 #include "BsMonoUtil.h"
 #include "BsScriptShader.h"
-#include "BsScriptTexture2D.h"
-#include "BsScriptTexture3D.h"
-#include "BsScriptTextureCube.h"
+#include "BsScriptTexture.h"
 #include <BsBuiltinResources.h>
 
 namespace bs
@@ -36,9 +34,7 @@ namespace bs
 		metaData.scriptClass->addInternalCall("Internal_SetMatrix3", &ScriptMaterial::internal_SetMatrix3);
 		metaData.scriptClass->addInternalCall("Internal_SetMatrix4", &ScriptMaterial::internal_SetMatrix4);
 		metaData.scriptClass->addInternalCall("Internal_SetColor", &ScriptMaterial::internal_SetColor);
-		metaData.scriptClass->addInternalCall("Internal_SetTexture2D", &ScriptMaterial::internal_SetTexture2D);
-		metaData.scriptClass->addInternalCall("Internal_SetTexture3D", &ScriptMaterial::internal_SetTexture3D);
-		metaData.scriptClass->addInternalCall("Internal_SetTextureCube", &ScriptMaterial::internal_SetTextureCube);
+		metaData.scriptClass->addInternalCall("Internal_SetTexture", &ScriptMaterial::internal_SetTexture);
 
 		metaData.scriptClass->addInternalCall("Internal_GetFloat", &ScriptMaterial::internal_GetFloat);
 		metaData.scriptClass->addInternalCall("Internal_GetVector2", &ScriptMaterial::internal_GetVector2);
@@ -47,9 +43,7 @@ namespace bs
 		metaData.scriptClass->addInternalCall("Internal_GetMatrix3", &ScriptMaterial::internal_GetMatrix3);
 		metaData.scriptClass->addInternalCall("Internal_GetMatrix4", &ScriptMaterial::internal_GetMatrix4);
 		metaData.scriptClass->addInternalCall("Internal_GetColor", &ScriptMaterial::internal_GetColor);
-		metaData.scriptClass->addInternalCall("Internal_GetTexture2D", &ScriptMaterial::internal_GetTexture2D);
-		metaData.scriptClass->addInternalCall("Internal_GetTexture3D", &ScriptMaterial::internal_GetTexture3D);
-		metaData.scriptClass->addInternalCall("Internal_GetTextureCube", &ScriptMaterial::internal_GetTextureCube);
+		metaData.scriptClass->addInternalCall("Internal_GetTexture", &ScriptMaterial::internal_GetTexture);
 	}
 
 	void ScriptMaterial::internal_CreateInstance(MonoObject* instance, ScriptShader* shader)
@@ -151,31 +145,7 @@ namespace bs
 		nativeInstance->getHandle()->setColor(paramName, *value);
 	}
 
-	void ScriptMaterial::internal_SetTexture2D(ScriptMaterial* nativeInstance, MonoString* name, ScriptTexture2D* value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		HTexture texture;
-
-		if (value != nullptr)
-			texture = value->getHandle();
-
-		nativeInstance->getHandle()->setTexture(paramName, texture);
-	}
-
-	void ScriptMaterial::internal_SetTexture3D(ScriptMaterial* nativeInstance, MonoString* name, ScriptTexture3D* value)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		HTexture texture;
-
-		if (value != nullptr)
-			texture = value->getHandle();
-
-		nativeInstance->getHandle()->setTexture(paramName, texture);
-	}
-
-	void ScriptMaterial::internal_SetTextureCube(ScriptMaterial* nativeInstance, MonoString* name, ScriptTextureCube* value)
+	void ScriptMaterial::internal_SetTexture(ScriptMaterial* nativeInstance, MonoString* name, ScriptTexture* value)
 	{
 		String paramName = MonoUtil::monoToString(name);
 
@@ -236,35 +206,7 @@ namespace bs
 		*value = nativeInstance->getHandle()->getColor(paramName);
 	}
 
-	MonoObject* ScriptMaterial::internal_GetTexture2D(ScriptMaterial* nativeInstance, MonoString* name)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		HTexture texture = nativeInstance->getHandle()->getTexture(paramName);
-		if (texture == nullptr)
-			return nullptr;
-
-		ScriptTexture2D* scriptTexture;
-		ScriptResourceManager::instance().getScriptResource(texture, &scriptTexture, true);
-
-		return scriptTexture->getManagedInstance();
-	}
-
-	MonoObject* ScriptMaterial::internal_GetTexture3D(ScriptMaterial* nativeInstance, MonoString* name)
-	{
-		String paramName = MonoUtil::monoToString(name);
-
-		HTexture texture = nativeInstance->getHandle()->getTexture(paramName);
-		if (texture == nullptr)
-			return nullptr;
-
-		ScriptTexture3D* scriptTexture;
-		ScriptResourceManager::instance().getScriptResource(texture, &scriptTexture, true);
-
-		return scriptTexture->getManagedInstance();
-	}
-
-	MonoObject* ScriptMaterial::internal_GetTextureCube(ScriptMaterial* nativeInstance, MonoString* name)
+	MonoObject* ScriptMaterial::internal_GetTexture(ScriptMaterial* nativeInstance, MonoString* name)
 	{
 		String paramName = MonoUtil::monoToString(name);
 
@@ -272,7 +214,7 @@ namespace bs
 		if (texture == nullptr)
 			return nullptr;
 
-		ScriptTextureCube* scriptTexture;
+		ScriptTexture* scriptTexture;
 		ScriptResourceManager::instance().getScriptResource(texture, &scriptTexture, true);
 
 		return scriptTexture->getManagedInstance();

+ 6 - 6
Source/SBansheeEngine/Source/BsScriptRenderTexture2D.cpp

@@ -6,7 +6,7 @@
 #include "BsMonoClass.h"
 #include "BsMonoManager.h"
 #include "BsRenderTexture.h"
-#include "BsScriptTexture2D.h"
+#include "BsScriptTexture.h"
 #include "BsMonoUtil.h"
 #include "BsScriptResourceManager.h"
 
@@ -46,7 +46,7 @@ namespace bs
 		new (bs_alloc<ScriptRenderTexture2D>()) ScriptRenderTexture2D(tex, instance);
 	}
 
-	void ScriptRenderTexture2D::internal_create(MonoObject* instance, MonoArray* colorSurfaces, ScriptTexture2D* depthStencilSurface)
+	void ScriptRenderTexture2D::internal_create(MonoObject* instance, MonoArray* colorSurfaces, ScriptTexture* depthStencilSurface)
 	{
 		ScriptArray colorSurfacesList(colorSurfaces);
 
@@ -76,7 +76,7 @@ namespace bs
 			surfaceDesc.mipLevel = 0;
 			surfaceDesc.numFaces = 1;
 
-			ScriptTexture2D* scriptSurface = colorSurfacesList.get<ScriptTexture2D*>(i);
+			ScriptTexture* scriptSurface = colorSurfacesList.get<ScriptTexture*>(i);
 			if (scriptSurface != nullptr)
 			{
 				HTexture textureHandle = scriptSurface->getHandle();
@@ -102,7 +102,7 @@ namespace bs
 		SPtr<RenderTexture> tex = thisPtr->getRenderTexture();
 
 		UINT32 numColorSurfaces = BS_MAX_MULTIPLE_RENDER_TARGETS;
-		ScriptArray outArray = ScriptArray::create<ScriptTexture2D>(numColorSurfaces);
+		ScriptArray outArray = ScriptArray::create<ScriptTexture>(numColorSurfaces);
 
 		for (UINT32 i = 0; i < numColorSurfaces; i++)
 		{
@@ -110,7 +110,7 @@ namespace bs
 
 			if (colorTex != nullptr)
 			{
-				ScriptTexture2D* scriptSurface;
+				ScriptTexture* scriptSurface;
 				ScriptResourceManager::instance().getScriptResource(colorTex, &scriptSurface, true);
 
 				outArray.set<MonoObject*>(i, scriptSurface->getManagedInstance());
@@ -127,7 +127,7 @@ namespace bs
 		SPtr<RenderTexture> tex = thisPtr->getRenderTexture();
 		HTexture depthTex = tex->getDepthStencilTexture();
 
-		ScriptTexture2D* scriptSurface;
+		ScriptTexture* scriptSurface;
 		ScriptResourceManager::instance().getScriptResource(depthTex, &scriptSurface, true);
 
 		*value = scriptSurface->getManagedInstance();

+ 2 - 5
Source/SBansheeEngine/Source/BsScriptResource.cpp

@@ -4,9 +4,7 @@
 #include "BsScriptResourceManager.h"
 #include "BsResource.h"
 #include "BsMonoUtil.h"
-#include "BsScriptTexture2D.h"
-#include "BsScriptTexture3D.h"
-#include "BsScriptTextureCube.h"
+#include "BsScriptTexture.h"
 #include "BsScriptSpriteTexture.h"
 #include "BsScriptMaterial.h"
 #include "BsScriptMesh.h"
@@ -63,8 +61,7 @@ namespace bs
 		switch (typeId)
 		{
 		case TID_Texture:
-			// TODO - Need to distinguish from 2D/3D/Cube
-			return ScriptTexture2D::getMetaData()->scriptClass;
+			return ScriptTexture::getMetaData()->scriptClass;
 		case TID_SpriteTexture:
 			return ScriptSpriteTexture::getMetaData()->scriptClass;
 		case TID_Font:

+ 5 - 38
Source/SBansheeEngine/Source/BsScriptResourceManager.cpp

@@ -5,9 +5,7 @@
 #include "BsMonoAssembly.h"
 #include "BsMonoClass.h"
 #include "BsResources.h"
-#include "BsScriptTexture2D.h"
-#include "BsScriptTexture3D.h"
-#include "BsScriptTextureCube.h"
+#include "BsScriptTexture.h"
 #include "BsScriptSpriteTexture.h"
 #include "BsScriptPlainText.h"
 #include "BsScriptScriptCode.h"
@@ -92,19 +90,6 @@ namespace bs
 			thisPtr->createScriptResource(monoInstance, resourceHandle, out);
 		}
 
-		template<>
-		void ScriptResourceManager_createScriptResource(ScriptResourceManager* thisPtr, const ResourceHandle<Texture>& resourceHandle, ScriptTextureBase** out)
-		{
-			TextureType type = resourceHandle->getProperties().getTextureType();
-
-			if (type == TEX_TYPE_3D)
-				return ScriptResourceManager_createScriptResource(thisPtr, resourceHandle, (ScriptTexture3D**)out);
-			else if (type == TEX_TYPE_CUBE_MAP)
-				return ScriptResourceManager_createScriptResource(thisPtr, resourceHandle, (ScriptTextureCube**)out);
-			else
-				return ScriptResourceManager_createScriptResource(thisPtr, resourceHandle, (ScriptTexture2D**)out);
-		}
-
 		template<>
 		void ScriptResourceManager_createScriptResource(ScriptResourceManager* thisPtr, const HResource& resourceHandle, ScriptResourceBase** out)
 		{
@@ -117,17 +102,7 @@ namespace bs
 			switch (resTypeID)
 			{
 			case TID_Texture:
-			{
-				HTexture texture = static_resource_cast<Texture>(resourceHandle);
-				TextureType type = texture->getProperties().getTextureType();
-
-				if (type == TEX_TYPE_3D)
-					return ScriptResourceManager_createScriptResource(thisPtr, texture, (ScriptTexture3D**)out);
-				else if (type == TEX_TYPE_CUBE_MAP)
-					return ScriptResourceManager_createScriptResource(thisPtr, texture, (ScriptTextureCube**)out);
-				else
-					return ScriptResourceManager_createScriptResource(thisPtr, texture, (ScriptTexture2D**)out);
-			}
+				return ScriptResourceManager_createScriptResource(thisPtr, static_resource_cast<Texture>(resourceHandle), (ScriptTexture**)out);
 			case TID_SpriteTexture:
 				return ScriptResourceManager_createScriptResource(thisPtr, static_resource_cast<SpriteTexture>(resourceHandle), (ScriptSpriteTexture**)out);
 			case TID_Font:
@@ -167,10 +142,7 @@ namespace bs
 			}
 		}
 
-		template void ScriptResourceManager_createScriptResource(ScriptResourceManager* thisPtr, const ResourceHandle<Texture>&, ScriptTexture2D**);
-		template void ScriptResourceManager_createScriptResource(ScriptResourceManager* thisPtr, const ResourceHandle<Texture>&, ScriptTexture3D**);
-		template void ScriptResourceManager_createScriptResource(ScriptResourceManager* thisPtr, const ResourceHandle<Texture>&, ScriptTextureCube**);
-		template void ScriptResourceManager_createScriptResource(ScriptResourceManager* thisPtr, const ResourceHandle<Texture>&, ScriptTextureBase**);
+		template void ScriptResourceManager_createScriptResource(ScriptResourceManager* thisPtr, const ResourceHandle<Texture>&, ScriptTexture**);
 		template void ScriptResourceManager_createScriptResource(ScriptResourceManager* thisPtr, const ResourceHandle<SpriteTexture>&, ScriptSpriteTexture**);
 		template void ScriptResourceManager_createScriptResource(ScriptResourceManager* thisPtr, const ResourceHandle<Mesh>&, ScriptMesh**);
 		template void ScriptResourceManager_createScriptResource(ScriptResourceManager* thisPtr, const ResourceHandle<Material>&, ScriptMaterial**);
@@ -188,9 +160,7 @@ namespace bs
 		template void ScriptResourceManager_createScriptResource(ScriptResourceManager* thisPtr, const ResourceHandle<AnimationClip>&, ScriptAnimationClip**);
 	}
 
-	template BS_SCR_BE_EXPORT void ScriptResourceManager::createScriptResource(MonoObject*, const ResourceHandle<Texture>&, ScriptTexture2D**);
-	template BS_SCR_BE_EXPORT void ScriptResourceManager::createScriptResource(MonoObject*, const ResourceHandle<Texture>&, ScriptTexture3D**);
-	template BS_SCR_BE_EXPORT void ScriptResourceManager::createScriptResource(MonoObject*, const ResourceHandle<Texture>&, ScriptTextureCube**);
+	template BS_SCR_BE_EXPORT void ScriptResourceManager::createScriptResource(MonoObject*, const ResourceHandle<Texture>&, ScriptTexture**);
 	template BS_SCR_BE_EXPORT void ScriptResourceManager::createScriptResource(MonoObject*, const ResourceHandle<SpriteTexture>&, ScriptSpriteTexture**);
 	template BS_SCR_BE_EXPORT void ScriptResourceManager::createScriptResource(MonoObject*, const ResourceHandle<Mesh>&, ScriptMesh**);
 	template BS_SCR_BE_EXPORT void ScriptResourceManager::createScriptResource(MonoObject*, const ResourceHandle<Material>&, ScriptMaterial**);
@@ -208,10 +178,7 @@ namespace bs
 	template BS_SCR_BE_EXPORT void ScriptResourceManager::createScriptResource(MonoObject*, const ResourceHandle<AnimationClip>&, ScriptAnimationClip**);
 	template BS_SCR_BE_EXPORT void ScriptResourceManager::createScriptResource(MonoObject*, const ResourceHandle<ManagedResource>&, ScriptManagedResource**);
 
-	template BS_SCR_BE_EXPORT void ScriptResourceManager::getScriptResource(const ResourceHandle<Texture>& resourceHandle, ScriptTexture2D** out, bool create);
-	template BS_SCR_BE_EXPORT void ScriptResourceManager::getScriptResource(const ResourceHandle<Texture>& resourceHandle, ScriptTexture3D** out, bool create);
-	template BS_SCR_BE_EXPORT void ScriptResourceManager::getScriptResource(const ResourceHandle<Texture>& resourceHandle, ScriptTextureCube** out, bool create);
-	template BS_SCR_BE_EXPORT void ScriptResourceManager::getScriptResource(const ResourceHandle<Texture>& resourceHandle, ScriptTextureBase** out, bool create);
+	template BS_SCR_BE_EXPORT void ScriptResourceManager::getScriptResource(const ResourceHandle<Texture>& resourceHandle, ScriptTexture** out, bool create);
 	template BS_SCR_BE_EXPORT void ScriptResourceManager::getScriptResource(const ResourceHandle<SpriteTexture>& resourceHandle, ScriptSpriteTexture** out, bool create);
 	template BS_SCR_BE_EXPORT void ScriptResourceManager::getScriptResource(const ResourceHandle<Mesh>& resourceHandle, ScriptMesh** out, bool create);
 	template BS_SCR_BE_EXPORT void ScriptResourceManager::getScriptResource(const ResourceHandle<Material>& resourceHandle, ScriptMaterial** out, bool create);

+ 1 - 18
Source/SBansheeEngine/Source/BsScriptResourceRef.cpp

@@ -6,7 +6,7 @@
 #include "BsMonoUtil.h"
 #include "BsResources.h"
 #include "BsScriptResource.h"
-#include "BsScriptTexture2D.h"
+#include "BsScriptTexture.h"
 #include "BsScriptResourceManager.h"
 #include "BsApplication.h"
 
@@ -31,23 +31,6 @@ namespace bs
 		return obj;
 	}
 
-	MonoObject* ScriptResourceRef::create(const WeakResourceHandle<Texture>& handle, TextureType type)
-	{
-		switch (type)
-		{
-		case TEX_TYPE_2D:
-			return createInternal(handle);
-		case TEX_TYPE_3D:
-			return createInternal(handle);
-		case TEX_TYPE_CUBE_MAP:
-			return createInternal(handle);
-		default:
-			break;
-		}
-
-		return nullptr;
-	}
-
 	bool ScriptResourceRef::internal_IsLoaded(ScriptResourceRef* nativeInstance)
 	{
 		return nativeInstance->mResource.isLoaded(false);

+ 4 - 4
Source/SBansheeEngine/Source/BsScriptSpriteTexture.cpp

@@ -7,7 +7,7 @@
 #include "BsMonoClass.h"
 #include "BsMonoManager.h"
 #include "BsSpriteTexture.h"
-#include "BsScriptTexture2D.h"
+#include "BsScriptTexture.h"
 
 namespace bs
 {
@@ -43,7 +43,7 @@ namespace bs
 
 	void ScriptSpriteTexture::internal_createInstance(MonoObject* instance, MonoObject* texture, Vector2* offset, Vector2* scale)
 	{
-		ScriptTexture2D* scriptTexture = ScriptTexture2D::toNative(texture);
+		ScriptTexture* scriptTexture = ScriptTexture::toNative(texture);
 		ScriptSpriteTexture* scriptInstance;
 
 		if (scriptTexture == nullptr)
@@ -68,13 +68,13 @@ namespace bs
 		if (!texture.isLoaded())
 			return nullptr;
 
-		ScriptTexture2D* scriptTexture = nullptr;
+		ScriptTexture* scriptTexture = nullptr;
 		ScriptResourceManager::instance().getScriptResource(texture, &scriptTexture, true);
 
 		return scriptTexture->getManagedInstance();
 	}
 
-	void ScriptSpriteTexture::internal_SetTexture(ScriptSpriteTexture* thisPtr, ScriptTexture2D* value)
+	void ScriptSpriteTexture::internal_SetTexture(ScriptSpriteTexture* thisPtr, ScriptTexture* value)
 	{
 		HSpriteTexture spriteTexture = thisPtr->getHandle();
 		if (!spriteTexture.isLoaded())

+ 117 - 2
Source/SBansheeEngine/Source/BsScriptTexture.cpp

@@ -5,17 +5,24 @@
 #include "BsMonoField.h"
 #include "BsMonoClass.h"
 #include "BsMonoManager.h"
+#include "BsScriptResourceManager.h"
+#include "BsScriptAsyncOp.h"
+
+#include "BsScriptPixelData.generated.h"
+
+using namespace std::placeholders;
 
 namespace bs
 {
-	ScriptTexture::ScriptTexture(MonoObject* instance)
-		:ScriptObject(instance)
+	ScriptTexture::ScriptTexture(MonoObject* instance, const HTexture& texture)
+		:TScriptResource(instance, texture)
 	{
 
 	}
 
 	void ScriptTexture::initRuntimeData()
 	{
+		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptTexture::internal_createInstance);
 		metaData.scriptClass->addInternalCall("Internal_GetPixelFormat", &ScriptTexture::internal_getPixelFormat);
 		metaData.scriptClass->addInternalCall("Internal_GetUsage", &ScriptTexture::internal_getUsage);
 		metaData.scriptClass->addInternalCall("Internal_GetWidth", &ScriptTexture::internal_getWidth);
@@ -23,6 +30,40 @@ namespace bs
 		metaData.scriptClass->addInternalCall("Internal_GetGammaCorrection", &ScriptTexture::internal_getGammaCorrection);
 		metaData.scriptClass->addInternalCall("Internal_GetSampleCount", &ScriptTexture::internal_getSampleCount);
 		metaData.scriptClass->addInternalCall("Internal_GetMipmapCount", &ScriptTexture::internal_getMipmapCount);
+		metaData.scriptClass->addInternalCall("Internal_GetPixels", &ScriptTexture::internal_getPixels);
+		metaData.scriptClass->addInternalCall("Internal_GetGPUPixels", &ScriptTexture::internal_getGPUPixels);
+		metaData.scriptClass->addInternalCall("Internal_SetPixels", &ScriptTexture::internal_setPixels);
+		metaData.scriptClass->addInternalCall("Internal_SetPixelsArray", &ScriptTexture::internal_setPixelsArray);
+	}
+
+	void ScriptTexture::internal_createInstance(MonoObject* instance, PixelFormat format, UINT32 width,
+		UINT32 height, UINT32 depth, TextureType texType, TextureUsage usage, UINT32 numSamples, bool hasMipmaps, 
+		bool gammaCorrection)
+	{
+		int numMips = 0;
+		if (hasMipmaps)
+			numMips = PixelUtil::getMaxMipmaps(width, height, 1, format);
+
+		TEXTURE_DESC texDesc;
+		texDesc.type = texType;
+		texDesc.width = width;
+		texDesc.height = height;
+		
+		if (texType == TEX_TYPE_3D)
+			texDesc.depth = depth;
+		else
+			texDesc.depth = 1;
+
+		texDesc.numMips = numMips;
+		texDesc.format = format;
+		texDesc.usage = usage;
+		texDesc.hwGamma = gammaCorrection;
+		texDesc.numSamples = numSamples;
+
+		HTexture texture = Texture::create(texDesc);
+
+		ScriptTexture* scriptInstance;
+		ScriptResourceManager::instance().createScriptResource(instance, texture, &scriptInstance);
 	}
 
 	void ScriptTexture::internal_getPixelFormat(ScriptTexture* thisPtr, PixelFormat* value)
@@ -66,4 +107,78 @@ namespace bs
 		HTexture texture = static_resource_cast<Texture>(thisPtr->getGenericHandle());
 		*value = (TextureUsage)texture->getProperties().getNumMipmaps();
 	}
+
+	MonoObject* ScriptTexture::internal_getPixels(ScriptTexture* thisPtr, UINT32 face, UINT32 mipLevel)
+	{
+		HTexture texture = thisPtr->getHandle();
+
+		SPtr<PixelData> pixelData = texture->getProperties().allocBuffer(face, mipLevel);
+		texture->readCachedData(*pixelData, face, mipLevel);
+
+		return ScriptPixelData::create(pixelData);
+	}
+
+	MonoObject* ScriptTexture::internal_getGPUPixels(ScriptTexture* thisPtr, UINT32 face, UINT32 mipLevel)
+	{
+		HTexture texture = thisPtr->getHandle();
+		SPtr<PixelData> readData = texture->getProperties().allocBuffer(face, mipLevel);
+
+		AsyncOp asyncOp = texture->readData(readData, face, mipLevel);
+
+		std::function<MonoObject*(const AsyncOp&, const SPtr<PixelData>&)> asyncOpToMono =
+			[&](const AsyncOp& op, const SPtr<PixelData>& returnValue)
+		{
+			return ScriptPixelData::create(returnValue);
+		};
+
+		return ScriptAsyncOp::create(asyncOp, std::bind(asyncOpToMono, _1, readData));
+	}
+
+	void ScriptTexture::internal_setPixels(ScriptTexture* thisPtr, MonoObject* data, UINT32 face, UINT32 mipLevel)
+	{
+		ScriptPixelData* scriptPixelData = ScriptPixelData::toNative(data);
+
+		if (scriptPixelData != nullptr)
+		{
+			HTexture texture = thisPtr->getHandle();
+			texture->writeData(scriptPixelData->getInternal(), face, mipLevel, false);
+		}
+	}
+
+	void ScriptTexture::internal_setPixelsArray(ScriptTexture* thisPtr, MonoArray* colors, UINT32 face, UINT32 mipLevel)
+	{
+		if (colors == nullptr)
+		{
+			LOGWRN("SetPixels called with a null array. Ignoring call.");
+			return;
+		}
+
+		ScriptArray scriptArray(colors);
+		Color* colorsRaw = (Color*)scriptArray.getRawPtr(sizeof(Color), 0);
+		UINT32 numElements = (UINT32)scriptArray.size();
+
+		HTexture texture = thisPtr->getHandle();
+		const TextureProperties& props = texture->getProperties();
+
+		UINT32 texNumElements = props.getWidth() * props.getHeight() * props.getDepth();
+
+		if (texNumElements != numElements)
+		{
+			LOGWRN("SetPixels called with incorrect dimensions. Ignoring call.");
+			return;
+		}		
+
+		SPtr<PixelData> pixelData = bs_shared_ptr_new<PixelData>(props.getWidth(), props.getHeight(), props.getDepth(), 
+			props.getFormat());
+		pixelData->allocateInternalBuffer();
+		pixelData->setColors(colorsRaw, numElements);
+
+		texture->writeData(pixelData, face, mipLevel, false);
+	}
+
+
+	MonoObject* ScriptTexture::createInstance()
+	{
+		return metaData.scriptClass->createInstance();
+	}
 }

+ 0 - 117
Source/SBansheeEngine/Source/BsScriptTexture2D.cpp

@@ -1,117 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "BsScriptTexture2D.h"
-#include "BsScriptResourceManager.h"
-#include "BsScriptMeta.h"
-#include "BsMonoField.h"
-#include "BsMonoClass.h"
-#include "BsMonoManager.h"
-#include "BsTexture.h"
-#include "BsPixelUtil.h"
-#include "BsException.h"
-#include "BsScriptAsyncOp.h"
-#include "BsCoreThread.h"
-
-#include "BsScriptPixelData.generated.h"
-
-using namespace std::placeholders;
-
-namespace bs
-{
-	ScriptTexture2D::ScriptTexture2D(MonoObject* instance, const HTexture& texture)
-		:TScriptResource(instance, texture)
-	{
-
-	}
-
-	void ScriptTexture2D::initRuntimeData()
-	{
-		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptTexture2D::internal_createInstance);
-		metaData.scriptClass->addInternalCall("Internal_GetPixels", &ScriptTexture2D::internal_getPixels);
-		metaData.scriptClass->addInternalCall("Internal_GetGPUPixels", &ScriptTexture2D::internal_getGPUPixels);
-		metaData.scriptClass->addInternalCall("Internal_SetPixels", &ScriptTexture2D::internal_setPixels);
-		metaData.scriptClass->addInternalCall("Internal_SetPixelsArray", &ScriptTexture2D::internal_setPixelsArray);
-	}
-
-	void ScriptTexture2D::internal_createInstance(MonoObject* instance, PixelFormat format, UINT32 width,
-		UINT32 height, TextureUsage usage, UINT32 numSamples, bool hasMipmaps, bool gammaCorrection)
-	{
-		int numMips = 0;
-		if(hasMipmaps)
-			numMips = PixelUtil::getMaxMipmaps(width, height, 1, format);
-
-		TEXTURE_DESC texDesc;
-		texDesc.type = TEX_TYPE_2D;
-		texDesc.width = width;
-		texDesc.height = height;
-		texDesc.numMips = numMips;
-		texDesc.format = format;
-		texDesc.usage = usage;
-		texDesc.hwGamma = gammaCorrection;
-		texDesc.numSamples = numSamples;
-
-		HTexture texture = Texture::create(texDesc);
-
-		ScriptTexture2D* scriptInstance;
-		ScriptResourceManager::instance().createScriptResource(instance, texture, &scriptInstance);
-	}
-
-	MonoObject* ScriptTexture2D::internal_getPixels(ScriptTexture2D* thisPtr, UINT32 mipLevel)
-	{
-		HTexture texture = thisPtr->getHandle();
-
-		SPtr<PixelData> pixelData = texture->getProperties().allocBuffer(0, mipLevel);
-		texture->readCachedData(*pixelData, 0, mipLevel);
-
-		return ScriptPixelData::create(pixelData);
-	}
-
-	MonoObject* ScriptTexture2D::internal_getGPUPixels(ScriptTexture2D* thisPtr, UINT32 mipLevel)
-	{
-		HTexture texture = thisPtr->getHandle();
-		SPtr<PixelData> readData = texture->getProperties().allocBuffer(0, mipLevel);
-
-		AsyncOp asyncOp = texture->readData(readData, 0, mipLevel);
-
-		std::function<MonoObject*(const AsyncOp&, const SPtr<PixelData>&)> asyncOpToMono =
-			[&](const AsyncOp& op, const SPtr<PixelData>& returnValue)
-		{
-			return ScriptPixelData::create(returnValue);
-		};
-
-		return ScriptAsyncOp::create(asyncOp, std::bind(asyncOpToMono, _1, readData));
-	}
-
-	void ScriptTexture2D::internal_setPixels(ScriptTexture2D* thisPtr, MonoObject* data, UINT32 mipLevel)
-	{
-		ScriptPixelData* scriptPixelData = ScriptPixelData::toNative(data);
-
-		if (scriptPixelData != nullptr)
-		{
-			HTexture texture = thisPtr->getHandle();
-			texture->writeData(scriptPixelData->getInternal(), 0, mipLevel, false);
-		}
-	}
-
-	void ScriptTexture2D::internal_setPixelsArray(ScriptTexture2D* thisPtr, MonoArray* colors, UINT32 mipLevel)
-	{
-		ScriptArray scriptArray(colors);
-
-		Color* colorsRaw = (Color*)scriptArray.getRawPtr(sizeof(Color), 0);
-		UINT32 numElements = (UINT32)scriptArray.size();
-
-		HTexture texture = thisPtr->getHandle();
-		const TextureProperties& props = texture->getProperties();
-
-		SPtr<PixelData> pixelData = bs_shared_ptr_new<PixelData>(props.getWidth(), props.getHeight(), props.getDepth(), props.getFormat());
-		pixelData->allocateInternalBuffer();
-		pixelData->setColors(colorsRaw, numElements);
-
-		texture->writeData(pixelData, 0, mipLevel, false);
-	}
-
-	MonoObject* ScriptTexture2D::createInstance()
-	{
-		return metaData.scriptClass->createInstance();
-	}
-}

+ 0 - 100
Source/SBansheeEngine/Source/BsScriptTexture3D.cpp

@@ -1,100 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "BsScriptTexture3D.h"
-#include "BsScriptResourceManager.h"
-#include "BsScriptMeta.h"
-#include "BsMonoField.h"
-#include "BsMonoClass.h"
-#include "BsMonoManager.h"
-#include "BsTexture.h"
-#include "BsPixelUtil.h"
-#include "BsException.h"
-#include "BsScriptAsyncOp.h"
-#include "BsCoreThread.h"
-
-#include "BsScriptPixelData.generated.h"
-
-using namespace std::placeholders;
-
-namespace bs
-{
-	ScriptTexture3D::ScriptTexture3D(MonoObject* instance, const HTexture& texture)
-		:TScriptResource(instance, texture)
-	{
-
-	}
-
-	void ScriptTexture3D::initRuntimeData()
-	{
-		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptTexture3D::internal_createInstance);
-		metaData.scriptClass->addInternalCall("Internal_GetPixels", &ScriptTexture3D::internal_getPixels);
-		metaData.scriptClass->addInternalCall("Internal_GetGPUPixels", &ScriptTexture3D::internal_getGPUPixels);
-		metaData.scriptClass->addInternalCall("Internal_SetPixels", &ScriptTexture3D::internal_setPixels);
-	}
-
-	void ScriptTexture3D::internal_createInstance(MonoObject* instance, PixelFormat format, UINT32 width,
-		UINT32 height, UINT32 depth, TextureUsage usage, bool hasMipmaps, bool gammaCorrection)
-	{
-		int numMips = 0;
-		if (hasMipmaps)
-			numMips = PixelUtil::getMaxMipmaps(width, height, depth, format);
-
-		TEXTURE_DESC texDesc;
-		texDesc.type = TEX_TYPE_3D;
-		texDesc.width = width;
-		texDesc.height = height;
-		texDesc.depth = depth;
-		texDesc.numMips = numMips;
-		texDesc.format = format;
-		texDesc.usage = usage;
-		texDesc.hwGamma = gammaCorrection;
-
-		HTexture texture = Texture::create(texDesc);
-
-		ScriptTexture3D* scriptInstance;
-		ScriptResourceManager::instance().createScriptResource(instance, texture, &scriptInstance);
-	}
-
-	MonoObject* ScriptTexture3D::internal_getPixels(ScriptTexture3D* thisPtr, UINT32 mipLevel)
-	{
-		HTexture texture = thisPtr->getHandle();
-
-		SPtr<PixelData> pixelData = texture->getProperties().allocBuffer(0, mipLevel);
-		texture->readCachedData(*pixelData, 0, mipLevel);
-
-		return ScriptPixelData::create(pixelData);
-	}
-
-	MonoObject* ScriptTexture3D::internal_getGPUPixels(ScriptTexture3D* thisPtr, UINT32 mipLevel)
-	{
-		HTexture texture = thisPtr->getHandle();
-		SPtr<PixelData> readData = texture->getProperties().allocBuffer(0, mipLevel);
-
-		AsyncOp asyncOp = texture->readData(readData, 0, mipLevel);
-
-		std::function<MonoObject*(const AsyncOp&, const SPtr<PixelData>&)> asyncOpToMono =
-			[&](const AsyncOp& op, const SPtr<PixelData>& returnValue)
-		{
-			return ScriptPixelData::create(returnValue);
-		};
-
-		return ScriptAsyncOp::create(asyncOp, std::bind(asyncOpToMono, _1, readData));
-	}
-
-	void ScriptTexture3D::internal_setPixels(ScriptTexture3D* thisPtr, MonoObject* data, UINT32 mipLevel)
-	{
-		ScriptPixelData* scriptPixelData = ScriptPixelData::toNative(data);
-
-		if (scriptPixelData != nullptr)
-		{
-			HTexture texture = thisPtr->getHandle();
-
-			texture->writeData(scriptPixelData->getInternal(), 0, mipLevel, false);
-		}
-	}
-
-	MonoObject* ScriptTexture3D::createInstance()
-	{
-		return metaData.scriptClass->createInstance();
-	}
-}

+ 0 - 98
Source/SBansheeEngine/Source/BsScriptTextureCube.cpp

@@ -1,98 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "BsScriptTextureCube.h"
-#include "BsScriptResourceManager.h"
-#include "BsScriptMeta.h"
-#include "BsMonoField.h"
-#include "BsMonoClass.h"
-#include "BsMonoManager.h"
-#include "BsTexture.h"
-#include "BsPixelUtil.h"
-#include "BsScriptAsyncOp.h"
-#include "BsCoreThread.h"
-
-#include "BsScriptPixelData.generated.h"
-
-using namespace std::placeholders;
-
-namespace bs
-{
-	ScriptTextureCube::ScriptTextureCube(MonoObject* instance, const HTexture& texture)
-		:TScriptResource(instance, texture)
-	{
-
-	}
-
-	void ScriptTextureCube::initRuntimeData()
-	{
-		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptTextureCube::internal_createInstance);
-		metaData.scriptClass->addInternalCall("Internal_GetPixels", &ScriptTextureCube::internal_getPixels);
-		metaData.scriptClass->addInternalCall("Internal_GetGPUPixels", &ScriptTextureCube::internal_getGPUPixels);
-		metaData.scriptClass->addInternalCall("Internal_SetPixels", &ScriptTextureCube::internal_setPixels);
-	}
-
-	void ScriptTextureCube::internal_createInstance(MonoObject* instance, PixelFormat format, UINT32 width,
-		UINT32 height, TextureUsage usage, UINT32 numSamples, bool hasMipmaps, bool gammaCorrection)
-	{
-		int numMips = 0;
-		if (hasMipmaps)
-			numMips = PixelUtil::getMaxMipmaps(width, height, 1, format);
-
-		TEXTURE_DESC texDesc;
-		texDesc.type = TEX_TYPE_CUBE_MAP;
-		texDesc.width = width;
-		texDesc.height = height;
-		texDesc.numMips = numMips;
-		texDesc.format = format;
-		texDesc.usage = usage;
-		texDesc.hwGamma = gammaCorrection;
-		texDesc.numSamples = numSamples;
-
-		HTexture texture = Texture::create(texDesc);
-
-		ScriptTextureCube* scriptInstance;
-		ScriptResourceManager::instance().createScriptResource(instance, texture, &scriptInstance);
-	}
-
-	MonoObject* ScriptTextureCube::internal_getPixels(ScriptTextureCube* thisPtr, UINT32 face, UINT32 mipLevel)
-	{
-		HTexture texture = thisPtr->getHandle();
-
-		SPtr<PixelData> pixelData = texture->getProperties().allocBuffer(face, mipLevel);
-		texture->readCachedData(*pixelData, face, mipLevel);
-
-		return ScriptPixelData::create(pixelData);
-	}
-
-	MonoObject* ScriptTextureCube::internal_getGPUPixels(ScriptTextureCube* thisPtr, UINT32 face, UINT32 mipLevel)
-	{
-		HTexture texture = thisPtr->getHandle();
-		SPtr<PixelData> readData = texture->getProperties().allocBuffer(face, mipLevel);
-
-		AsyncOp asyncOp = texture->readData(readData, face, mipLevel);
-
-		std::function<MonoObject*(const AsyncOp&, const SPtr<PixelData>&)> asyncOpToMono =
-			[&](const AsyncOp& op, const SPtr<PixelData>& returnValue)
-		{
-			return ScriptPixelData::create(returnValue);
-		};
-
-		return ScriptAsyncOp::create(asyncOp, std::bind(asyncOpToMono, _1, readData));
-	}
-
-	void ScriptTextureCube::internal_setPixels(ScriptTextureCube* thisPtr, MonoObject* data, UINT32 face, UINT32 mipLevel)
-	{
-		ScriptPixelData* scriptPixelData = ScriptPixelData::toNative(data);
-
-		if (scriptPixelData != nullptr)
-		{
-			HTexture texture = thisPtr->getHandle();
-			texture->writeData(scriptPixelData->getInternal(), face, mipLevel, false);
-		}
-	}
-
-	MonoObject* ScriptTextureCube::createInstance()
-	{
-		return metaData.scriptClass->createInstance();
-	}
-}