Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Created March 13, 2015 20:33
Show Gist options
  • Select an option

  • Save unitycoder/2be9dea1acde0c210f94 to your computer and use it in GitHub Desktop.

Select an option

Save unitycoder/2be9dea1acde0c210f94 to your computer and use it in GitHub Desktop.

Revisions

  1. unitycoder created this gist Mar 13, 2015.
    5 changes: 5 additions & 0 deletions gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    // need to create new sprite, cannot assign or convert Texture2D into sprite
    Sprite sprite = Sprite.Create (tex, new Rect(0,0,tex.width,tex.height), new Vector2 (0, 0), pixelToUnits);
    GetComponent<SpriteRenderer>().sprite = sprite;

    http://docs.unity3d.com/ScriptReference/Sprite.Create.html