コード例 #1
0
        private static void ParseConfig(ConfigNode node)
        {
            ParseUtil.ParseIntIndirect(ref _decalLayer, node, "decalLayer");
            ParseUtil.ParseBoolIndirect(ref _selectableInFlight, node, "selectableInFlight");

            foreach (var blacklist in node.GetNodes("SHADERBLACKLIST"))
            {
                foreach (var shaderName in blacklist.GetValuesList("shader"))
                {
                    _shaderBlacklist.Add(shaderName);
                }
            }

            var allFonts = Resources.FindObjectsOfTypeAll <TMP_FontAsset>();

            foreach (var fontNode in node.GetNodes("FONT"))
            {
                try {
                    var font = new DecalFont(fontNode, allFonts);
                    _fontList.Add(font.Name, font);
                }
                catch (Exception e) {
                    Debug.LogException(e);
                }
            }
        }
コード例 #2
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();
            }
        }