Search Unity

Panel's Backgound

Discussion in 'UGUI & TextMesh Pro' started by IK, Jul 22, 2016.

  1. IK

    IK

    Joined:
    Oct 29, 2012
    Posts:
    34
    I must be missing something obvious, but where is the image for the basic panels located? I'd like to be able to assign it to UI elements created at run time until I am ready to replace it with something of my own design but I can't find it anywhere.
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
  3. IK

    IK

    Joined:
    Oct 29, 2012
    Posts:
    34
    Thanks @eses ! Just what I needed.

    Encase anyone else comes across this, this is what I did to get it to work based off of the other thread:

    Code (csharp):
    1.  
    2. //at the top
    3. using UnityEditor;
    4.  
    5. //in a static class that I reference sprites from
    6.     private const string kBackgroundSpriteResourcePath = "UI/Skin/Background.psd";
    7.     public static Sprite basicBackground = AssetDatabase.GetBuiltinExtraResource<Sprite>(kBackgroundSpriteResourcePath);
    8.  
    9. //when needed elsewhere (doesn't require the namespace UnityEditor)
    10.         GameObject panel = new GameObject("Grouping Panel");
    11.         Image i = panel.AddComponent<Image>();
    12.         i.sprite = GameConstants.basicBackground;
    13.         i.type = Image.Type.Sliced;
    14.  
    15.  
     
    Last edited: Jul 22, 2016
    eses likes this.