Ejemplo n.º 1
0
 public Sprite(Tex image, SpriteType type = SpriteType.Atlased, string atlasId = "default")
 {
     _spriteInst = NativeAPI.sprite_create(image._texInst, type, atlasId);
     if (_spriteInst == IntPtr.Zero)
     {
         Log.Write(LogLevel.Warning, "Couldn't create sprite!");
     }
 }
Ejemplo n.º 2
0
 /// <summary>Sets a shader parameter with the given name to the provided value. If no parameter
 /// is found, nothing happens, and the value is not set!</summary>
 /// <param name="name">Name of the shader parameter.</param>
 /// <param name="value">New value for the parameter.</param>
 public void SetTexture(string name, Tex value)
 {
     NativeAPI.material_set_texture(_materialInst, name, value._texInst);
 }
Ejemplo n.º 3
0
        /// <summary>Create a sprite from a Texture object!</summary>
        /// <param name="image">The texture to build a sprite from. Must be a
        /// valid, 2D image!</param>
        /// <param name="type">Should this sprite be atlased, or an
        /// individual image? Adding this as an atlased image is better for
        /// performance, but will cause the atlas to be rebuilt! Images that
        /// take up too much space on the atlas, or might be loaded or
        /// unloaded during runtime may be better as Single rather than
        /// Atlased!</param>
        /// <param name="atlasId">The name of which atlas the sprite should
        /// belong to, this is only relevant if the SpriteType is Atlased.
        /// </param>
        /// <returns>A Sprite asset, or null if the image failed when adding
        /// to the sprite system!</returns>
        public static Sprite FromTex(Tex image, SpriteType type = SpriteType.Atlased, string atlasId = "default")
        {
            IntPtr inst = NativeAPI.sprite_create(image._inst, type, atlasId);

            return(inst == IntPtr.Zero ? null : new Sprite(inst));
        }