Beispiel #1
0
        private static GUISkin CreateSkin()
        {
            var newSkin = Object.Instantiate(GUI.skin);

            Object.DontDestroyOnLoad(newSkin);

            // Load the custom skin from resources
            var texData = ResourceUtils.GetEmbeddedResource("guisharp-box.png");

            _boxBackground = UnityFeatureHelper.LoadTexture(texData);
            Object.DontDestroyOnLoad(_boxBackground);
            newSkin.box.onNormal.background = null;
            newSkin.box.normal.background   = _boxBackground;
            newSkin.box.normal.textColor    = Color.white;

            texData        = ResourceUtils.GetEmbeddedResource("guisharp-window.png");
            _winBackground = UnityFeatureHelper.LoadTexture(texData);
            Object.DontDestroyOnLoad(_winBackground);
            newSkin.window.onNormal.background = null;
            newSkin.window.normal.background   = _winBackground;
            newSkin.window.padding             = new RectOffset(6, 6, 22, 6);
            newSkin.window.border           = new RectOffset(10, 10, 20, 10);
            newSkin.window.normal.textColor = Color.white;

            newSkin.button.padding          = new RectOffset(4, 4, 3, 3);
            newSkin.button.normal.textColor = Color.white;

            newSkin.textField.normal.textColor = Color.white;

            newSkin.label.normal.textColor = Color.white;

            return(newSkin);
        }
        private static GUISkin CreateSkin()
        {
            // Reflection because unity 4.x refuses to instantiate if built with newer versions of UnityEngine
            var newSkin = typeof(Object).GetMethod("Instantiate", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(Object) }, null).Invoke(null, new object[] { GUI.skin }) as GUISkin;

            Object.DontDestroyOnLoad(newSkin);

            // Load the custom skin from resources
            var texData = ResourceUtils.GetEmbeddedResource("guisharp-box.png");

            _boxBackground = UnityFeatureHelper.LoadTexture(texData);
            Object.DontDestroyOnLoad(_boxBackground);
            newSkin.box.onNormal.background = null;
            newSkin.box.normal.background   = _boxBackground;
            newSkin.box.normal.textColor    = Color.white;

            texData        = ResourceUtils.GetEmbeddedResource("guisharp-window.png");
            _winBackground = UnityFeatureHelper.LoadTexture(texData);
            Object.DontDestroyOnLoad(_winBackground);
            newSkin.window.onNormal.background = null;
            newSkin.window.normal.background   = _winBackground;
            newSkin.window.padding             = new RectOffset(6, 6, 22, 6);
            newSkin.window.border           = new RectOffset(10, 10, 20, 10);
            newSkin.window.normal.textColor = Color.white;

            newSkin.button.padding          = new RectOffset(4, 4, 3, 3);
            newSkin.button.normal.textColor = Color.white;

            newSkin.textField.normal.textColor = Color.white;

            newSkin.label.normal.textColor = Color.white;

            return(newSkin);
        }