Esempio n. 1
0
        }//Play

        void Awake()
        {
            //There should only ever be one of these, so keep track of the singleton instance.
            if (_self == null)
            {
                _self = this;
            }
            else
            {
                Debug.LogError("Object \"" + name + "\" tried to create a second Helpdesk instance. Disabling. -" + GetType());
                enabled = false;
                return;
            }//else

            messageQueue = new Queue <HelpdeskMessage>();


            if (defaultFont == null)
            {
                defaultFont = Resources.GetBuiltinResource <Font>("Arial.ttf");
                //font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
            }//if

            if (helpMessage == null)
            {
                Canvas canvas = gameObject.AddComponent <Canvas>();
                canvas.renderMode = RenderMode.ScreenSpaceOverlay;
                gameObject.AddComponent <CanvasScaler>();

                helpMessage = new GameObject("Helpdesk text").AddComponent <Text>();
                helpMessage.transform.SetParent(canvas.transform);

                helpMessage.font     = defaultFont;
                helpMessage.fontSize = defaultFontSize;

                helpMessage.text  = "ASDJLASJDLASJKDLKAS";
                helpMessage.color = Color.white;

                helpMessage.alignment = TextAnchor.LowerCenter;
                helpMessage.rectTransform.sizeDelta = new Vector2(Screen.width - Screen.width * 0.2f, Screen.height / 7);
                helpMessage.rectTransform.anchorMin = new Vector2(0.5f, 0);
                helpMessage.rectTransform.anchorMax = new Vector2(0.5f, 0);
                helpMessage.horizontalOverflow      = HorizontalWrapMode.Wrap;
                helpMessage.verticalOverflow        = VerticalWrapMode.Overflow;

                helpMessage.supportRichText = true;

                Shadow textShadow = helpMessage.gameObject.AddComponent <Shadow>();
                textShadow.effectColor = Color.black;


                helpMessage.transform.position = new Vector3(Screen.width * 0.5f, Screen.height / 10, 0);

                helpMessage.enabled = false; //Turn it off by default.
            }//if
        }//Start
Esempio n. 2
0
 private static void InitSingleton()
 {
     _self = new GameObject("Helpdesk").AddComponent <EasyHelpdesk>();
 }                                                                                                        //InitSingleton