summaryrefslogtreecommitdiff
path: root/Runtime/Export/SpritesBindings.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Runtime/Export/SpritesBindings.txt')
-rw-r--r--Runtime/Export/SpritesBindings.txt191
1 files changed, 191 insertions, 0 deletions
diff --git a/Runtime/Export/SpritesBindings.txt b/Runtime/Export/SpritesBindings.txt
new file mode 100644
index 0000000..3f9dc97
--- /dev/null
+++ b/Runtime/Export/SpritesBindings.txt
@@ -0,0 +1,191 @@
+C++RAW
+#include "UnityPrefix.h"
+#include "Configuration/UnityConfigure.h"
+#include "Runtime/Scripting/ScriptingExportUtility.h"
+#include "Runtime/Scripting/Scripting.h"
+#if ENABLE_SPRITES
+#include "Runtime/Mono/MonoBehaviour.h"
+#include "Runtime/Filters/Mesh/SpriteRenderer.h"
+#include "Runtime/Graphics/SpriteFrame.h"
+#include "Runtime/Graphics/Texture2D.h"
+#include "Runtime/Scripting/ScriptingExportUtility.h"
+#endif //ENABLE_SPRITES
+
+CSRAW
+using UnityEngine;
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Collections;
+
+#if ENABLE_SPRITES
+namespace UnityEngine
+{
+CSRAW
+ ENUM public SpriteAlignment
+ Center = 0,
+ TopLeft = 1,
+ TopCenter = 2,
+ TopRight = 3,
+ LeftCenter = 4,
+ RightCenter = 5,
+ BottomLeft = 6,
+ BottomCenter = 7,
+ BottomRight = 8,
+ Custom = 9,
+ END
+
+CONDITIONAL ENABLE_SPRITES
+ENUM SpritePackingMode
+ Tight = 0,
+ Rectangle
+END
+
+CONDITIONAL ENABLE_SPRITES
+ENUM SpritePackingRotation
+ None = 0,
+ // Reserved
+ Any = 15
+END
+
+CONDITIONAL ENABLE_SPRITES
+ENUM SpriteMeshType
+ FullRect = 0,
+ Tight = 1
+END
+
+CONDITIONAL ENABLE_SPRITES
+/// Describes one sprite frame.
+CLASS Sprite : Object
+
+ CUSTOM public static Sprite Create(Texture2D texture, Rect rect, Vector2 pivot, float pixelsToUnits = 100.0f, uint extrude = 0, SpriteMeshType meshType = SpriteMeshType.Tight)
+ {
+ if (texture.IsNull())
+ return NULL;
+
+ Sprite* sprite = CreateObjectFromCode<Sprite>();
+ sprite->Initialize(texture, rect, pivot, pixelsToUnits, extrude, meshType);
+ return Scripting::ScriptingWrapperFor(sprite);
+ }
+
+ CUSTOM_PROP Bounds bounds
+ {
+ return self->GetBounds();
+ }
+
+ // Sprite definition rectangle on source texture (in texels).
+ CUSTOM_PROP Rect rect
+ {
+ return self->GetRect();
+ }
+
+ CUSTOM_PROP Texture2D texture
+ {
+ return Scripting::ScriptingWrapperFor(self->GetRenderDataForPlayMode().texture);
+ }
+
+ // Sprite rectangle on texture (in texels).
+ CUSTOM_PROP Rect textureRect
+ {
+ const SpriteRenderData& rd = self->GetRenderDataForPlayMode(); // RenderData must match <texture> accessor's behavior.
+ if (rd.settings.packed && rd.settings.packingMode != kSPMRectangle)
+ Scripting::RaiseMonoException("Sprite is not rectangle-packed. TextureRect is invalid.");
+ return rd.textureRect;
+ }
+
+ // Sprite rectangle offset in sprite definition rectangle space (in texels).
+ CSRAW public Vector2 textureRectOffset
+ {
+ get
+ {
+ Vector2 v;
+ Internal_GetTextureRectOffset(this, out v);
+ return v;
+ }
+ }
+
+ CUSTOM_PROP bool packed
+ {
+ return self->GetIsPacked();
+ }
+
+ CUSTOM_PROP SpritePackingMode packingMode
+ {
+ const SpriteRenderData& rd = self->GetRenderData(true); // RenderData must always come from atlasing.
+ if (!rd.settings.packed)
+ Scripting::RaiseMonoException("Sprite is not packed.");
+ return (SpritePackingMode)rd.settings.packingMode;
+ }
+
+ CUSTOM_PROP SpritePackingRotation packingRotation
+ {
+ const SpriteRenderData& rd = self->GetRenderData(true); // RenderData must always come from atlasing.
+ if (!rd.settings.packed)
+ Scripting::RaiseMonoException("Sprite is not packed.");
+ return (SpritePackingRotation)rd.settings.packingRotation;
+ }
+
+ CUSTOM private static void Internal_GetTextureRectOffset(Sprite sprite, out Vector2 output)
+ {
+ const SpriteRenderData& rd = sprite->GetRenderDataForPlayMode(); // RenderData must match <texture> accessor's behavior.
+ if (rd.settings.packed && rd.settings.packingMode != kSPMRectangle)
+ Scripting::RaiseMonoException("Sprite is not rectangle-packed. TextureRectOffset is invalid.");
+ output->x = rd.textureRectOffset.x;
+ output->y = rd.textureRectOffset.y;
+ }
+
+ CONDITIONAL ENABLE_SPRITECOLLIDER
+ CUSTOM_PROP int colliderPathCount
+ {
+ return self->GetPoly().GetPathCount();
+ }
+
+ CONDITIONAL ENABLE_SPRITECOLLIDER
+ CUSTOM public Vector2[] GetColliderPath(int index)
+ {
+ if (index >= self->GetPoly().GetPathCount())
+ {
+ Scripting::RaiseOutOfRangeException("Path %d does not exist.", index);
+ return SCRIPTING_NULL;
+ }
+
+ const Polygon2D::TPath& path = self->GetPoly().GetPath(index);
+ return CreateScriptingArrayStride<Vector2f>(path.data(), path.size(), MONO_COMMON.vector2, sizeof(*path.data()));
+ }
+
+END
+
+CONDITIONAL ENABLE_SPRITES
+/// Renders a Sprite.
+CLASS SpriteRenderer : Renderer
+
+ CSRAW
+ public Sprite sprite
+ {
+ get
+ {
+ return GetSprite_INTERNAL();
+ }
+ set
+ {
+ SetSprite_INTERNAL(value);
+ }
+ }
+
+ CUSTOM private Sprite GetSprite_INTERNAL()
+ {
+ return Scripting::ScriptingWrapperFor(self->GetSprite());
+ }
+
+ CUSTOM private void SetSprite_INTERNAL(Sprite sprite)
+ {
+ self->SetSprite(sprite);
+ }
+
+ AUTO_PROP Color color GetColor SetColor
+
+END
+
+}
+
+#endif //ENABLE_SPRITES