コード例 #1
0
        public static void ReplaceAllPHFonts()
        {
            foreach (var kvp in _PHFontNameToAssetName)
            {
                List <string> flags = new List <string>()
                {
                    ""
                };
                var allflags = CapsDistributeEditor.GetOptionalDistributes();
                for (int i = 0; i < allflags.Length; ++i)
                {
                    var flag = allflags[i];
                    if (!ResManager.GetValidDistributeFlagsSet().Contains(flag))
                    {
                        flags.Add(flag);
                    }
                }
                flags.AddRange(ResManager.GetValidDistributeFlags());
                var list = GetFallbackFontNames(kvp.Key, flags.ToArray());

                var fiph = AssetImporter.GetAtPath(kvp.Value) as TrueTypeFontImporter;
                if (fiph != null)
                {
                    if (!ListEquals(fiph.fontNames, list))
                    {
                        fiph.fontNames      = list.ToArray();
                        fiph.fontReferences = null;
                        EditorUtility.SetDirty(fiph);
                        AssetDatabase.WriteImportSettingsIfDirty(kvp.Value);
                        AssetDatabase.ImportAsset(kvp.Value);
                        AssetDatabase.Refresh();
                    }
                }
            }
        }
コード例 #2
0
        public void SaveDistributeFlags()
        {
            var  old     = ResManager.PreRuntimeDFlags;
            bool changed = old.Count != DistributeFlagOrder.Count;

            if (!changed)
            {
                int index = 0;
                foreach (var flag in DistributeFlagOrder)
                {
                    if (old[index++] != flag)
                    {
                        changed = true;
                        break;
                    }
                }
            }
            if (changed)
            {
                AssetDatabase.SaveAssets();
                System.Text.StringBuilder sbflags = new System.Text.StringBuilder();
                foreach (var oflag in DistributeFlagOrder)
                {
                    sbflags.Append("<");
                    sbflags.Append(oflag);
                }
                var path = CapsDistributeEditor.GetDistributeFlagsFilePath();
                System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path));
                System.IO.File.WriteAllText(path, sbflags.ToString());
                AssetDatabase.ImportAsset(CapsModEditor.GetAssetNameFromPath(path));

                ResManager.PreRuntimeDFlags = new List <string>(DistributeFlagOrder);
                CapsDistributeEditor.FireOnDistributeFlagsChanged();
            }
        }
コード例 #3
0
        public static void Init()
        {
            var win = GetWindow <DistributeSelectWindow>();

            win.titleContent        = new GUIContent("Distribute Flags");
            win.DistributeFlags     = new Dictionary <string, bool>();
            win.DistributeFlagOrder = new LinkedList <string>();
            var allflags = CapsDistributeEditor.GetOptionalDistributes();

            for (int i = 0; i < allflags.Length; ++i)
            {
                win.DistributeFlags[allflags[i]] = false;
            }
            var selflags = ResManager.PreRuntimeDFlags;

            for (int i = 0; i < selflags.Count; ++i)
            {
                win.SelectDistributeFlag(selflags[i], true);
            }
            win.SaveDistributeFlags();
        }
コード例 #4
0
 private static void OnPackagesChanged()
 {
     CapsDistributeEditor.CheckDefaultSelectedDistributeFlags();
     CapsModEditor.CheckModsAndMakeLink();
     UnityEngineEx.ResManager.RebuildRuntimeResCache();
 }