Beispiel #1
0
 public YojoySolutionExpander()
 {
     yojoyIcon = EditorIcon.CreateIcon(
         iconDirectory.Value,
         "yojoy_common_icon");
     yojoyRootConstString =
         "Assets/" + YojoyEditorSettings.YojoyRootDirectoyId;
 }
Beispiel #2
0
        public static EditorIcon CreateIcon(string iconDirectory,
                                            string whiteId, string blackId = null)
        {
            if (!Directory.Exists(iconDirectory))
            {
                throw new Exception($"" +
                                    $"The target directory {iconDirectory} is not exist!");
            }

            var finalBlackId = blackId ?? whiteId;
            var whitePath    = GetIconPath(iconDirectory, whiteId);
            var blackPath    = GetIconPath(iconDirectory, finalBlackId);

            TryShowIconNotExistError(whitePath);
            TryShowIconNotExistError(blackPath);

            var whiteIcon = AssetDatabaseUtility.LoadAssetAtPath <Texture2D>(
                whitePath);
            var blackIcon = AssetDatabaseUtility.LoadAssetAtPath <Texture2D>(
                blackPath);
            var editorIcon = new EditorIcon(whiteIcon, blackIcon);

            return(editorIcon);


            void TryShowIconNotExistError(string iconPath)
            {
                if (!File.Exists(iconPath))
                {
                    throw new Exception(
                              $"The target path {iconPath} is not exist!");
                }
            }

            string GetIconPath(string directory, string id)
            => directory + id + ".png";
        }