コード例 #1
0
        protected static T LoadInstance()
        {
            var targetAsset = UnityEditorUtility.FindAssetsByType <T>(string.Format("t:{0}", typeof(T).FullName)).FirstOrDefault();

            if (targetAsset == null)
            {
                Debug.LogErrorFormat("Not found a matching instance.\nclass : {0}", typeof(T).FullName);
            }

            return(targetAsset);
        }
コード例 #2
0
        private void DeleteMissingSourceAsset(BehaviorControlSetting setting, string[] filePaths)
        {
            var exportFolderPath = setting.GetExportFolderPath();

            var deleteList = new List <string>();

            var existPaths = filePaths.Select(x => ConvertDataPathToAssetPath(setting, x)).ToArray();

            var assets = UnityEditorUtility.FindAssetsByType <BehaviorControlAsset>("t:BehaviorControlAsset", new[] { exportFolderPath }).ToArray();

            foreach (var asset in assets)
            {
                var assetPath = AssetDatabase.GetAssetPath(asset);

                if (existPaths.Contains(assetPath))
                {
                    continue;
                }

                deleteList.Add(assetPath);
            }

            if (deleteList.Any())
            {
                var builder = new StringBuilder();

                builder.AppendLine("Delete missing source assets.");
                builder.AppendLine();

                using (new AssetEditingScope())
                {
                    foreach (var item in deleteList)
                    {
                        builder.AppendLine(item);

                        AssetDatabase.DeleteAsset(item);
                    }
                }

                Debug.LogWarning(builder.ToString());

                AssetDatabase.Refresh();
            }
        }
コード例 #3
0
        //----- params -----

        //----- field -----

        //----- property -----

        //----- method -----

        public static void Build()
        {
            var config = LocalizeSpriteConfig.Instance;

            var cryptoKey = config.GetCryptoKey();

            var targets = UnityEditorUtility.FindAssetsByType <LocalizeSpriteAsset>($"t:{ typeof(LocalizeSpriteAsset).FullName }");

            foreach (var target in targets)
            {
                SetFolderInfo(target, cryptoKey);

                SetSpriteFolderInfo(target);

                UnityEditorUtility.SaveAsset(target);
            }

            using (new DisableStackTraceScope())
            {
                Debug.Log("Update LocalizeAsset complete.");
            }
        }
コード例 #4
0
        //----- property -----

        //----- method -----

        public override void OnInspectorGUI()
        {
            instance = target as TextSpacing;

            EditorGUILayout.Separator();

            EditorGUI.BeginChangeCheck();

            var spacing = EditorGUILayout.FloatField("Tracking", instance.Tracking);

            if (EditorGUI.EndChangeCheck())
            {
                UnityEditorUtility.RegisterUndo("TextSpacingInspector Undo", instance);
                instance.Tracking = spacing;
            }

            if (currentFont != instance.Text.font)
            {
                currentFont = instance.Text.font;

                var assets = UnityEditorUtility.FindAssetsByType <FontKerningSetting>("t:FontKerningSetting");

                settings = assets.Where(x => x.Font == currentFont).ToArray();
            }

            using (new DisableScope(settings.IsEmpty()))
            {
                using (new EditorGUILayout.HorizontalScope())
                {
                    var labels = settings.Select(x => x.name).ToList();

                    labels.Insert(0, "None");

                    var index     = settings.IndexOf(x => x == instance.KerningSetting);
                    var selection = index != -1 ? index + 1 : 0;

                    EditorGUI.BeginChangeCheck();

                    selection = EditorGUILayout.Popup("Kerning", selection, labels.ToArray());

                    if (EditorGUI.EndChangeCheck())
                    {
                        var kerningSetting = 0 < selection?settings.ElementAtOrDefault(selection - 1) : null;

                        UnityEditorUtility.RegisterUndo("TextSpacingInspector Undo", instance);

                        instance.KerningSetting = kerningSetting;
                    }

                    using (new DisableScope(instance.KerningSetting == null))
                    {
                        if (GUILayout.Button("select", EditorStyles.miniButton, GUILayout.Width(45f)))
                        {
                            Selection.activeObject = instance.KerningSetting;
                        }
                    }
                }
            }

            if (settings.IsEmpty())
            {
                EditorGUILayout.HelpBox("Can not find kerning setting file for this font.", MessageType.Info);
            }
        }
コード例 #5
0
 protected static T LoadInstance()
 {
     return(UnityEditorUtility.FindAssetsByType <T>().FirstOrDefault());
 }