コード例 #1
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            string textRaw = "";

            if (ParseUtil.ParseStringIndirect(ref textRaw, node, "text"))
            {
                text = WebUtility.UrlDecode(textRaw);
            }

            string fontName = "";

            if (ParseUtil.ParseStringIndirect(ref fontName, node, "fontName"))
            {
                font = DecalConfig.GetFont(fontName);
            }
            else if (font == null)
            {
                font = DecalConfig.GetFont("Calibri SDF");
            }

            int styleInt = 0;

            if (ParseUtil.ParseIntIndirect(ref styleInt, node, "style"))
            {
                style = (FontStyles)styleInt;
            }

            ParseUtil.ParseColor32Indirect(ref fillColor, node, "fillColor");
            ParseUtil.ParseColor32Indirect(ref outlineColor, node, "outlineColor");

            if (HighLogic.LoadedSceneIsGame)
            {
                // For some reason, rendering doesnt work right on the first frame a scene is loaded
                // So delay any rendering until the next frame when called in OnLoad
                // This is probably a problem with Unity, not KSP
                StartCoroutine(UpdateTextLate());
            }
            else
            {
                UpdateText();
            }
        }