Beispiel #1
0
        public static World_Sprite CreateDebugButton(Transform parent, Vector3 localPosition,
                                                     string text, System.Action ClickFunc,
                                                     int fontSize   = 30, float paddingX = 5,
                                                     float paddingY = 5)
        {
            GameObject gameObject = new GameObject("DebugButton");

            gameObject.transform.parent        = parent;
            gameObject.transform.localPosition = localPosition;

            TextMesh textMesh = UtilsClass.CreateWorldText(
                text,
                gameObject.transform,
                Vector3.zero,
                fontSize,
                Color.white,
                TextAnchor.MiddleCenter,
                TextAlignment.Center,
                20000
                );
            Bounds rendererBounds = textMesh.GetComponent <MeshRenderer>().bounds;

            Color color = UtilsClass.GetColorFromString("00BA00FF");

            if (color.r >= 1f)
            {
                color.r = .9f;
            }
            if (color.g >= 1f)
            {
                color.g = .9f;
            }
            if (color.b >= 1f)
            {
                color.b = .9f;
            }
            Color colorOver = color * 1.1f; // button over color lighter

            World_Sprite worldSprite = new World_Sprite(
                gameObject.transform,
                Vector3.zero,
                rendererBounds.size + new Vector3(paddingX, paddingY),
                Assets.i.s_White,
                color,
                sortingOrderDefault
                );

            worldSprite.AddButton(
                ClickFunc,
                () => worldSprite.SetColor(colorOver),
                () => worldSprite.SetColor(color)
                );
            return(worldSprite);
        }
Beispiel #2
0
        public static World_Sprite CreateDebugButton(Vector3 position, System.Action ClickFunc)
        {
            World_Sprite worldSprite = new World_Sprite(
                null,
                position,
                new Vector3(10, 10),
                Assets.i.s_White,
                Color.green,
                sortingOrderDefault
                );

            worldSprite.AddButton(ClickFunc, null, null);
            return(worldSprite);
        }