GetBuiltinResource() public static method

public static GetBuiltinResource ( Type type, string path ) : System.Object
type System.Type
path string
return System.Object
コード例 #1
0
        public static void DisplayVRSubtitle(string text, Color textColor, Color outlineColor, Action <Action> onDestroy)
        {
            if (text.IsNullOrWhiteSpace())
            {
                return;
            }
            InitGUI();

            Font fontFace = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf");
            int  fsize    = -5;

            fsize = (int)(fsize < 0 ? (fsize * (Screen.height) / -100.0) : fsize);

            GameObject subtitle = new GameObject("SubtitleText");

            subtitle.transform.SetParent(Pane.transform, false);

            var rect = subtitle.GetOrAddComponent <RectTransform>();

            rect.pivot     = new Vector2(0.5f, 0);
            rect.sizeDelta = new Vector2(Screen.width * .5f * 0.990f, fsize + (fsize * 0.05f));

            var subtitleText = subtitle.GetOrAddComponent <Text>();

            subtitleText.font               = fontFace;
            subtitleText.fontSize           = fsize;
            subtitleText.fontStyle          = fontFace.dynamic ? UnityEngine.FontStyle.Bold : UnityEngine.FontStyle.Normal;
            subtitleText.alignment          = TextAnchor.LowerCenter;
            subtitleText.horizontalOverflow = HorizontalWrapMode.Wrap;
            subtitleText.verticalOverflow   = VerticalWrapMode.Overflow;
            subtitleText.color              = textColor;

            var effectDistance = new Vector2(1.5f, -1.5f);
            var subOutline     = subtitle.GetOrAddComponent <Outline>();

            subOutline.effectColor    = outlineColor;
            subOutline.effectDistance = effectDistance;
            var subShadow = subtitle.GetOrAddComponent <Shadow>();

            subShadow.effectColor    = outlineColor;
            subShadow.effectDistance = effectDistance;

            subtitleText.text = text;
            VRLog.Info(text);

            onDestroy(() => VRPlugin.Destroy(subtitle));
        }
コード例 #2
0
 public static T GetBuiltinResource <T>(string path) where T : Object
 {
     return((T)((object)Resources.GetBuiltinResource(typeof(T), path)));
 }
コード例 #3
0
        private void OnGUI()
        {
            GUISkin skin    = GUI.skin;
            GUISkin gUISkin = ScriptableObject.CreateInstance("GUISkin") as GUISkin;

            gUISkin.box.normal.background    = (Texture2D)Resources.GetBuiltinResource(typeof(Texture2D), "GameSkin/box.png");
            gUISkin.box.normal.textColor     = new Color(0.9f, 0.9f, 0.9f, 1f);
            gUISkin.box.padding.left         = 6;
            gUISkin.box.padding.right        = 6;
            gUISkin.box.padding.top          = 4;
            gUISkin.box.padding.bottom       = 4;
            gUISkin.box.border.left          = 6;
            gUISkin.box.border.right         = 6;
            gUISkin.box.border.top           = 6;
            gUISkin.box.border.bottom        = 6;
            gUISkin.box.margin.left          = 4;
            gUISkin.box.margin.right         = 4;
            gUISkin.box.margin.top           = 4;
            gUISkin.box.margin.bottom        = 4;
            gUISkin.button.normal.background = (Texture2D)Resources.GetBuiltinResource(typeof(Texture2D), "GameSkin/button.png");
            gUISkin.button.normal.textColor  = new Color(0.9f, 0.9f, 0.9f, 1f);
            gUISkin.button.hover.background  = (Texture2D)Resources.GetBuiltinResource(typeof(Texture2D), "GameSkin/button hover.png");
            gUISkin.button.hover.textColor   = Color.white;
            gUISkin.button.active.background = (Texture2D)Resources.GetBuiltinResource(typeof(Texture2D), "GameSkin/button active.png");
            gUISkin.button.active.textColor  = new Color(0.9f, 0.9f, 0.9f, 1f);
            gUISkin.button.border.left       = 6;
            gUISkin.button.border.right      = 6;
            gUISkin.button.border.top        = 6;
            gUISkin.button.border.bottom     = 6;
            gUISkin.button.padding.left      = 8;
            gUISkin.button.padding.right     = 8;
            gUISkin.button.padding.top       = 4;
            gUISkin.button.padding.bottom    = 4;
            gUISkin.button.margin.left       = 4;
            gUISkin.button.margin.right      = 4;
            gUISkin.button.margin.top        = 4;
            gUISkin.button.margin.bottom     = 4;
            gUISkin.label.normal.textColor   = new Color(0.9f, 0.9f, 0.9f, 1f);
            gUISkin.label.padding.left       = 6;
            gUISkin.label.padding.right      = 6;
            gUISkin.label.padding.top        = 4;
            gUISkin.label.padding.bottom     = 4;
            gUISkin.label.margin.left        = 4;
            gUISkin.label.margin.right       = 4;
            gUISkin.label.margin.top         = 4;
            gUISkin.label.margin.bottom      = 4;
            gUISkin.label.alignment          = TextAnchor.UpperLeft;
            gUISkin.window.normal.background = (Texture2D)Resources.GetBuiltinResource(typeof(Texture2D), "GameSkin/window.png");
            gUISkin.window.normal.textColor  = Color.white;
            gUISkin.window.border.left       = 8;
            gUISkin.window.border.right      = 8;
            gUISkin.window.border.top        = 18;
            gUISkin.window.border.bottom     = 8;
            gUISkin.window.padding.left      = 8;
            gUISkin.window.padding.right     = 8;
            gUISkin.window.padding.top       = 20;
            gUISkin.window.padding.bottom    = 5;
            gUISkin.window.alignment         = TextAnchor.UpperCenter;
            gUISkin.window.contentOffset     = new Vector2(0f, -18f);
            GUI.skin        = gUISkin;
            this.windowRect = GUI.Window(0, this.windowRect, new GUI.WindowFunction(this.DoUserAuthorizationDialog), "Unity Web Player Authorization Request");
            GUI.skin        = skin;
        }