This commit is contained in:
2026-05-17 15:12:16 +07:00
parent 93da00c206
commit bf0ebe447d
902 changed files with 142169 additions and 31515 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 049369e8fc56b424096f0b61f0382cc6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 712e0d67c6de2c84eb01f7eb27910519
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
#if JSONNET_EXISTS
using Newtonsoft.Json;
#endif
namespace DA_Assets.FCU.Model
{
public struct AuthResult
{
#if JSONNET_EXISTS
[JsonProperty("access_token")]
#endif
public string AccessToken { get; set; }
#if JSONNET_EXISTS
[JsonProperty("expires_in")]
#endif
public string ExpiresIn { get; set; }
#if JSONNET_EXISTS
[JsonProperty("refresh_token")]
#endif
public string RefreshToken { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 354bdafd6ab9b134faecff943a0ff340
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e3731067170012443ab12dd8ea9fca47
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,29 @@
using System;
#if JSONNET_EXISTS
using Newtonsoft.Json;
#endif
namespace DA_Assets.FCU.Model
{
[Serializable]
public struct FigmaUser
{
#if JSONNET_EXISTS
[JsonProperty("id")]
#endif
public string Id { get; set; }
#if JSONNET_EXISTS
[JsonProperty("handle")]
#endif
public string Name { get; set; }
#if JSONNET_EXISTS
[JsonProperty("email")]
#endif
public string Email { get; set; }
#if JSONNET_EXISTS
[JsonProperty("img_url")]
#endif
public string ImgUrl { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4900b6b9596bc5d4092a7c186a9d682d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 35d4bf06fd4d60148a0a52f6345aa8ff
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System;
namespace DA_Assets.FCU.Attributes
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Field, AllowMultiple = false)]
public class FObjectAttribute : Attribute
{
/// <summary>
/// The object's name in Figma.
/// </summary>
public string Name { get; }
public FObjectAttribute(string name)
{
Name = name;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: af80620cfa3a6394b8b14198dc5f84d4

View File

@@ -0,0 +1,41 @@
using DA_Assets.DAI;
using System;
using UnityEngine;
namespace DA_Assets.FCU
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class FcuInspectorProperty : CustomInspectorProperty
{
public FcuInspectorProperty(
ComponentType type,
FcuLocKey label,
FcuLocKey tooltip,
float minValue = 0,
float maxValue = 1) : base(type, new GUIContent(GetLabelFromEnum(label), GetLabelFromEnum(tooltip)), minValue, maxValue)
{
}
private static string GetLabelFromEnum(FcuLocKey value)
{
return value.Localize();
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false)]
public class FcuPropertyHeader : PropertyHeader
{
public FcuPropertyHeader(
FcuLocKey label,
FcuLocKey tooltip) : base(new GUIContent(GetLabelFromEnum(label), GetLabelFromEnum(tooltip)))
{
}
private static string GetLabelFromEnum(FcuLocKey value)
{
return value.Localize();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5c43b919dc8a35843b4a83a298c874a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using System;
namespace DA_Assets.FCU.Attributes
{
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public sealed class PaintPriorityAttribute : Attribute
{
public int Priority { get; }
public PaintPriorityAttribute(int priority)
{
Priority = priority;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aa800b8053a516044b19668e55e95eff
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1e74f51a5e6e3c24da8a04e17eb043cf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,162 @@
using DA_Assets.Constants;
using DA_Assets.Extensions;
using DA_Assets.FCU.Model;
using DA_Assets.Singleton;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
#pragma warning disable CS0649
namespace DA_Assets.FCU
{
[CreateAssetMenu(menuName = DAConstants.Publisher + "/FCU Config")]
public class FcuConfig : AssetConfig<FcuConfig>
{
[SerializeField] List<TagConfig> tags;
public List<TagConfig> TagConfigs => tags;
[Header("File names")]
[SerializeField] string webLogFileName;
public string WebLogFileName => webLogFileName;
[Header("Formats")]
[SerializeField] string dateTimeFormat1;
public string DateTimeFormat1 => dateTimeFormat1;
[SerializeField] string dateTimeFormat2;
public string DateTimeFormat2 => dateTimeFormat2;
[SerializeField] string dateTimeFormat3;
public string DateTimeFormat3 => dateTimeFormat3;
[Header("GameObject names")]
[SerializeField] string canvasGameObjectName;
public string CanvasGameObjectName => canvasGameObjectName;
[SerializeField] string i2LocGameObjectName;
public string I2LocGameObjectName => i2LocGameObjectName;
[Header("Values")]
[SerializeField] int recentProjectsLimit = 20;
public int RecentProjectsLimit => recentProjectsLimit;
[SerializeField] int figmaSessionsLimit = 10;
public int FigmaSessionsLimit => figmaSessionsLimit;
[SerializeField] int logFilesLimit = 50;
public int LogFilesLimit => logFilesLimit;
[SerializeField] int maxRenderSize = 4096;
public int MaxRenderSize => maxRenderSize;
[SerializeField] int renderUpscaleFactor = 2;
public int RenderUpscaleFactor => renderUpscaleFactor;
[SerializeField] string blurredObjectTag = "UIBlur";
public string BlurredObjectTag => blurredObjectTag;
[SerializeField] string blurCameraTag = "BackgroundBlur";
public string BlurCameraTag => blurCameraTag;
[SerializeField] char realTagSeparator = '-';
public char RealTagSeparator => realTagSeparator;
[Header("Api")]
[SerializeField] int apiRequestsCountLimit = 2;
public int ApiRequestsCountLimit => apiRequestsCountLimit;
[SerializeField] int apiTimeoutSec = 5;
public int ApiTimeoutSec => apiTimeoutSec;
[SerializeField] int chunkSizeGetNodes;
public int ChunkSizeGetNodes => chunkSizeGetNodes;
[SerializeField] int frameListDepth = 2;
public int FrameListDepth => frameListDepth;
[SerializeField] string gFontsApiKey;
public string GoogleFontsApiKey { get => gFontsApiKey; set => gFontsApiKey = value; }
[Header("Other")]
[SerializeField] Sprite whiteSprite32px;
public Sprite WhiteSprite32px => whiteSprite32px;
[SerializeField] Sprite missingImageTexture128px;
public Sprite MissingImageTexture128px => missingImageTexture128px;
[SerializeField] TextAsset baseClass;
public TextAsset BaseClass => baseClass;
[SerializeField] Material imageLinearMaterial;
public Material ImageLinearMaterial => imageLinearMaterial;
[SerializeField] VectorMaterials vectorMaterials;
public VectorMaterials VectorMaterials => vectorMaterials;
/////////////////////////////////////////////////////////////////////////////////
//CONSTANTS//////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
public const string ProductName = "Figma Converter for Unity";
public const string ProductNameShort = "FCU";
public const string DestroyChilds = "Destroy childs";
public const string SetFcuToSyncHelpers = "Set current FCU to SyncHelpers";
public const string CompareTwoObjects = "Compare two selected objects";
public const string DestroyLastImported = "Destroy last imported frames";
public const string DestroySyncHelpers = "Destroy SyncHelpers";
public const string CreatePrefabs = "Create Prefabs";
public const string UpdatePrefabs = "Update Prefabs";
public const string Create = "Create";
public const string OptimizeSyncHelpers = "Optimize SyncHelpers";
public const string GenerateScripts = "Generate scripts";
public const float IMAGE_SCALE_MIN = 0.25f;
public const float IMAGE_SCALE_MAX = 4f;
public static char HierarchyDelimiter { get; } = '/';
public static string PARENT_ID { get; } = "603951929:602259738";
public static char AsterisksChar { get; } = '•';
public static string DefaultLocalizationCulture { get; } = "en-US";
public static string RATEME_PREFS_KEY { get; } = "DONT_SHOW_RATEME";
public static string RECENT_PROJECTS_PREFS_KEY { get; } = "recentProjectsPrefsKey";
public static string FIGMA_SESSIONS_PREFS_KEY { get; } = "FigmaSessions";
public static string ClientId => "LaB1ONuPoY7QCdfshDbQbT";
public static string ClientSecret => "E9PblceydtAyE7Onhg5FHLmnvingDp";
public static string RedirectUri => "http://localhost:1923/";
public static string AuthUrl => "https://www.figma.com/api/oauth/token?client_id={0}&client_secret={1}&redirect_uri={2}&code={3}&grant_type=authorization_code";
public static string OAuthUrl => "https://www.figma.com/oauth?client_id={0}&redirect_uri={1}&scope=file_read&state={2}&response_type=code";
private static string logPath;
public static string LogPath
{
get
{
if (logPath.IsEmpty())
logPath = Path.Combine(Directory.GetParent(Application.dataPath).FullName, "Logs");
logPath.CreateFolderIfNotExists();
return logPath;
}
}
private static string cachePath;
public static string CachePath
{
get
{
if (cachePath.IsEmpty())
{
string tempFolder = Path.GetTempPath();
cachePath = Path.Combine(tempFolder, "FcuCache");
}
cachePath.CreateFolderIfNotExists();
return cachePath;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 471efbc970a337c4c83b1330ba757435
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,43 @@
using DA_Assets.Tools;
using System.Linq;
namespace DA_Assets.FCU
{
public class FcuDebugSettings
{
private const string FCU_DEBUG_PREFS_KEY = "FCU_DEBUG_FLAGS";
private static FcuDebugSettingsFlags flags;
static FcuDebugSettings()
{
FcuDebugSettingsFlags[] debugFlags = new FcuDebugSettingsFlags[]
{
FcuDebugSettingsFlags.LogDefault,
FcuDebugSettingsFlags.LogSetTag,
FcuDebugSettingsFlags.LogIsDownloadable,
FcuDebugSettingsFlags.LogTransform,
FcuDebugSettingsFlags.LogGameObjectDrawer,
FcuDebugSettingsFlags.LogComponentDrawer,
FcuDebugSettingsFlags.LogHashGenerator
};
flags = (FcuDebugSettingsFlags)LocalPrefs.GetInt(FCU_DEBUG_PREFS_KEY, (int)debugFlags.Aggregate((acc, flag) => acc | flag));
}
public static FcuDebugSettingsFlags Settings
{
get
{
return flags;
}
set
{
if (flags != value)
{
flags = value;
LocalPrefs.SetInt(FCU_DEBUG_PREFS_KEY, (int)flags);
}
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 16c8888a480355f41ada786e50e2d3e9

View File

@@ -0,0 +1,38 @@
using System;
using UnityEngine;
#pragma warning disable CS0649
namespace DA_Assets.FCU.Model
{
[Serializable]
public struct TagConfig
{
[SerializeField] string label;
[SerializeField] FcuTag fcuTag;
[SerializeField] string figmaTag;
[SerializeField] bool customButtonTag;
[SerializeField] bool canBeDownloaded;
[SerializeField] bool canBeInsideSingleImage;
[SerializeField] bool hasComponent;
public FcuTag FcuTag => fcuTag;
public string FigmaTag => figmaTag;
public bool CustomButtonTag => customButtonTag;
public bool CanBeDownloaded => canBeDownloaded;
/// <summary>
/// If the parent component includes at least one component with 1 == fall, it cannot be a downloadable image.
/// </summary>
public bool CanBeInsideSingleImage => canBeInsideSingleImage;
/// <summary>
/// Needed to count instantiated scripts/components.
/// </summary>
public bool HasComponent => hasComponent;
public void SetDefaultData(FcuTag fcuTag)
{
this.label = fcuTag.ToString();
this.fcuTag = fcuTag;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aaaa5a9158c5bf043866042fa968b2e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 918d6ace255af2845bc2032d17356d04
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,154 @@
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using DA_Assets.Extensions;
#if JSONNET_EXISTS
using Newtonsoft.Json;
#endif
namespace DA_Assets.FCU
{
public class DAFormatter
{
static List<string> GetJsonPropertyNames<T>()
{
List<string> propertyNames = new List<string>();
FieldInfo[] fields = typeof(T).GetFields(BindingFlags.Public | BindingFlags.Instance);
PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (var field in fields)
{
#if JSONNET_EXISTS
JsonPropertyAttribute attribute = field.GetCustomAttribute<JsonPropertyAttribute>();
if (attribute != null)
{
propertyNames.Add(attribute.PropertyName ?? field.Name);
}
#endif
}
foreach (var property in properties)
{
#if JSONNET_EXISTS
JsonPropertyAttribute attribute = property.GetCustomAttribute<JsonPropertyAttribute>();
if (attribute != null)
{
propertyNames.Add(attribute.PropertyName ?? property.Name);
}
#endif
}
return propertyNames;
}
private const int indentLength = 4;
private static string Repeat(int n) => new string(' ', n * indentLength);
public static JFResult Format<T>(string str)
{
JFResult jsonFormatResult = new JFResult();
if (str.IsEmpty())
{
return new JFResult
{
Json = string.Empty,
IsValid = false,
MatchTargetType = false
};
}
List<string> typeNames = GetJsonPropertyNames<T>();
foreach (string typeName in typeNames)
{
if (str.Contains($"\"{typeName}\""))
{
jsonFormatResult.MatchTargetType = true;
break;
}
}
bool hasOpenBrace = false;
bool hasCloseBrace = false;
int indent = 0;
bool quoted = false;
StringBuilder sb = new StringBuilder();
for (var i = 0; i < str.Length; i++)
{
var ch = str[i];
switch (ch)
{
case '{':
case '[':
if (ch == '{')
hasOpenBrace = true;
sb.Append(ch);
if (quoted == false)
{
sb.AppendLine();
sb.Append(Repeat(++indent));
}
break;
case '}':
case ']':
if (ch == '}')
hasCloseBrace = true;
if (quoted == false)
{
sb.AppendLine();
sb.Append(Repeat(--indent));
}
sb.Append(ch);
break;
case '"':
sb.Append(ch);
bool escaped = false;
var index = i;
while (index > 0 && str[--index] == '\\')
escaped = !escaped;
if (escaped == false)
quoted = !quoted;
break;
case ',':
sb.Append(ch);
if (quoted == false)
{
sb.AppendLine();
sb.Append(Repeat(indent));
}
break;
case ':':
sb.Append(ch);
if (quoted == false)
sb.Append(" ");
break;
default:
sb.Append(ch);
break;
}
}
jsonFormatResult.Json = sb.ToString();
jsonFormatResult.IsValid = hasOpenBrace && hasCloseBrace;
return jsonFormatResult;
}
}
public struct JFResult
{
public bool IsValid { get; set; }
public string Json { get; set; }
public bool MatchTargetType { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 06a73c612ca81644c9da29771f70be48
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,98 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;
#if JSONNET_EXISTS
using Newtonsoft.Json;
#endif
namespace DA_Assets.FCU
{
public class DAJson
{
#if JSONNET_EXISTS
private static JsonSerializerSettings settings = new JsonSerializerSettings()
{
Error = (sender, error) => error.ErrorContext.Handled = true,
Formatting = Formatting.Indented
};
#endif
public static string ToJson(object obj)
{
#if JSONNET_EXISTS
return JsonConvert.SerializeObject(obj, settings);
#else
return "";
#endif
}
public static T FromJson<T>(string json)
{
#if JSONNET_EXISTS
return JsonConvert.DeserializeObject<T>(json, settings);
#else
return default(T);
#endif
}
public static async Task<DAResult<T>> FromJsonAsync<T>(string json)
{
DAResult<T> @return = new DAResult<T>();
try
{
#if JSONNET_EXISTS == false
throw new MissingComponentException("Json.NET packaghe is not installed.");
#endif
JFResult jfr = default;
await Task.Run(() =>
{
jfr = DAFormatter.Format<T>(json);
});
if (jfr.IsValid == false)
{
throw new Exception("Not valid json.");
}
if (jfr.MatchTargetType == false)
{
throw new InvalidCastException("The input json does not match the target type.");
}
await Task.Run(() =>
{
#if JSONNET_EXISTS
@return.Object = JsonConvert.DeserializeObject<T>(json, settings);
#endif
});
@return.Success = true;
}
catch (InvalidCastException ex)
{
@return.Success = false;
@return.Error = new WebError(29, ex.Message, ex);
}
catch (MissingComponentException ex)
{
@return.Success = false;
@return.Error = new WebError(455, ex.Message, ex);
}
catch (ThreadAbortException ex)
{
@return.Success = false;
@return.Error = new WebError(-1, ex.Message, ex);
}
catch (Exception ex)
{
@return.Success = false;
@return.Error = new WebError(422, ex.Message, ex);
}
return @return;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 13a6488720117b440923d3f85416ede7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
{
"name": "DA_Assets.FCU",
"rootNamespace": "DA_Assets.FCU",
"references": [
"GUID:1b74e700d4693d342a6732b0ca624858",
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:68550284b645f4b9894995579f34290a",
"GUID:552447fb6cdb3d34b969d73c1b33b7d8"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"Newtonsoft.Json.dll"
],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fd2d248e310f8234eb351b83126b632e
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a8fbd541e7e9a1e4e91ea5b1970b580a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,112 @@
using System;
namespace DA_Assets.FCU
{
[Flags]
public enum ProceduralCondition
{
Sprite = 1 << 0,
RectangleNoRoundedCorners = 1 << 1,
}
[Flags]
public enum SvgCondition
{
ImageOrVideo = 1 << 0,
AnyEffect = 1 << 1,
}
public enum PreserveRatioMode
{
None,
WidthControlsHeight,
HeightControlsWidth,
}
public enum FcuLogType
{
Default,
SetTag,
IsDownloadable,
Transform,
Error,
GameObjectDrawer,
ComponentDrawer,
HashGenerator
}
public enum FcuImageType
{
None,
Downloadable,
Drawable,
Generative,
Mask
}
public enum PositioningMode
{
Absolute = 0,
GameView = 1
}
public enum UIFramework
{
UGUI = 0,
UITK = 1,
NOVA = 2
}
public enum ImageFormat
{
PNG = 0,
JPG = 1,
SVG = 2
}
public enum ImageComponent
{
UnityImage = 0,
SubcShape = 1,
MPImage = 2,
ProceduralImage = 3,
RawImage = 4,
SpriteRenderer = 5,
RoundedImage = 6,
UIBlock2D = 7,
SvgImage = 8,
}
public enum TextComponent
{
UnityText = 0,
TextMeshPro = 1,
RTLTextMeshPro = 2
}
public enum ShadowComponent
{
Figma = 0,
TrueShadow = 1
}
public enum ButtonComponent
{
UnityButton = 0,
FcuButton = 2
}
public enum LocalizationComponent
{
None = 0,
DALocalizator = 1,
I2Localization = 2,
}
public enum LocalizationKeyCaseType
{
snake_case = 0,
UPPER_SNAKE_CASE = 1,
PascalCase = 2,
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c5d6a028bd143c041a134d05d930f0b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System;
namespace DA_Assets.FCU
{
[Flags]
public enum FcuDebugSettingsFlags
{
None = 0,
LogDefault = 1 << 0,
LogSetTag = 1 << 1,
LogIsDownloadable = 1 << 2,
LogTransform = 1 << 3,
LogGameObjectDrawer = 1 << 4,
LogComponentDrawer = 1 << 5,
LogHashGenerator = 1 << 6,
DebugMode = 1 << 7
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 381f5c4fc5ebe9c43917de692c0a7116

View File

@@ -0,0 +1,773 @@
namespace DA_Assets.FCU
{
public static class FcuLocExtensions
{
public static string Localize(this FcuLocKey key, params object[] args) =>
FcuConfig.Instance.Localizator.GetLocalizedText(key, args);
}
public enum FcuLocKey
{
// Logs
log_added_total,
log_api_waiting,
log_auth_complete,
log_cant_auth,
log_cant_draw_object,
log_cant_find_package,
log_cant_get_images,
log_cant_get_part_of_frames,
log_cant_get_image_links,
log_cant_execute_because_no_backup,
log_component_not_selected_in_hierarchy,
log_current_canvas_metas_destroy,
log_dev_function_enabled,
log_downloading_fonts,
log_downloading_images,
log_drawn_count,
log_enable_http_project_settings,
log_fcu_assigned,
log_generating_sprites,
log_generating_tmp_fonts,
log_getting_frames,
log_getting_links,
log_import_complete,
log_import_task_canceled,
log_incorrect_selection,
log_instantiate_game_objects,
log_links_added,
log_local_prefabs_found,
log_malformed_url,
log_mark_as_sprite,
log_need_auth,
log_no_google_fonts_api_key,
log_no_sync_helper,
log_nothing_to_import,
log_open_auth_page,
log_prefabs_created,
log_project_downloaded,
log_project_empty,
log_project_not_found,
log_search_local_prefabs,
log_set_anchors,
log_ssl_error,
log_start_adding_to_fonts_list,
log_start_creating_prefabs,
log_start_download_images,
log_start_setting_transform,
log_tagging,
log_unknown_aligment,
log_unknown_error,
log_not_authorized,
log_feature_not_available_with,
log_incorrent_project_url,
log_name_linking_not_recommended,
log_svg_scale_1,
log_import_failed_incompatible,
log_import_failed_enable_required,
log_import_failed_unsupported,
log_tagging_by_parts,
log_asset_not_imported,
//unknown
loading_google_fonts,
cant_download_fonts,
cant_generate_fonts,
cant_load_sprites,
cant_download_sprite,
// Labels and Tooltips
label_advanced_mode,
tooltip_advanced_mode,
label_add_tmp_fonts_from_folder,
tooltip_add_fonts_from_folder,
label_add_ttf_fonts_from_folder,
tooltip_add_ttf_fonts_from_folder,
label_all,
tooltip_all,
label_apply_and_continue,
tooltip_apply_and_continue,
label_asset,
tooltip_asset,
label_asset_creator_settings,
tooltip_asset_creator_settings,
label_asset_dependencies,
tooltip_asset_dependencies,
label_atlas_padding,
tooltip_atlas_padding,
label_atlas_population_mode,
tooltip_atlas_population_mode,
label_atlas_resolution,
tooltip_atlas_resolution,
label_auto_disable_compress_assets_on_import,
tooltip_auto_disable_compress_assets_on_import,
label_auto_size,
tooltip_auto_size,
label_best_fit,
tooltip_best_fit,
label_beta_version,
tooltip_beta_version,
label_buggy_version,
tooltip_buggy_version,
label_button_settings,
tooltip_button_settings,
label_button_type,
tooltip_button_type,
label_change,
tooltip_change,
label_changed_in_figma,
tooltip_changed_in_figma,
label_changed_in_unity,
tooltip_changed_in_unity,
label_comparer_desc,
tooltip_comparer_desc,
label_components_settings,
tooltip_import_components,
label_compression_quality,
tooltip_compression_quality,
label_copy_new_data,
tooltip_copy_new_data,
label_copy_old_data,
tooltip_copy_old_data,
label_copy_to_clipboard,
tooltip_copy_to_clipboard,
label_crunched_compression,
tooltip_crunched_compression,
label_csv_separator,
tooltip_csv_separator,
label_custom_pivot,
tooltip_custom_pivot,
label_dabutton_settings,
tooltip_dabutton_settings,
label_debug_mode,
tooltip_debug_mode,
label_debug_tools,
label_debug,
tooltip_debug_tools,
label_dependencies,
tooltip_dependencies,
label_disable_compress_assets_on_import,
tooltip_disable_compress_assets_on_import,
label_disabled_color,
tooltip_disabled_color,
label_dont_remove_fcu_meta,
tooltip_dont_remove_fcu_meta,
label_download_fonts_from_project,
tooltip_download_fonts_from_project,
label_download_multiple_fills,
tooltip_download_multiple_fills,
label_download_unsupported_gradients,
tooltip_download_unsupported_gradients,
label_fade_duration,
tooltip_fade_duration,
label_figma_auth,
tooltip_figma_auth,
label_figma_color,
tooltip_figma_color,
label_figma_comp,
tooltip_figma_comp,
label_figma_comp_desc,
tooltip_figma_comp_desc,
label_figma_layout_culture,
tooltip_figma_layout_culture,
label_find_added_objects,
tooltip_find_added_objects,
label_flip_x,
tooltip_flip_x,
label_flip_y,
tooltip_flip_y,
label_font_settings,
tooltip_font_settings,
label_font_subset,
tooltip_font_subset,
label_force_fix,
tooltip_force_fix,
label_frames_to_import,
tooltip_frames_to_import,
label_generate_physics_shape,
tooltip_generate_physics_shape,
label_gradient_resolution,
tooltip_gradient_resolution,
label_highlighted_color,
tooltip_highlighted_color,
label_horizontal_mapping,
tooltip_horizontal_mapping,
label_horizontal_overflow,
tooltip_horizontal_overflow,
label_https_setting,
tooltip_https_setting,
label_image_and_sprites,
tooltip_image_and_sprites,
label_image_component,
tooltip_image_component,
label_image_type,
tooltip_image_type,
label_import,
tooltip_import,
label_import_events,
tooltip_import_events,
log_import_stoped_because_error,
tooltip_import_stoped_because_error,
log_import_stoped_manually,
tooltip_stop_import,
label_kerning,
tooltip_kerning,
label_kilobytes,
tooltip_kilobytes,
label_layout_culture,
tooltip_layout_culture,
label_line_spacing,
tooltip_line_spacing,
label_loc_case_type,
tooltip_loc_case_type,
label_loc_component,
tooltip_loc_component,
label_loc_file_name,
tooltip_loc_file_name,
label_loc_file_path,
tooltip_loc_file_path,
label_localization_settings,
tooltip_localization_settings,
label_localizator,
tooltip_localizator,
label_log_default,
tooltip_log_default,
label_log_downloadable,
tooltip_log_downloadable,
label_log_go_drawer,
tooltip_log_go_drawer,
label_log_set_tag,
tooltip_log_set_tag,
label_log_transform,
tooltip_log_transform,
label_made_by,
tooltip_made_by,
label_main_settings,
tooltip_main_settings,
label_mask_interaction,
tooltip_mask_interaction,
label_maskable,
tooltip_maskable,
label_max_cord_deviation_enabled,
tooltip_max_cord_deviation_enabled,
label_max_tangent_angle_enabled,
tooltip_max_tangent_angle_enabled,
label_mipmap_enabled,
tooltip_mipmap_enabled,
label_missings_in_frame,
tooltip_missings_in_frame,
label_namespace,
tooltip_namespace,
label_new,
tooltip_new,
label_no_recent_projects,
tooltip_no_recent_projects,
label_normal_color,
tooltip_normal_color,
label_old_data,
tooltip_old_data,
label_override_line_spacing_px,
tooltip_override_line_spacing_px,
label_override_tags,
tooltip_override_tags,
label_parse_escape_characters,
tooltip_parse_escape_characters,
label_pixels_per_unit,
tooltip_pixels_per_unit,
label_positioning_mode,
tooltip_positioning_mode,
label_prefab_creator,
tooltip_prefab_creator,
label_prefabs_path,
tooltip_prefabs_path,
label_preserve_aspect,
tooltip_preserve_aspect,
label_preserve_numbers,
tooltip_preserve_numbers,
label_pressed_color,
tooltip_pressed_color,
label_project_url,
tooltip_project_url,
label_pui_falloff_distance,
tooltip_pui_falloff_distance,
label_rate,
tooltip_rate,
label_rateme,
tooltip_rateme,
label_rateme_desc,
tooltip_rateme_desc,
label_raycast_padding,
tooltip_raycast_padding,
label_raycast_target,
tooltip_raycast_target,
label_redownload_sprites,
tooltip_redownload_sprites,
label_remove,
tooltip_remove,
label_remove_unused_sprites,
tooltip_remove_unused_sprites,
label_render_mode,
tooltip_render_mode,
label_rich_text,
tooltip_rich_text,
label_rtl_textmeshpro_settings,
tooltip_rtl_textmeshpro_settings,
label_sampling_steps,
tooltip_sampling_steps,
label_selected_color,
tooltip_selected_color,
label_shadow_type,
tooltip_shadow_type,
label_shadows_tab,
tooltip_shadows_tab,
label_sort_point,
tooltip_sort_point,
label_sorting_layer,
tooltip_sorting_layer,
label_sprite_import_mode,
tooltip_sprite_import_mode,
label_step_distance,
tooltip_step_distance,
label_svg_image_settings,
tooltip_svg_image_settings,
label_svg_importer_settings,
tooltip_svg_importer_settings,
label_svg_type,
tooltip_svg_type,
label_text_and_fonts,
tooltip_text_and_fonts,
label_text_and_font_settings,
tooltip_text_and_font_settings,
label_text_component,
tooltip_text_component,
label_textmeshpro_settings,
tooltip_textmeshpro_settings,
label_texture_compression,
tooltip_texture_compression,
label_texture_importer_settings,
tooltip_texture_importer_settings,
label_texture_type,
tooltip_texture_type,
label_ttf_path,
tooltip_ttf_path,
label_ui_framework,
tooltip_ui_framework,
label_ui_toolkit,
tooltip_ui_toolkit,
label_unity_comp,
tooltip_unity_comp,
label_unity_image_settings,
tooltip_unity_image_settings,
label_unity_text_settings,
tooltip_unity_text_settings,
label_uitk_linking_mode,
tooltip_uitk_linking_mode,
label_uitk_output_path,
tooltip_uitk_output_path,
label_use_i2localization,
tooltip_use_i2localization,
label_visible_descender,
tooltip_visible_descender,
label_viewport_options,
tooltip_viewport_options,
label_vertical_mapping,
tooltip_vertical_mapping,
label_vertical_overflow,
tooltip_vertical_overflow,
label_without_changes,
tooltip_label_without_changes,
label_wrapping,
tooltip_wrapping,
label_xml_parsing,
tooltip_xml_parsing,
label_procedural_ui_settings,
tooltip_procedural_ui_settings,
label_pui_settings,
tooltip_pui_settings,
label_color_multiplier,
tooltip_color_multiplier,
label_mpuikit_settings,
tooltip_mpuikit_settings,
label_sr_settings,
tooltip_sr_settings,
label_is_readable,
tooltip_is_readable,
label_next_order_step,
tooltip_next_order_step,
label_raw_import,
tooltip_raw_import,
label_images_and_sprites_tab,
tooltip_images_and_sprites_tab,
label_buttons_tab,
tooltip_buttons_tab,
label_ui_toolkit_tab,
tooltip_ui_toolkit_tab,
label_nova_components,
tooltip_nova_components,
label_fcu,
tooltip_fcu,
label_settings,
tooltip_settings,
label_script_generator,
tooltip_script_generator,
label_enabled,
tooltip_enabled,
label_scripts_output_path,
tooltip_scripts_output_path,
label_select_folder,
tooltip_select_folder,
label_text_prefab_naming_mode,
tooltip_text_prefab_naming_mode,
label_humanized_color,
tooltip_humanized_color,
label_hex_color,
tooltip_hex_color,
label_log_component_drawer,
tooltip_log_component_drawer,
label_log_hash_generator_drawer,
tooltip_log_hash_generator_drawer,
label_override_tmp_letter_spacing,
tooltip_override_tmp_letter_spacing,
label_object_comparer,
tooltip_object_comparer,
label_fcu_is_null,
tooltip_fcu_is_null,
label_more_about_layout_updating,
tooltip_more_about_layout_updating,
tooltip_open_fcu_window,
tooltip_change_window_mode,
label_orthographic_mode,
tooltip_orthographic_mode,
label_extra_padding,
tooltip_extra_padding,
label_overflow,
tooltip_overflow,
label_geometry_sorting,
tooltip_geometry_sorting,
label_shader,
tooltip_shader,
label_farsi,
tooltip_farsi,
label_fix_tags,
tooltip_fix_tags,
label_user_name,
tooltip_user_id,
label_asset_instance_id,
tooltip_asset_instance_id,
label_stable_version,
tooltip_stable_version,
label_open_diff_checker,
tooltip_open_diff_checker,
label_go_name_max_length,
tooltip_go_name_max_length,
label_text_name_max_length,
tooltip_text_name_max_length,
label_go_layer,
tooltip_go_layer,
label_pivot_type,
tooltip_pivot_type,
label_components_to_import,
tooltip_components_to_import,
label_components_with_count,
tooltip_components_with_count,
tooltip_recent_projects,
tooltip_download_project,
label_sampling_point_size,
tooltip_sampling_point_size,
label_enable_multi_atlas_support,
tooltip_enable_multi_atlas_support,
label_images_format,
tooltip_images_format,
label_images_scale,
tooltip_images_scale,
label_preserve_ratio_mode,
tooltip_preserve_ratio_mode,
label_sprites_path,
tooltip_sprites_path,
label_shapes2d_settings,
tooltip_shapes2d_settings,
label_google_fonts_settings,
tooltip_google_fonts_settings,
label_google_fonts_api_key,
tooltip_google_fonts_api_key,
label_get_google_api_key,
tooltip_get_google_api_key,
label_remove_from_scene,
tooltip_remove_from_scene,
label_token,
tooltip_token,
tooltip_recent_tokens,
tooltip_auth,
label_tmp_path,
tooltip_tmp_path,
label_no_recent_sessions,
tooltip_no_recent_sessions,
label_different_component_data,
tooltip_different_component_data,
label_has_differences,
tooltip_has_differences,
label_new_components,
tooltip_new_components,
label_import_frames,
tooltip_import_frames,
label_open_settings_window,
tooltip_open_settings_window,
label_select_fonts_folder,
tooltip_select_fonts_folder,
label_select_prefabs_folder,
tooltip_select_prefabs_folder,
label_max_cord_deviation,
tooltip_max_cord_deviation,
label_max_tangent_angle,
tooltip_max_tangent_angle,
label_loc_folder_path,
tooltip_loc_folder_path,
label_use_image_linear_material,
tooltip_use_image_linear_material,
label_loc_key_max_lenght,
tooltip_loc_key_max_lenght,
label_supported_from_unity_version,
label_field_name_max_length,
tooltip_field_name_max_length,
label_method_name_max_length,
tooltip_method_name_max_length,
label_class_name_max_length,
tooltip_class_name_max_length,
label_base_class,
tooltip_base_class,
label_serialization_mode,
tooltip_serialization_mode,
label_max_sprite_size,
tooltip_max_sprite_size
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 022e0160593f1914191fa26a448a0497
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
namespace DA_Assets.FCU
{
public enum FcuNameType
{
Object,
Field,
Method,
File,
UitkGuid,
Class,
UssClass,
LocKey,
HumanizedTextPrefabName,
UxmlPath,
Figma,
UITK_SpritePath,
UITK_FontPath
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 621831154d92cfa40b5c887f71041168

View File

@@ -0,0 +1,43 @@
namespace DA_Assets.FCU
{
public enum FcuTag
{
None = 0,
Container = 1,
Frame = 2,
Page = 3,
AutoLayoutGroup = 100,
ContentSizeFitter = 101,
AspectRatioFitter = 102,
Text = 200,
Image = 201,
//Vector = 202,
Background = 203,
Slice9 = 204,
Button = 300,
InputField = 301,
Placeholder = 302,
ScrollView = 303,
PasswordField = 304,
Toggle = 305,
ToggleGroup = 306,
BtnDefault = 400,
BtnHover = 401,
BtnPressed = 402,
BtnSelected = 403,
BtnDisabled = 404,
BtnLooped = 405,
Shadow = 500,
CanvasGroup = 501,
Mask = 502,
Blur = 503,
Ignore = 600,
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3eb5a805e99e8874881fa13b3693657e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
using System;
using UnityEngine;
namespace DA_Assets.FCU
{
[Flags]
public enum FontSubset
{
Latin = 1 << 0,
LatinExt = 1 << 1,
Sinhala = 1 << 2,
Greek = 1 << 3,
Hebrew = 1 << 4,
Vietnamese = 1 << 5,
Cyrillic = 1 << 6,
CyrillicExt = 1 << 7,
Devanagari = 1 << 8,
Arabic = 1 << 9,
Khmer = 1 << 10,
Tamil = 1 << 11,
GreekExt = 1 << 12,
Thai = 1 << 13,
Bengali = 1 << 14,
Gujarati = 1 << 15,
Oriya = 1 << 16,
Malayalam = 1 << 17,
Gurmukhi = 1 << 18,
Kannada = 1 << 19,
Telugu = 1 << 20,
Myanmar = 1 << 21,
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f293b2949ef9cf5449263ef27584988e

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 11d8605c61a74514ebdcd65975193eee
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,259 @@
using DA_Assets.Extensions;
using DA_Assets.FCU.Model;
using DA_Assets.Logging;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
namespace DA_Assets.FCU.Extensions
{
public static class AutoLayoutExtensions
{
public static bool TryFixSizeWithStroke(this FObject fobject, float currentY, out float newY)
{
newY = 0;
if (currentY > 0)
return false;
if (fobject.Strokes.IsEmpty())
return false;
if (!fobject.Strokes.Any(x => x.Visible.ToBoolNullTrue()))
return false;
newY = fobject.StrokeWeight;
return true;
}
public static bool IsInsideAutoLayout(this FObject parent, out HorizontalOrVerticalLayoutGroup layoutGroup)
{
layoutGroup = null;
if (!parent.ContainsTag(FcuTag.AutoLayoutGroup))
return false;
if (parent.Data?.GameObject == null)
return false;
if (!parent.Data.GameObject.TryGetComponentSafe(out layoutGroup))
return false;
return true;
}
public static RectOffset GetPadding(this FObject fobject)
{
try
{
return new RectOffset
{
bottom = (int)Mathf.Round(fobject.PaddingBottom.ToFloat()),
top = (int)Mathf.Round(fobject.PaddingTop.ToFloat()),
left = (int)Mathf.Round(fobject.PaddingLeft.ToFloat()),
right = (int)Mathf.Round(fobject.PaddingRight.ToFloat())
};
}
catch (System.Exception ex)
{
DALogger.LogError(ex.Message);
return new RectOffset(0, 0, 0, 0);
}
}
public static TextAnchor GetHorLayoutAnchor(this FObject fobject)
{
string aligment = "";
aligment += fobject.PrimaryAxisAlignItems;
aligment += " ";
aligment += fobject.CounterAxisAlignItems;
switch (aligment)
{
case "NONE NONE":
return TextAnchor.UpperLeft;
case "SPACE_BETWEEN NONE":
return TextAnchor.UpperCenter;
case "CENTER NONE":
return TextAnchor.UpperCenter;
case "MAX NONE":
return TextAnchor.UpperRight;
case "NONE CENTER":
return TextAnchor.MiddleLeft;
case "NONE BASELINE":
return TextAnchor.MiddleLeft;
case "SPACE_BETWEEN CENTER":
return TextAnchor.MiddleCenter;
case "CENTER CENTER":
return TextAnchor.MiddleCenter;
case "CENTER BASELINE":
return TextAnchor.MiddleCenter;
case "MAX CENTER":
return TextAnchor.MiddleRight;
case "MAX BASELINE":
return TextAnchor.MiddleRight;
case "NONE MAX":
return TextAnchor.LowerLeft;
case "SPACE_BETWEEN MAX":
return TextAnchor.LowerCenter;
case "CENTER MAX":
return TextAnchor.LowerCenter;
case "MAX MAX":
return TextAnchor.LowerRight;
}
DALogger.LogError(FcuLocKey.log_unknown_aligment.Localize(aligment, fobject.Data.NameHierarchy));
return TextAnchor.UpperLeft;
}
public static TextAnchor GetVertLayoutAnchor(this FObject fobject)
{
string aligment = "";
aligment += fobject.PrimaryAxisAlignItems;
aligment += " ";
aligment += fobject.CounterAxisAlignItems;
switch (aligment)
{
case "NONE NONE":
return TextAnchor.UpperLeft;
case "NONE CENTER":
return TextAnchor.UpperCenter;
case "NONE MAX":
return TextAnchor.UpperRight;
case "CENTER NONE":
return TextAnchor.MiddleLeft;
case "SPACE_BETWEEN NONE":
return TextAnchor.MiddleLeft;
case "CENTER CENTER":
return TextAnchor.MiddleCenter;
case "SPACE_BETWEEN CENTER":
return TextAnchor.MiddleCenter;
case "CENTER MAX":
return TextAnchor.MiddleRight;
case "SPACE_BETWEEN MAX":
return TextAnchor.MiddleRight;
case "MAX NONE":
return TextAnchor.LowerLeft;
case "MAX CENTER":
return TextAnchor.LowerCenter;
case "MAX MAX":
return TextAnchor.LowerRight;
}
DALogger.LogError(FcuLocKey.log_unknown_aligment.Localize(aligment, fobject.Data.NameHierarchy));
return TextAnchor.UpperLeft;
}
public static bool IsNeedStretchByX(this FObject fobject)
{
HashSet<float?> layoutGrows = new HashSet<float?>();
foreach (FObject child in fobject.Children)
{
layoutGrows.Add(child.LayoutGrow);
}
if (layoutGrows.Count == 1)
{
if (layoutGrows.First() == 1)
{
return true;
}
}
return false;
}
public static bool IsNeedStretchByY(this FObject fobject)
{
HashSet<string> layoutAligns = new HashSet<string>();
foreach (FObject child in fobject.Children)
{
layoutAligns.Add(child.LayoutAlign);
}
if (layoutAligns.Count == 1)
{
if (layoutAligns.First() == "STRETCH")
{
return true;
}
}
return false;
}
public static float GetHorSpacing(this FObject fobject)
{
if (fobject.PrimaryAxisAlignItems == PrimaryAxisAlignItem.SPACE_BETWEEN)
{
if (fobject.Data.ChildIndexes.IsEmpty())
{
return 0;
}
else if (fobject.Data.ChildIndexes.Count == 1)
{
return 0;
}
else
{
int childCount = fobject.Data.ChildIndexes.Count;
int spacingCount = childCount - 1;
float parentWidth = fobject.Data.Size.x;
float allChildsWidth = 0;
foreach (FObject child in fobject.Children)
{
allChildsWidth += child.Data.Size.x;
}
float spacingWidth = (parentWidth - allChildsWidth) / spacingCount;
return spacingWidth;
}
}
else
{
return fobject.ItemSpacing.ToFloat();
}
}
public static float GetVertSpacing(this FObject fobject)
{
if (fobject.PrimaryAxisAlignItems == PrimaryAxisAlignItem.SPACE_BETWEEN)
{
if (fobject.Data.ChildIndexes.IsEmpty())
{
return 0;
}
else if (fobject.Data.ChildIndexes.Count == 1)
{
return 0;
}
else
{
int childCount = fobject.Data.ChildIndexes.Count;
int spacingCount = childCount - 1;
float parentHeight = fobject.Data.Size.y;
float allChildsHeight = 0;
foreach (FObject child in fobject.Children)
{
allChildsHeight += child.Data.Size.y;
}
float spacingWidth = (parentHeight - allChildsHeight) / spacingCount;
return spacingWidth;
}
}
else
{
return fobject.ItemSpacing.ToFloat();
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d9f91ffd5c1010848837e071bff89977
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,206 @@
using DA_Assets.FCU.Model;
using DA_Assets.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using UnityEngine;
using System.IO;
namespace DA_Assets.FCU.Extensions
{
public static class FObjectExtensionsAssembly
{
public static bool IsSupportedRenderSize(this Vector2 sourceSize, float imageScale, out Vector2Int spriteSize, out Vector2Int renderSize)
{
spriteSize = (sourceSize * imageScale).ToVector2Int();
int maxRenderSize = FcuConfig.Instance.MaxRenderSize;
int renderUpscaleFactor = FcuConfig.Instance.RenderUpscaleFactor;
renderSize = spriteSize * renderUpscaleFactor;
if (renderSize.x <= maxRenderSize && renderSize.y <= maxRenderSize)
{
return true;
}
return false;
}
public static bool IsSvgExtension(this FObject fobject)
{
if (fobject.Data.SpritePath.IsEmpty())
{
return false;
}
string spriteExt = Path.GetExtension(fobject.Data.SpritePath);
if (spriteExt.StartsWith(".") && spriteExt.Length > 1)
spriteExt = spriteExt.Remove(0, 1);
bool isSvgSprite = spriteExt.ToLower() == ImageFormat.SVG.ToLower();
return isSvgSprite;
}
public static void ExecuteWithTemporaryParent(this FObject fobject, Transform tempChildsParent, Func<FObject, GameObject> targetSelector, Action action)
{
GameObject target = targetSelector(fobject);
List<Transform> children = new List<Transform>();
List<int> siblingIndices = new List<int>();
foreach (Transform child in target.transform)
{
children.Add(child);
siblingIndices.Add(child.GetSiblingIndex());
}
foreach (Transform child in children)
{
child.SetParent(tempChildsParent);
}
action.Invoke();
for (int i = 0; i < children.Count; i++)
{
children[i].SetParent(target.transform);
children[i].SetSiblingIndex(siblingIndices[i]);
}
}
public static bool IsSprite(this SyncData data)
{
return data.FcuImageType == FcuImageType.Downloadable || data.FcuImageType == FcuImageType.Generative;
}
public static bool IsSprite(this FObject fobject)
{
return fobject.Data.FcuImageType == FcuImageType.Downloadable || fobject.Data.FcuImageType == FcuImageType.Generative;
}
public static bool IsCircle(this FObject fobject)
{
if (fobject.Type != NodeType.ELLIPSE)
return false;
if (fobject.Size.x.Round(1) == fobject.Size.y.Round(1))
{
return true;
}
else
{
return false;
}
}
public static bool IsRectangle(this FObject fobject)
{
if (fobject.Type == NodeType.RECTANGLE)
return true;
if (fobject.Type != NodeType.FRAME)
return false;
if (fobject.Type == NodeType.LINE && fobject.IsSupportedLine())
return false;
if (!fobject.Children.IsEmpty())
return false;
return true;
}
public static void SetFlagToAllChilds(this FObject parent, Action<FObject> action)
{
if (parent.IsDefault() || parent.Children.IsEmpty())
return;
foreach (FObject child in parent.Children)
{
action(child);
SetFlagToAllChilds(child, action);
}
}
public static List<GradientAlphaKey> ToGradientAlphaKeys(this Paint gradient)
{
List<GradientAlphaKey> gradientColorKeys = new List<GradientAlphaKey>();
if (gradient.GradientStops.IsEmpty())
{
return gradientColorKeys;
}
foreach (GradientStop gradientStop in gradient.GradientStops)
{
gradientColorKeys.Add(new GradientAlphaKey
{
alpha = gradientStop.Color.a,
time = gradientStop.Position
});
}
return gradientColorKeys;
}
public static List<GradientColorKey> ToGradientColorKeys(this Paint gradient)
{
List<GradientColorKey> gradientColorKeys = new List<GradientColorKey>();
if (gradient.GradientStops.IsEmpty())
{
return gradientColorKeys;
}
foreach (GradientStop gradientStop in gradient.GradientStops)
{
gradientColorKeys.Add(new GradientColorKey
{
color = gradientStop.Color,
time = gradientStop.Position
});
}
return gradientColorKeys;
}
public static string GetText(this FObject fobject)
{
return fobject.Characters.Replace("\\r", " ").Replace("\\n", Environment.NewLine);
}
public static bool IsSupportedLine(this FObject fobject)
{
if (fobject.StrokeCap == StrokeCap.SQUARE)
return true;
if (fobject.StrokeCap == StrokeCap.ROUND && fobject.StrokeWeight >= 2f)
return true;
return false;
}
public static bool HasVisibleProperty<T>(this FObject fobject, Expression<Func<FObject, IEnumerable<T>>> propertySelector) where T : IVisible
{
var func = propertySelector.Compile();
IEnumerable<T> collection = func(fobject);
return !collection.IsEmpty() && collection.Any(item => item.Visible.ToBoolNullTrue());
}
public static bool TryGetLocalPosition(this FObject fobject, out Vector2 rtPos)
{
try
{
rtPos = new Vector2(fobject.RelativeTransform[0][2].ToFloat(), -fobject.RelativeTransform[1][2].ToFloat());
return true;
}
catch
{
rtPos = new Vector2(0, 0);
return false;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 79da7c3c8977f9b45b75150ab1498550
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
using DA_Assets.Extensions;
namespace DA_Assets.FCU.Extensions
{
public static class FontExtensions
{
public static string FormatFontName(this string value)
{
if (value.IsEmpty())
{
return "null";
}
return value
.Replace("SDF", "")
.ToLower()
.Replace(" ", "")
.Replace("-", "")
.Replace("_", "");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6b8e451f8adc5b0468a9a22bc1a3a434
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,335 @@
using DA_Assets.FCU.Attributes;
using DA_Assets.FCU.Model;
using DA_Assets.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;
#pragma warning disable CS0219
namespace DA_Assets.FCU.Extensions
{
public static class GraphicExtensions
{
private static int _roundDigits = 3;
public static bool GetBoundingSize(this FObject fobject, out Vector2 size)
{
size = default;
float? x = fobject.AbsoluteBoundingBox.Width;
float? y = fobject.AbsoluteBoundingBox.Height;
if (x == null || y == null)
{
return false;
}
float xR = (float)Math.Round(x.Value, _roundDigits);
float yR = (float)Math.Round(y.Value, _roundDigits);
size = new Vector2(xR, yR);
return true;
}
public static bool GetBoundingPosition(this FObject fobject, out Vector2 position)
{
position = default;
float? x = fobject.AbsoluteBoundingBox.X;
float? y = fobject.AbsoluteBoundingBox.Y;
if (x == null || y == null)
{
return false;
}
float xR = (float)Math.Round(x.Value, _roundDigits);
float yR = (float)Math.Round(y.Value, _roundDigits);
position = new Vector2(xR, yR);
return true;
}
public static bool GetRenderSize(this FObject fobject, out Vector2 size)
{
size = default;
float? x = fobject.AbsoluteRenderBounds.Width;
float? y = fobject.AbsoluteRenderBounds.Height;
if (x == null || y == null)
{
return false;
}
float xR = (float)Math.Round(x.Value, _roundDigits);
float yR = (float)Math.Round(y.Value, _roundDigits);
size = new Vector2(xR, yR);
return true;
}
public static bool GetRenderPosition(this FObject fobject, out Vector2 position)
{
position = default;
float? x = fobject.AbsoluteRenderBounds.X;
float? y = fobject.AbsoluteRenderBounds.Y;
if (x == null || y == null)
{
return false;
}
float xR = (float)Math.Round(x.Value, _roundDigits);
float yR = (float)Math.Round(y.Value, _roundDigits);
position = new Vector2(xR, yR);
return true;
}
public static bool IsZeroSize(this FObject fobject)
{
if (fobject.AbsoluteBoundingBox.Width <= 0 || fobject.AbsoluteBoundingBox.Height <= 0)
{
return true;
}
return false;
}
public static bool IsVisible(this FObject fobject) => fobject.Visible.ToBoolNullTrue();
public static bool IsVisible(this Paint paint) => paint.Visible.ToBoolNullTrue();
public static bool IsVisible(this Effect effect) => effect.Visible.ToBoolNullTrue();
public static bool IsSingleLinearGradient(this FObject fobject, out Paint paint)
{
paint = default;
bool result = false;
int reason = 0;
if (fobject.Fills.IsEmpty())
{
result = false;
reason = 1;
}
else
{
IEnumerable<Paint> enabledFills = fobject.Fills.Where(x => x.IsVisible());
IEnumerable<Paint> linearFills = fobject.Fills.Where(x => x.IsVisible() && x.Type == PaintType.GRADIENT_LINEAR);
if (!fobject.Strokes.IsEmpty())
{
result = false;
reason = 2;
}
else if (!fobject.Effects.IsEmpty())
{
result = false;
reason = 3;
}
else if (enabledFills.Count() > 1)
{
result = false;
reason = 4;
}
else if (linearFills.Count() == 1)
{
paint = linearFills.First();
result = true;
reason = 4;
}
}
return result;
}
public static bool ContainsImageEmojiVideo(this FObject fobject)
{
if (fobject.Fills.IsEmpty())
return false;
foreach (Paint paint in fobject.Fills)
{
if (!paint.IsVisible())
return false;
if (paint.ImageRef.IsEmpty() == false || paint.GifRef.IsEmpty() == false)
return true;
switch (paint.Type)
{
case PaintType.IMAGE:
case PaintType.EMOJI:
case PaintType.VIDEO:
return true;
}
}
return false;
}
public static bool IsSingleColor(this FObject fobject, out Color color)
{
Dictionary<Color, float?> values = new Dictionary<Color, float?>();
List<bool> flags = new List<bool>();
IsSingleColorRecursive(fobject, flags, values);
if (flags.Count > 0)
{
color = default;
return false;
}
if (values.Count == 1)
{
color = values.First().Key;
return true;
}
else
{
color = default;
return false;
}
}
private static void IsSingleColorRecursive(FObject fobject, List<bool> flags, Dictionary<Color, float?> values)
{
if (fobject.Fills.IsEmpty() == false)
{
foreach (Paint paint in fobject.Fills)
{
if (!paint.IsVisible())
continue;
if (paint.ImageRef.IsEmpty() == false || paint.GifRef.IsEmpty() == false)
{
flags.Add(true);
return;
}
if (paint.Type.ToString().Contains("SOLID") == false)
{
flags.Add(true);
return;
}
values.TryAddValue<Color, float?>(paint.Color, paint.Opacity);
}
}
if (fobject.Strokes.IsEmpty() == false)
{
foreach (Paint paint in fobject.Strokes)
{
if (!paint.IsVisible())
continue;
if (paint.ImageRef.IsEmpty() == false || paint.GifRef.IsEmpty() == false)
{
flags.Add(true);
return;
}
if (paint.Type.ToString().Contains("SOLID") == false)
{
flags.Add(true);
return;
}
values.TryAddValue<Color, float?>(paint.Color, paint.Opacity);
}
}
if (fobject.Effects.IsEmpty() == false)
{
foreach (Effect effect in fobject.Effects)
{
if (!effect.IsVisible())
continue;
if (effect.Type.ToString().Contains("SOLID") == false)
{
flags.Add(true);
return;
}
values.TryAddValue<Color, float?>(effect.Color, effect.Opacity);
}
}
if (fobject.Children.IsEmpty())
return;
foreach (FObject item in fobject.Children)
{
if (item.Type == NodeType.TEXT)
continue;
IsSingleColorRecursive(item, flags, values);
}
}
public static bool ContainsRoundedCorners(this FObject fobject)
{
return fobject.CornerRadius > 0 || (fobject.CornerRadiuses?.Any(radius => radius > 0)).ToBoolNullFalse();
}
public static bool IsArcDataFilled(this FObject fobject)
{
if (fobject.ArcData.Equals(default(ArcData)))
{
return false;
}
return fobject.ArcData.EndingAngle < 6.28f;
}
public static Paint GetFirstSolidPaint(this List<Paint> paints)
{
if (paints == null)
return default;
Paint fill = default;
foreach (Paint paint in paints)
{
if (!paint.IsVisible())
continue;
if (paint.Type == PaintType.SOLID)
{
fill = paint;
fill.Color = fill.Color.SetAlpha(paint.Opacity);
break;
}
}
return fill;
}
public static int GetPriority(this PaintType paintType)
{
Type type = paintType.GetType();
MemberInfo[] memberInfo = type.GetMember(paintType.ToString());
if (memberInfo.Length > 0)
{
PaintPriorityAttribute attribute = memberInfo[0].GetCustomAttribute<PaintPriorityAttribute>();
if (attribute != null)
{
return attribute.Priority;
}
}
return 0;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 779a5a334f500474499d3fe965b7d78a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,71 @@
#if NOVA_UI_EXISTS
using DA_Assets.Extensions;
using Nova;
using System.Threading.Tasks;
using UnityEngine;
namespace DA_Assets.FCU.Extensions
{
public static class NovaExtensions
{
public static async Task SetNovaAnchor(this UIBlock uiBlock, AnchorType anchorType)
{
Vector3 worldPosition = uiBlock.transform.position;
Alignment aligment = Alignment.TopLeft;
switch (anchorType)
{
case AnchorType.TopLeft:
aligment = Alignment.TopLeft;
break;
case AnchorType.TopCenter:
aligment = Alignment.TopCenter;
break;
case AnchorType.TopRight:
aligment = Alignment.TopRight;
break;
case AnchorType.MiddleLeft:
aligment = Alignment.CenterLeft;
break;
case AnchorType.MiddleCenter:
aligment = Alignment.CenterCenter;
break;
case AnchorType.MiddleRight:
aligment = Alignment.CenterRight;
break;
case AnchorType.BottomLeft:
aligment = Alignment.BottomLeft;
break;
case AnchorType.BottomCenter:
aligment = Alignment.BottomCenter;
break;
case AnchorType.BottomRight:
aligment = Alignment.BottomRight;
break;
case AnchorType.BottomStretch:
break;
case AnchorType.VertStretchLeft:
break;
case AnchorType.VertStretchRight:
break;
case AnchorType.VertStretchCenter:
break;
case AnchorType.HorStretchTop:
break;
case AnchorType.HorStretchMiddle:
break;
case AnchorType.HorStretchBottom:
break;
case AnchorType.StretchAll:
break;
default:
break;
}
uiBlock.Layout.Alignment = aligment;
await Task.Delay(100);
uiBlock.TrySetWorldPosition(worldPosition);
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 175408f06d5030c47ac335b3b1faebb9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,155 @@
using DA_Assets.Extensions;
using DA_Assets.Networking;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace DA_Assets.FCU
{
public static class OtherExtensions
{
public static bool TryParseSpriteName(this string spriteName, out float scale, out System.Numerics.BigInteger hash)
{
try
{
if (spriteName.IsEmpty())
{
throw new Exception($"Sprite name is empty.");
}
char delimiter = ' ';
string withoutEx = Path.GetFileNameWithoutExtension(spriteName);
List<string> nameParts = withoutEx.Split(delimiter).ToList();
if (nameParts.Count < 2)
{
throw new Exception($"nameParts.Count < 2: {spriteName}");
}
string _hash = nameParts[nameParts.Count() - 1];
string _scale = nameParts[nameParts.Count() - 2].Replace("x", "");
bool scaleParsed = _scale.TryParseWithDot(out scale);
bool hashParsed = System.Numerics.BigInteger.TryParse(_hash, out hash);
if (scaleParsed == false)
{
throw new Exception($"Cant parse scale from name: {spriteName}");
}
if (hashParsed == false)
{
throw new Exception($"Cant parse hash from name: {spriteName}");
}
return true;
}
catch
{
scale = 1;
hash = -1;
return false;
}
}
public static async Task WriteLog(this DARequest request, UnityHttpClient webRequest)
{
FileInfo[] fileInfos = new DirectoryInfo(FcuConfig.LogPath).GetFiles($"*.*");
if (fileInfos.Length >= FcuConfig.Instance.LogFilesLimit)
{
foreach (FileInfo file in fileInfos)
{
try
{
file.Delete();
}
catch
{
}
}
}
string logFileName = $"{DateTime.Now.ToString(FcuConfig.Instance.DateTimeFormat1)}_{FcuConfig.Instance.WebLogFileName}";
string logFilePath = Path.Combine(FcuConfig.LogPath, logFileName);
string result;
string text = webRequest.downloadHandler.text;
JFResult jfr = DAFormatter.Format<string>(text);
if (jfr.IsValid)
{
result = jfr.Json;
}
else
{
result = text;
}
result = $"{request.Query}\n{webRequest.error}\n{result}";
File.WriteAllText(logFilePath, result);
await Task.Yield();
}
public static bool IsProjectEmpty(this SelectableFObject sf)
{
if (sf == null)
return true;
if (sf.Id.IsEmpty())
return true;
return false;
}
public static bool IsScrollContent(this string objectName)
{
if (objectName.IsEmpty())
return false;
objectName = objectName.ToLower();
objectName = Regex.Replace(objectName, "[^a-z]", "");
return objectName == "content";
}
public static bool IsScrollViewport(this string objectName)
{
if (objectName.IsEmpty())
return false;
objectName = objectName.ToLower();
objectName = Regex.Replace(objectName, "[^a-z]", "");
return objectName == "viewport";
}
public static bool IsInputTextArea(this string objectName)
{
if (objectName.IsEmpty())
return false;
objectName = objectName.ToLower();
objectName = Regex.Replace(objectName, "[^a-z]", "");
return objectName == "textarea";
}
public static bool IsCheckmark(this string objectName)
{
if (objectName.IsEmpty())
return false;
objectName = objectName.ToLower();
objectName = Regex.Replace(objectName, "[^a-z]", "");
return objectName == "checkmark";
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a7f2f12bd810da64cb180f4a1e6dda46

View File

@@ -0,0 +1,185 @@
using DA_Assets.FCU.Model;
using DA_Assets.Extensions;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace DA_Assets.FCU.Extensions
{
public static class TagExtensions
{
public static bool HaveUndownloadableTags(this FObject fobject, out string reason)
{
bool result = false;
reason = null;
if (fobject.ContainsTag(FcuTag.Image) == false)
{
reason = "fobject.ContainsTag(FcuTag.Image) == false)";
result = true;
}
else
{
foreach (FcuTag fcuTag in fobject.Data.Tags)
{
TagConfig tc = fcuTag.GetTagConfig();
if (tc.CanBeDownloaded == false)
{
reason = $"{fobject.Data.Tags.ToLine()}";
result = true;
break;
}
}
}
return result;
}
public static void RemoveNotDownloadableTags(this FObject fobject)
{
List<FcuTag> newTags = new List<FcuTag>();
foreach (FcuTag tag in fobject.Data.Tags)
{
TagConfig tc = tag.GetTagConfig();
if (tc.CanBeDownloaded)
{
newTags.Add(tag);
}
}
fobject.Data.Tags = newTags;
}
public static void AddTag(this FObject fobject, FcuTag tag)
{
if (fobject.Data.Tags == null)
fobject.Data.Tags = new List<FcuTag>();
if (fobject.Data.Tags.Contains(tag) == false)
fobject.Data.Tags.Add(tag);
}
public static bool ContainsCustomButtonTags(this FObject fobject) =>
fobject.ContainsAnyTag(
FcuTag.BtnDefault,
FcuTag.BtnDisabled,
FcuTag.BtnHover,
FcuTag.BtnPressed,
FcuTag.BtnSelected);
public static bool IsRootSprite(this FObject child, FObject parent)
{
bool value = false;
if (parent.ContainsTag(FcuTag.Frame))
{
switch (child.Type)
{
case NodeType.VECTOR:
case NodeType.BOOLEAN_OPERATION:
case NodeType.STAR:
case NodeType.REGULAR_POLYGON:
{
value = true;
}
break;
}
}
return value;
}
public static bool ContainsAnyTag(this FObject fobject, params FcuTag[] tags)
{
if (fobject.Data == null)
{
Debug.LogWarning("fobject.Data == null");
return false;
}
if (fobject.Data.Tags.IsEmpty())
return false;
foreach (FcuTag tag in tags)
{
if (fobject.ContainsTag(tag))
{
return true;
}
}
return false;
}
public static bool ContainsAnyTag(this SyncHelper syncHelper, params FcuTag[] tags)
{
if (syncHelper?.Data == null)
{
Debug.LogWarning("syncHelper.Data == null");
return false;
}
if (syncHelper.Data.Tags.IsEmpty())
return false;
foreach (FcuTag tag in tags)
{
if (syncHelper.ContainsTag(tag))
{
return true;
}
}
return false;
}
public static bool ContainsTag(this SyncHelper syncHelper, FcuTag tag)
{
if (syncHelper?.Data == null)
{
//Debug.LogWarning("syncHelper.Data == null");
return false;
}
if (syncHelper.Data.Tags.IsEmpty())
return false;
return syncHelper.Data.Tags.Contains(tag);
}
public static bool ContainsTag(this FObject fobject, FcuTag tag)
{
if (fobject.Data == null)
{
//Debug.LogWarning("fobject.Data == null");
return false;
}
if (fobject.Data.Tags.IsEmpty())
return false;
return fobject.Data.Tags.Contains(tag);
}
public static TagConfig GetTagConfig(this FcuTag fcuTag)
{
TagConfig tagConfig = FcuConfig.Instance.TagConfigs.FirstOrDefault(x => x.FcuTag == fcuTag);
if (tagConfig.IsDefault())
{
Debug.LogError($"No tag config for '{fcuTag}' tag.");
return new TagConfig();
}
return tagConfig;
}
public static string ToLine(this IList<FcuTag> tags)
{
return string.Join(", ", tags);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3fcc0ad1f585482438d39c2901cd078a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,279 @@
using DA_Assets.FCU.Model;
using DA_Assets.Extensions;
using System.Linq;
using UnityEngine;
#if TextMeshPro
using TMPro;
#endif
namespace DA_Assets.FCU.Extensions
{
public static class TextExtensions
{
public static FontStyle GetFontWeight(this FObject fobject)
{
string fontStyleRaw = fobject.Style.FontPostScriptName;
if (fontStyleRaw.IsEmpty() == false)
{
if (fontStyleRaw.Contains(FontStyle.Bold.ToString()))
{
if (fobject.Style.Italic.ToBoolNullFalse())
{
return FontStyle.BoldAndItalic;
}
else
{
return FontStyle.Bold;
}
}
else if (fobject.Style.Italic.ToBoolNullFalse())
{
return FontStyle.Italic;
}
}
return FontStyle.Normal;
}
public static TextAnchor GetTextAnchor(this FObject fobject)
{
string textAligment = fobject.Style.TextAlignVertical + " " + fobject.Style.TextAlignHorizontal;
switch (textAligment)
{
case "BOTTOM CENTER":
return TextAnchor.LowerCenter;
case "BOTTOM LEFT":
return TextAnchor.LowerLeft;
case "BOTTOM RIGHT":
return TextAnchor.LowerRight;
case "CENTER CENTER":
return TextAnchor.MiddleCenter;
case "CENTER LEFT":
return TextAnchor.MiddleLeft;
case "CENTER RIGHT":
return TextAnchor.MiddleRight;
case "TOP CENTER":
return TextAnchor.UpperCenter;
case "TOP LEFT":
return TextAnchor.UpperLeft;
case "TOP RIGHT":
return TextAnchor.UpperRight;
default:
return TextAnchor.MiddleCenter;
}
}
#if TextMeshPro
public static TextAlignmentOptions ToTextMeshAnchor(this TextAnchor textAnchor)
{
switch (textAnchor)
{
case TextAnchor.LowerCenter:
return TextAlignmentOptions.Bottom;
case TextAnchor.LowerLeft:
return TextAlignmentOptions.BottomLeft;
case TextAnchor.LowerRight:
return TextAlignmentOptions.BottomRight;
case TextAnchor.MiddleCenter:
return TextAlignmentOptions.Center;
case TextAnchor.MiddleLeft:
return TextAlignmentOptions.Left;
case TextAnchor.MiddleRight:
return TextAlignmentOptions.Right;
case TextAnchor.UpperCenter:
return TextAlignmentOptions.Top;
case TextAnchor.UpperLeft:
return TextAlignmentOptions.TopLeft;
case TextAnchor.UpperRight:
return TextAlignmentOptions.TopRight;
default:
return TextAlignmentOptions.Center;
}
}
#endif
public static string ToUITKAnchor(this TextAnchor textAnchor)
{
switch (textAnchor)
{
case TextAnchor.LowerCenter:
return "lower-center";
case TextAnchor.LowerLeft:
return "lower-left";
case TextAnchor.LowerRight:
return "lower-right";
case TextAnchor.MiddleCenter:
return "middle-center";
case TextAnchor.MiddleLeft:
return "middle-left";
case TextAnchor.MiddleRight:
return "middle-right";
case TextAnchor.UpperCenter:
return "upper-center";
case TextAnchor.UpperLeft:
return "upper-left";
case TextAnchor.UpperRight:
return "upper-right";
default:
return "middle-center";
}
}
public static string GetText(this GameObject go)
{
#if TextMeshPro
if (go.TryGetComponent(out TMP_Text tmpText))
{
return tmpText.text;
}
#endif
if (go.TryGetComponent(out UnityEngine.UI.Text unityText))
{
return unityText.text;
}
return null;
}
public static void SetText(this GameObject go, string text)
{
bool set = SetNovaText();
set = SetTMPText();
if (!set)
{
SetUnityText();
}
bool SetNovaText()
{
#if NOVA_UI_EXISTS
if (go.TryGetComponentSafe(out Nova.TextBlock textBlock))
{
textBlock.Text = text;
return true;
}
#endif
return false;
}
bool SetTMPText()
{
#if TextMeshPro
if (go.TryGetComponentSafe(out TMP_Text tmpText))
{
tmpText.text = text;
return true;
}
#endif
return false;
}
void SetUnityText()
{
if (go.TryGetComponent(out UnityEngine.UI.Text unityText))
{
unityText.text = text;
}
}
}
/// <summary>
/// https://drafts.csswg.org/css-fonts/#font-weight-numeric-values
/// </summary>
public static string FontWeightToString(this int weight)
{
switch (weight)
{
case 100: return "Thin";
case 200: return "ExtraLight";
case 300: return "Light";
case 400: return "Regular";//Normal
case 500: return "Medium";
case 600: return "SemiBold";
case 700: return "Bold";
case 800: return "ExtraBold";
case 900: return "Black";
}
return weight.ToString();
}
public static string FontNameToString(this FontMetadata fontMetadata,
bool includeWeight = true,
bool includeItalic = true,
FontSubset? fontSubset = null,
bool format = false)
{
string fullName = fontMetadata.Family;
if (includeWeight)
fullName += $"-{fontMetadata.Weight.FontWeightToString()}";
if (includeItalic)
if (fontMetadata.FontStyle == FontStyle.Italic)
fullName += $"-{FontStyle.Italic}";
if (fontSubset != null)
fullName += $"-{fontSubset}";
if (format)
{
fullName = fullName.FormatFontName();
}
return fullName;
}
public static FontMetadata GetFontMetadata(this FObject fobject)
{
string family = null;
int fontWeight = 0;
FontStyle italic = FontStyle.Normal;
if (!fobject.StyleOverrideTable.IsEmpty())
{
if (!fobject.StyleOverrideTable.First().Value.FontFamily.IsEmpty())
{
family = fobject.StyleOverrideTable.First().Value.FontFamily;
}
if (fobject.StyleOverrideTable.First().Value.FontWeight > 0)
{
fontWeight = fobject.StyleOverrideTable.First().Value.FontWeight;
}
italic = fobject.StyleOverrideTable.First().Value.Italic.ToBoolNullFalse() ? FontStyle.Italic : FontStyle.Normal;
}
if (family == null || fontWeight == 0)
{
family = fobject.Style.FontFamily;
fontWeight = fobject.Style.FontWeight;
italic = fobject.Style.Italic.ToBoolNullFalse() ? FontStyle.Italic : FontStyle.Normal;
}
FontMetadata fm = new FontMetadata
{
Family = family,
Weight = fontWeight,
FontStyle = italic,
};
return fm;
}
public static string FontNameToString(this FObject fobject,
bool includeWeight = true,
bool includeItalic = true,
FontSubset? fontSubset = null,
bool format = false)
{
FontMetadata fm = fobject.GetFontMetadata();
string fn = fm.FontNameToString(includeWeight, includeItalic, fontSubset, format);
return fn;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 16320b2d0b683f840b80ccde2cbb6b9a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,178 @@
using DA_Assets.FCU.Model;
using DA_Assets.Extensions;
using System.Collections.Generic;
using UnityEngine;
namespace DA_Assets.FCU.Extensions
{
public static class TransformExtensions
{
public static List<Transform> GetAllParents(this Transform child)
{
List<Transform> parents = new List<Transform>();
Transform currentParent = child.parent;
while (currentParent != null)
{
parents.Add(currentParent);
currentParent = currentParent.parent;
}
return parents;
}
public static float GetAngleFromMatrix(this FObject fobject)
{
float rotRad;
float rotDeg;
float a;
float b;
if (fobject.RelativeTransform.IsEmpty() ||
fobject.RelativeTransform.Count < 2 ||
fobject.RelativeTransform[1].Count < 2 ||
fobject.RelativeTransform[1][0] == null ||
fobject.RelativeTransform[1][1] == null)
{
//FcuLogger.Debug($"{nameof(GetAngleFromMatrix)} | {fobject.Data.NameHierarchy} | wrong relative transform.", FcuLogType.Error);
return 0;
}
else
{
a = (float)fobject.RelativeTransform[1][0];
b = (float)fobject.RelativeTransform[1][1];
rotRad = Mathf.Atan2(a, b).Round(5);
}
rotRad = -1 * rotRad;
rotDeg = rotRad * (180f / (float)Mathf.PI);
FcuLogger.Debug($"{nameof(GetAngleFromMatrix)} | {fobject.Data.NameHierarchy} | rotDeg: {rotDeg}\nb: {b}\na: {a}\nrotRad: {rotRad}");
return rotDeg;
}
public static float GetAngleFromField(this FObject fobject)
{
float rotRad;
float rotDeg;
float a = 0f;
float b = 0f;
rotRad = fobject.Rotation.HasValue ? fobject.Rotation.Value.Round(5) : 0;
rotRad = -1 * rotRad;
rotDeg = rotRad * (180f / (float)Mathf.PI);
FcuLogger.Debug($"{nameof(GetAngleFromField)} | {fobject.Data.NameHierarchy} | hasValue: {fobject.Rotation.HasValue} | rotDeg: {rotDeg}\nb: {b}\na: {a}\nrotRad: {rotRad}");
return rotDeg;
}
public static float GetFigmaRotationAngle(this FObject fobject)
{
float angle = fobject.GetAngleFromField();
if (angle == 0)
angle = fobject.GetAngleFromMatrix();
return angle;
}
public static AnchorType GetFigmaAnchor(this FObject fobject)
{
string anchor = fobject.Constraints.Vertical + " " + fobject.Constraints.Horizontal;
AnchorType anchorPreset;
switch (anchor)
{
////////////////LEFT////////////////
case "TOP LEFT":
anchorPreset = AnchorType.TopLeft;
break;
case "BOTTOM LEFT":
anchorPreset = AnchorType.BottomLeft;
break;
case "TOP_BOTTOM LEFT":
anchorPreset = AnchorType.VertStretchLeft;
break;
case "CENTER LEFT":
anchorPreset = AnchorType.MiddleLeft;
break;
case "SCALE LEFT":
anchorPreset = AnchorType.VertStretchLeft;
break;
////////////////RIGHT////////////////
case "TOP RIGHT":
anchorPreset = AnchorType.TopRight;
break;
case "BOTTOM RIGHT":
anchorPreset = AnchorType.BottomRight;
break;
case "TOP_BOTTOM RIGHT":
anchorPreset = AnchorType.VertStretchRight;
break;
case "CENTER RIGHT":
anchorPreset = AnchorType.MiddleRight;
break;
case "SCALE RIGHT":
anchorPreset = AnchorType.VertStretchRight;
break;
////////////////LEFT_RIGHT////////////////
case "TOP LEFT_RIGHT":
anchorPreset = AnchorType.HorStretchTop;
break;
case "BOTTOM LEFT_RIGHT":
anchorPreset = AnchorType.HorStretchBottom;
break;
case "TOP_BOTTOM LEFT_RIGHT":
anchorPreset = AnchorType.StretchAll;
break;
case "CENTER LEFT_RIGHT":
anchorPreset = AnchorType.HorStretchMiddle;
break;
case "SCALE LEFT_RIGHT":
anchorPreset = AnchorType.HorStretchMiddle;
break;
////////////////CENTER////////////////
case "TOP CENTER":
anchorPreset = AnchorType.TopCenter;
break;
case "BOTTOM CENTER":
anchorPreset = AnchorType.BottomCenter;
break;
case "TOP_BOTTOM CENTER":
anchorPreset = AnchorType.VertStretchCenter;
break;
case "CENTER CENTER":
anchorPreset = AnchorType.MiddleCenter;
break;
case "SCALE CENTER":
anchorPreset = AnchorType.StretchAll;
break;
////////////////SCALE////////////////
case "TOP SCALE":
anchorPreset = AnchorType.HorStretchTop;
break;
case "BOTTOM SCALE":
anchorPreset = AnchorType.HorStretchBottom;
break;
case "TOP_BOTTOM SCALE":
anchorPreset = AnchorType.VertStretchCenter;
break;
case "CENTER SCALE":
anchorPreset = AnchorType.StretchAll;
break;
case "SCALE SCALE":
anchorPreset = AnchorType.StretchAll;
break;
////////////////DEFAULT////////////////
default:
anchorPreset = AnchorType.MiddleCenter;
break;
}
return anchorPreset;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e7f15f65ac12aae42afd4fb794a003b7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,87 @@
using DA_Assets.FCU.Model;
using DA_Assets.Extensions;
using System.Linq;
namespace DA_Assets.FCU.Extensions
{
public static class TypeExtensions
{
public static bool IsAnyEffectInChildren(this FObject fobject)
{
if (fobject.Effects != null && fobject.Effects.Any(effect => effect.IsVisible()))
{
return true;
}
if (fobject.Children != null)
{
foreach (var child in fobject.Children)
{
if (child.IsAnyEffectInChildren())
{
return true;
}
}
}
return false;
}
public static bool IsAnyImageOrVideoOrEmojiTypeInChildren(this FObject fobject)
{
if (fobject.IsAnyImageOrVideoOrEmojiType())
{
return true;
}
if (fobject.Children != null)
{
foreach (var child in fobject.Children)
{
if (child.IsAnyImageOrVideoOrEmojiTypeInChildren())
{
return true;
}
}
}
return false;
}
public static bool IsShadowType(this Effect effect) => effect.Type.ToString().Contains("SHADOW");
public static bool IsBlurType(this Effect effect) => effect.Type.ToString().Contains("BLUR");
public static bool IsGradientType(this Paint paint) => paint.Type.ToString().Contains("GRADIENT");
public static bool IsAnyImageOrVideoOrEmojiType(this FObject fobject)
{
if (fobject.Fills.IsEmpty())
return false;
return fobject.Fills.Any(fill =>
fill.IsVisible() &&
(fill.Type == PaintType.IMAGE ||
fill.Type == PaintType.VIDEO ||
fill.Type == PaintType.EMOJI));
}
public static bool IsSingleImageOrVideoOrEmojiType(this FObject fobject)
{
bool hasImageOrVideo = fobject.IsAnyImageOrVideoOrEmojiType();
if (!hasImageOrVideo)
return false;
return fobject.Fills.Count(x => x.IsVisible()) == 1;
}
public static bool IsAnyMask(this FObject fobject) => fobject.IsObjectMask() || fobject.IsClipMask() || fobject.IsFrameMask();
public static bool IsFrameMask(this FObject fobject) => fobject.ContainsTag(FcuTag.Frame);
public static bool IsClipMask(this FObject fobject) => fobject.ClipsContent.ToBoolNullFalse();
public static bool IsObjectMask(this FObject fobject) => fobject.IsMask.ToBoolNullFalse();
public static bool IsGenerativeType(this FObject fobject) => fobject.Data.FcuImageType == FcuImageType.Generative;
public static bool IsDrawableType(this FObject fobject) => fobject.Data.FcuImageType == FcuImageType.Drawable;
public static bool IsDownloadableType(this FObject fobject) => fobject.Data.FcuImageType == FcuImageType.Downloadable;
public static bool IsMaskType(this FObject fobject) => fobject.Data.FcuImageType == FcuImageType.Mask;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 76e5200ceed976a49b1fefbc67b4e8af
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8ab3b80398078304a986e179784f82a4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
using DA_Assets.Extensions;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace DA_Assets.FCU
{
public class DACycles
{
public static async Task ForEach<T>(IList<T> source, Action<T> body, float iterationTimeout = 0, int beforeWaitItersCount = 0)
{
if (source.IsEmpty())
{
return;
}
for (int i = 0; i < source.Count; i++)
{
if (i != 0 &&
iterationTimeout != 0 &&
beforeWaitItersCount != 0 &&
i % beforeWaitItersCount == 0)
{
await Task.Delay((int)(iterationTimeout * 1000));
}
body.Invoke(source[i]);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 99a2b081d8369dd468eb0836b80676e5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,129 @@
using DA_Assets.Logging;
using System.Collections;
namespace DA_Assets.FCU
{
public class FcuLogger
{
public static void Debug(object log, FcuLogType logType = FcuLogType.Default)
{
switch (logType)
{
case FcuLogType.Default:
if (!FcuDebugSettings.Settings.HasFlag(FcuDebugSettingsFlags.LogDefault))
return;
break;
case FcuLogType.SetTag:
if (!FcuDebugSettings.Settings.HasFlag(FcuDebugSettingsFlags.LogSetTag))
return;
break;
case FcuLogType.IsDownloadable:
if (!FcuDebugSettings.Settings.HasFlag(FcuDebugSettingsFlags.LogIsDownloadable))
return;
break;
case FcuLogType.Transform:
if (!FcuDebugSettings.Settings.HasFlag(FcuDebugSettingsFlags.LogTransform))
return;
break;
case FcuLogType.GameObjectDrawer:
if (!FcuDebugSettings.Settings.HasFlag(FcuDebugSettingsFlags.LogGameObjectDrawer))
return;
break;
case FcuLogType.HashGenerator:
if (!FcuDebugSettings.Settings.HasFlag(FcuDebugSettingsFlags.LogHashGenerator))
return;
break;
case FcuLogType.ComponentDrawer:
if (!FcuDebugSettings.Settings.HasFlag(FcuDebugSettingsFlags.LogComponentDrawer))
return;
break;
case FcuLogType.Error:
UnityEngine.Debug.LogError(log);
return;
}
UnityEngine.Debug.Log(log);
}
public static bool WriteLogBeforeApiTimeout(ref int requestCount, ref int remainingTime, string log)
{
if (requestCount != 0 && requestCount % FcuConfig.Instance.ApiRequestsCountLimit == 0)
{
if (remainingTime > 0)
{
DALogger.Log(log);
remainingTime -= 10;
}
else if (remainingTime == 0)
{
DALogger.Log(log);
}
}
return remainingTime > 0;
}
public static bool WriteLogBeforeEqual(ICollection list1, ICollection list2, FcuLocKey locKey, int count1, int count2, ref int tempCount)
{
if (list1.Count != list2.Count)
{
if (tempCount != list1.Count)
{
tempCount = list1.Count;
DALogger.Log(locKey.Localize(count1, count2));
}
return true;
}
if (tempCount != list2.Count)
{
DALogger.Log(locKey.Localize(count1, count2));
}
return false;
}
public static bool WriteLogBeforeEqual(ref int count1, ref int count2, string log, ref int tempCount)
{
if (count1 != count2)
{
if (tempCount != count1)
{
tempCount = count1;
DALogger.Log(log);
}
return true;
}
if (tempCount != count2)
{
DALogger.Log(log);
}
return false;
}
public static bool WriteLogBeforeEqual(ICollection list1, ICollection list2, FcuLocKey locKey, ref int tempCount)
{
if (list1.Count != list2.Count)
{
if (tempCount != list1.Count)
{
tempCount = list1.Count;
DALogger.Log(locKey.Localize(list1.Count, list2.Count));
}
return true;
}
if (tempCount != list2.Count)
{
DALogger.Log(locKey.Localize(list1.Count, list2.Count));
}
return false;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 73023afdf56e0394294bbb96dba70b66
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,86 @@
using DA_Assets.Extensions;
using System.Collections.Generic;
using UnityEngine;
namespace DA_Assets.FCU
{
public class RequestCreator
{
public static DARequest CreateImageLinksRequest(string projectUrl, string format, float scale, IEnumerable<string> chunk, RequestHeader requestHeader)
{
string query = CreateImagesQuery(
chunk,
projectUrl,
format,
scale);
DARequest request = new DARequest
{
Query = query,
RequestType = RequestType.Get,
RequestHeader = requestHeader
};
return request;
}
public static string CreateImagesQuery(IEnumerable<string> chunk, string projectId, string extension, float scale)
{
string joinedIds = string.Join(",", chunk);
if (joinedIds.IsEmpty())
{
return null;
}
if (joinedIds[0] == ',')
joinedIds = joinedIds.Remove(0, 1);
string query = $"https://api.figma.com/v1/images/{projectId}?ids={joinedIds}&format={extension}&scale={scale.ToDotString()}";
return query;
}
public static DARequest CreateTokenRequest(string code)
{
string tokenQueryLink = string.Format(FcuConfig.AuthUrl, FcuConfig.ClientId, FcuConfig.ClientSecret, FcuConfig.RedirectUri, code);
DARequest request = new DARequest
{
Query = tokenQueryLink,
RequestType = RequestType.Post,
WWWForm = new WWWForm()
};
return request;
}
public static DARequest CreateProjectRequest(RequestHeader requestHeader, string projectId)
{
string query = string.Format("https://api.figma.com/v1/files/{0}?depth={1}&plugin_data=shared", projectId, FcuConfig.Instance.FrameListDepth);
DARequest request = new DARequest
{
Name = RequestName.Project,
Query = query,
RequestType = RequestType.Get,
RequestHeader = requestHeader
};
return request;
}
public static DARequest CreateNodeRequest(RequestHeader requestHeader, string projectId, string nodeIds)
{
string query = string.Format("https://api.figma.com/v1/files/{0}/nodes?ids={1}&geometry=paths&plugin_data=shared", projectId, nodeIds);
DARequest request = new DARequest
{
Query = query,
RequestType = RequestType.Get,
RequestHeader = requestHeader
};
return request;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3c2635a336ffd4047bd32cb3d5a6cb5c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
using DA_Assets.FCU.Model;
using System;
using UnityEngine;
namespace DA_Assets.FCU
{
//TODO: set current GameObject to SyncHelper
[Serializable]
public class SyncHelper : MonoBehaviour
{
void OnValidate()
{
if (data != null)
{
data.DisplayNameHierarchyInField();
}
}
[SerializeField] SyncData data;
public SyncData Data { get => data; set => data = value; }
public int HierarchyLevel
{
get
{
int level = 0;
Transform current = transform;
while (current.parent != null)
{
level++;
current = current.parent;
}
return level;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 18b42570416bdca4697b2749e5bf8c5c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
using UnityEngine;
namespace DA_Assets.FCU
{
public class LayerTools
{
public static int AddLayer(string layerName)
{
int layer = LayerMask.NameToLayer(layerName);
if (layer != -1)
return layer;
#if UNITY_EDITOR
UnityEditor.SerializedObject tagManager = new UnityEditor.SerializedObject(UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
UnityEditor.SerializedProperty layersProp = tagManager.FindProperty("layers");
for (int i = 8; i < layersProp.arraySize; i++)
{
UnityEditor.SerializedProperty sp = layersProp.GetArrayElementAtIndex(i);
if (sp != null && sp.stringValue == "")
{
sp.stringValue = layerName;
tagManager.ApplyModifiedProperties();
break;
}
}
#endif
layer = LayerMask.NameToLayer(layerName);
return layer;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 950610c39bee69745af27f5b5662b43d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 03f9ca319d7e4664b85568e36a79350a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,29 @@
using UnityEngine;
public struct DARequest
{
public RequestName Name { get; set; }
public string Query { get; set; }
public RequestType RequestType { get; set; }
public RequestHeader RequestHeader { get; set; }
public WWWForm WWWForm { get; set; }
}
public struct RequestHeader
{
public string Name { get; set; }
public string Value { get; set; }
}
public enum RequestType
{
Get,
Post,
GetFile,
}
public enum RequestName
{
None,
Project,
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 44581b577dc92f44d9a1d23e9852374e

View File

@@ -0,0 +1,27 @@
namespace DA_Assets.FCU
{
/// <summary>
///
/// </summary>
/// <typeparam name="T1">Object type.</typeparam>
public struct DAResult<T1>
{
private bool success;
public bool Success
{
get => success;
set
{
success = value;
}
}
public T1 Object { get; set; }
public WebError Error { get; set; }
}
/// <summary>
///
/// </summary>
/// <typeparam name="T1">Object type.</typeparam>
public delegate void Return<T1>(DAResult<T1> result);
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 539feb6c22d8e6b48af68de0c78a604c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,61 @@
#if JSONNET_EXISTS
using Newtonsoft.Json;
#endif
using System.Collections.Generic;
namespace DA_Assets.FCU
{
public struct FontItem
{
#if JSONNET_EXISTS
[JsonProperty("family")]
#endif
public string Family { get; set; }
#if JSONNET_EXISTS
[JsonProperty("variants")]
#endif
public List<string> Variants { get; set; }
#if JSONNET_EXISTS
[JsonProperty("subsets")]
#endif
public List<string> Subsets { get; set; }
#if JSONNET_EXISTS
[JsonProperty("version")]
#endif
public string Version { get; set; }
#if JSONNET_EXISTS
[JsonProperty("lastModified")]
#endif
public string LastModified { get; set; }
#if JSONNET_EXISTS
[JsonProperty("files")]
#endif
public Dictionary<string, string> Files { get; set; }
#if JSONNET_EXISTS
[JsonProperty("category")]
#endif
public string Category { get; set; }
#if JSONNET_EXISTS
[JsonProperty("kind")]
#endif
public string Kind { get; set; }
#if JSONNET_EXISTS
[JsonProperty("menu")]
#endif
public string Menu { get; set; }
}
public struct FontRoot
{
#if JSONNET_EXISTS
[JsonProperty("kind")]
#endif
public string Kind { get; set; }
#if JSONNET_EXISTS
[JsonProperty("items")]
#endif
public List<FontItem> Items { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fd16d919ff191a342af71a2d3707c452
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,222 @@
using DA_Assets.Extensions;
using DA_Assets.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using UnityEngine;
namespace DA_Assets.FCU.Model
{
[Serializable]
public class SyncData : IHaveId
{
[SerializeField] string id;
public string Id { get => id; set => id = value; }
[SerializeField] FNames names;
public FNames Names { get => names; set => names = value; }
[Space]
[SerializeField] List<FcuTag> tags = new List<FcuTag>();
public List<FcuTag> Tags { get => tags; set => tags = value; }
[SerializeField] FcuImageType fcuImageType;
public FcuImageType FcuImageType { get => fcuImageType; set => fcuImageType = value; }
[SerializeField] ButtonComponent buttonComponent;
public ButtonComponent ButtonComponent { get => buttonComponent; set => buttonComponent = value; }
[SerializeField] List<int> childIndexes = new List<int>();
public List<int> ChildIndexes { get => childIndexes; set => childIndexes = value; }
[Space]
[SerializeField] MonoBehaviour fcu;
public MonoBehaviour FigmaConverterUnity { get => fcu; set => fcu = value; }
[SerializeField] GameObject gameObject;
public GameObject GameObject { get => gameObject; set => gameObject = value; }
[Space]
[SerializeField] int hash;
public int Hash { get => hash; set => hash = value; }
[SerializeField, HideInInspector] List<FcuHierarchy> hierarchy = new List<FcuHierarchy>();
public List<FcuHierarchy> Hierarchy { get => hierarchy; set => hierarchy = value; }
#pragma warning disable IDE0052
[SerializeField] string nameHierarchy;
#pragma warning restore IDE0052
public void DisplayNameHierarchyInField() => nameHierarchy = this.NameHierarchy;
public string NameHierarchy
{
get
{
if (hierarchy.IsEmpty())
return null;
string h = string.Join(FcuConfig.HierarchyDelimiter.ToString(), hierarchy.Select(x => x.Name));
return h;
}
}
[SerializeField] GameObject rootFrameGO;
[SerializeField] SyncData rootFrameSD;
public SyncData RootFrame
{
get
{
if (rootFrameGO == null)
{
return rootFrameSD;
}
SyncHelper sh = rootFrameGO.GetComponent<SyncHelper>();
if (sh == null || sh.Data == null)
{
return rootFrameSD;
}
else
{
return sh.Data;
}
}
set
{
if (value?.GameObject != null)
{
rootFrameGO = value.GameObject;
}
if (rootFrameGO == null)
{
rootFrameSD = value;
return;
}
SyncHelper sh = rootFrameGO.GetComponent<SyncHelper>();
if (sh != null)
{
sh.Data = value;
}
else
{
rootFrameSD = value;
}
}
}
[Clear] public string UitkType { get; set; }
[Clear] public string HashData { get; set; }
[Clear] public XmlElement XmlElement { get; set; }
[Clear] public FObject Parent { get; set; }
[Clear] public string HashDataTree { get; set; }
[SerializeField, Clear] int parentIndex;
public int ParentIndex { get => parentIndex; set => parentIndex = value; }
[SerializeField, Clear] UguiTransformData uguiTransformData;
public UguiTransformData UguiTransformData { get => uguiTransformData; set => uguiTransformData = value; }
#if NOVA_UI_EXISTS
[SerializeField, Clear] NovaTransformData novaTransformData;
public NovaTransformData NovaTransformData { get => novaTransformData; set => novaTransformData = value; }
#endif
[SerializeField, Clear] FGraphic graphic;
public FGraphic Graphic { get => graphic; set => graphic = value; }
#if UNITY_2021_3_OR_NEWER
public UnityEngine.UIElements.UIDocument UIDocument { get; set; }
#endif
[SerializeField, Clear] GameObject rectGameObject;
public GameObject RectGameObject { get => rectGameObject; set => rectGameObject = value; }
[SerializeField, Clear] Vector2Int spriteSize;
public Vector2Int SpriteSize { get => spriteSize; set => spriteSize = value; }
[SerializeField, Clear] Vector2 size;
public Vector2 Size { get => size; set => size = value; }
[SerializeField, Clear] Vector2 position;
public Vector2 Position { get => position; set => position = value; }
[SerializeField, Clear] string spritePath;
public string SpritePath { get => spritePath; set => spritePath = value; }
[SerializeField, Clear] string link;
public string Link { get => link; set => link = value; }
[SerializeField, Clear] string tagReason;
public string TagReason { get => tagReason; set => tagReason = value; }
[SerializeField, Clear] string downloadableReason;
public string DownloadableReason { get => downloadableReason; set => downloadableReason = value; }
[SerializeField, Clear] string generativeReason;
public string GenerativeReason { get => generativeReason; set => generativeReason = value; }
[SerializeField, Clear] int downloadAttempsCount;
public int DownloadAttempsCount { get => downloadAttempsCount; set => downloadAttempsCount = value; }
[SerializeField, Clear] float angle;
public float Angle { get => angle; set => angle = value; }
[SerializeField, Clear] bool isDuplicate;
public bool IsDuplicate { get => isDuplicate; set => isDuplicate = value; }
[SerializeField, Clear] bool isMutual;
public bool IsMutual { get => isMutual; set => isMutual = value; }
[SerializeField, Clear] bool isEmpty;
public bool IsEmpty { get => isEmpty; set => isEmpty = value; }
[SerializeField, Clear] bool needDownload;
public bool NeedDownload { get => needDownload; set => needDownload = value; }
[SerializeField, Clear] bool needGenerate;
public bool NeedGenerate { get => needGenerate; set => needGenerate = value; }
[SerializeField, Clear] bool forceImage;
public bool ForceImage { get => forceImage; set => forceImage = value; }
[SerializeField, Clear] bool isOverlappedByStroke;
public bool IsOverlappedByStroke { get => isOverlappedByStroke; set => isOverlappedByStroke = value; }
[SerializeField, Clear] bool forceContainer;
public bool ForceContainer { get => forceContainer; set => forceContainer = value; }
[SerializeField, Clear] bool isInsideDownloadable;
public bool InsideDownloadable { get => isInsideDownloadable; set => isInsideDownloadable = value; }
[SerializeField, Clear] bool hasFontAsset;
public bool HasFontAsset { get => hasFontAsset; set => hasFontAsset = value; }
[SerializeField, Clear] ImageFormat imageFormat;
public ImageFormat ImageFormat { get => imageFormat; set => imageFormat = value; }
[SerializeField, Clear] float scale;
public float Scale { get => scale; set => scale = value; }
[SerializeField, Clear] Vector2 maxSpriteSize;
public Vector2 MaxSpriteSize { get => maxSpriteSize; set => maxSpriteSize = value; }
}
[Serializable]
public struct FcuHierarchy
{
public int Index;
public string Name;
public string Guid;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1eb7856c5f78e474fa74898bacaa1a8a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,28 @@
#if JSONNET_EXISTS
using Newtonsoft.Json;
#endif
using System;
namespace DA_Assets.FCU
{
public struct WebError
{
public WebError(int status = 0, string message = null, Exception ex = null)
{
this.Status = status;
this.Message = message;
this.Exception = ex;
}
public Exception Exception { get; set; }
#if JSONNET_EXISTS
[JsonProperty("status")]
#endif
public int Status { get; set; }
#if JSONNET_EXISTS
[JsonProperty("err")]
#endif
public string Message { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5154cd3b0fd100b47a4c48cc9088fa07
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 48fe5d66269821046bd245d3f2a911c0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
using DA_Assets.FCU.Model;
using DA_Assets.Tools;
using UnityEngine;
namespace DA_Assets.FCU
{
public class DiffInfo : IHaveId
{
public string Id { get; set; }
public string Name { get; set; }
public bool IsFrame { get; set; }
public SyncData RootFrame { get; set; }
public FObject NewData { get; set; }
public SyncData OldData { get; set; }
public bool IsNew { get; set; }
public bool HasFigmaDiff { get; set; }
public TProp<Color, Color> Color { get; set; }
public TProp<Vector2, Vector2> Size { get; set; }
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 7982bea7f939fb84bab9356f2f114fe5

View File

@@ -0,0 +1,76 @@
using DA_Assets.FCU.Model;
using DA_Assets.Extensions;
using System;
using UnityEngine;
namespace DA_Assets.FCU
{
[Serializable]
public class FGraphic
{
[SerializeField] bool hasFill;
public bool HasFill { get => hasFill; set => hasFill = value; }
[SerializeField] bool hasStroke;
public bool HasStroke { get => hasStroke; set => hasStroke = value; }
[SerializeField] FFill fill;
public FFill Fill { get => fill; set => fill = value; }
[SerializeField] FStroke stroke;
public FStroke Stroke { get => stroke; set => stroke = value; }
[SerializeField] Color spriteSingleColor;
public Color SpriteSingleColor { get => spriteSingleColor; set => spriteSingleColor = value; }
[SerializeField] Paint spriteSingleLinearGradient;
public Paint SpriteSingleLinearGradient { get => spriteSingleLinearGradient; set => spriteSingleLinearGradient = value; }
[SerializeField] bool fillAlpha1;
public bool FillAlpha1 { get => fillAlpha1; set => fillAlpha1 = value; }
}
[Serializable]
public struct FFill
{
[SerializeField] bool hasSolid;
public bool HasSolid { get => hasSolid; set => hasSolid = value; }
[SerializeField] bool hasGradient;
public bool HasGradient { get => hasGradient; set => hasGradient = value; }
[SerializeField] Paint gradientPaint;
public Paint GradientPaint { get => gradientPaint; set => gradientPaint = value; }
[SerializeField] Paint solidPaint;
public Paint SolidPaint { get => solidPaint; set => solidPaint = value; }
[SerializeField] Color singleColor;
public Color SingleColor { get => singleColor; set => singleColor = value; }
}
[Serializable]
public struct FStroke
{
[SerializeField] StrokeAlign align;
public StrokeAlign Align { get => align; set => align = value; }
[SerializeField] float weight;
public float Weight { get => weight; set => weight = value; }
[SerializeField] bool hasSolid;
public bool HasSolid { get => hasSolid; set => hasSolid = value; }
[SerializeField] bool hasGradient;
public bool HasGradient { get => hasGradient; set => hasGradient = value; }
[SerializeField] Paint solidPaint;
public Paint SolidPaint { get => solidPaint; set => solidPaint = value; }
[SerializeField] Paint gradientPaint;
public Paint GradientPaint { get => gradientPaint; set => gradientPaint = value; }
[SerializeField] Color singleColor;
public Color SingleColor { get => singleColor; set => singleColor = value; }
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 04e585e970251e04d95df4f02df39ce8

View File

@@ -0,0 +1,98 @@
using DA_Assets.Tools;
using System;
using UnityEngine;
namespace DA_Assets.FCU
{
[Serializable]
public class FNames
{
[SerializeField] SerializedDictionary<FcuNameType, string> names = new SerializedDictionary<FcuNameType, string>();
public SerializedDictionary<FcuNameType, string> Names => names;
public string this[FcuNameType key]
{
get => names.TryGetValue(key, out var value) ? value : string.Empty;
set => names[key] = value;
}
public string UITK_SpritePath
{
get => this[FcuNameType.UITK_SpritePath];
set => this[FcuNameType.UITK_SpritePath] = value;
}
public string UITK_FontPath
{
get => this[FcuNameType.UITK_FontPath];
set => this[FcuNameType.UITK_FontPath] = value;
}
public string FigmaName
{
get => this[FcuNameType.Figma];
set => this[FcuNameType.Figma] = value;
}
public string HumanizedTextPrefabName
{
get => this[FcuNameType.HumanizedTextPrefabName];
set => this[FcuNameType.HumanizedTextPrefabName] = value;
}
public string FileName
{
get => this[FcuNameType.File];
set => this[FcuNameType.File] = value;
}
public string ObjectName
{
get => this[FcuNameType.Object];
set => this[FcuNameType.Object] = value;
}
public string UitkGuid
{
get => this[FcuNameType.UitkGuid];
set => this[FcuNameType.UitkGuid] = value;
}
public string FieldName
{
get => this[FcuNameType.Field];
set => this[FcuNameType.Field] = value;
}
public string MethodName
{
get => this[FcuNameType.Method];
set => this[FcuNameType.Method] = value;
}
public string ClassName
{
get => this[FcuNameType.Class];
set => this[FcuNameType.Class] = value;
}
public string UssClassName
{
get => this[FcuNameType.UssClass];
set => this[FcuNameType.UssClass] = value;
}
public string UxmlPath
{
get => this[FcuNameType.UxmlPath];
set => this[FcuNameType.UxmlPath] = value;
}
public string LocKey
{
get => this[FcuNameType.LocKey];
set => this[FcuNameType.LocKey] = value;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f3e4a156465bae94c8ad7e974fdab70e

View File

@@ -0,0 +1,56 @@
using DA_Assets.FCU.Model;
using System.Collections.Generic;
namespace DA_Assets.FCU
{
public struct FObjectHashData
{
private int indent;
private FObject fobject;
private List<FieldHashData> hashes;
public List<EffectHashData> effectDatas;
public FObjectHashData(FObject fobject, List<FieldHashData> hashes, List<EffectHashData> effectDatas, int indent)
{
this.fobject = fobject;
this.hashes = hashes;
this.indent = indent;
this.effectDatas = effectDatas;
}
public int Indent => indent;
public FObject FObject => fobject;
public List<FieldHashData> FieldHashes => hashes;
public List<EffectHashData> EffectDatas => effectDatas;
}
public struct FieldHashData
{
private string name;
private object data;
public FieldHashData(string name, object data)
{
this.name = name;
this.data = data;
}
public string Name => name;
public object Data => data;
}
public struct EffectHashData
{
private string name;
private List<FieldHashData> data;
public EffectHashData(string name, List<FieldHashData> data)
{
this.name = name;
this.data = data;
}
public string Name => name;
public List<FieldHashData> Data => data;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 471e06a15cee05a4e880d1580b585e5e

View File

@@ -0,0 +1,17 @@
using System;
using UnityEngine;
namespace DA_Assets.FCU
{
[Serializable]
public struct FontMetadata
{
[SerializeField] string family;
[SerializeField] int weight;
[SerializeField] FontStyle fontStyle;
public string Family { get => family; set => family = value; }
public int Weight { get => weight; set => weight = value; }
public FontStyle FontStyle { get => fontStyle; set => fontStyle = value; }
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 074918296157e084b90b9137386435f1

View File

@@ -0,0 +1,20 @@
using System;
using UnityEngine;
namespace DA_Assets.FCU
{
[Serializable]
public struct FontStruct
{
[SerializeField] FontSubset fontSubset;
[SerializeField] FontItem fontItem;
[SerializeField] FontMetadata fontMetadata;
[SerializeField] byte[] bytes;
[SerializeField] UnityEngine.Object font;
public FontSubset FontSubset { get => fontSubset; set => fontSubset = value; }
public FontMetadata FontMetadata { get => fontMetadata; set => fontMetadata = value; }
public byte[] Bytes { get => bytes; set => bytes = value; }
public UnityEngine.Object Font { get => font; set => font = value; }
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: cca0b95920e7a754aa5f43c1f88e867d

View File

@@ -0,0 +1,11 @@
using DA_Assets.FCU.Model;
using System.Collections.Generic;
namespace DA_Assets.FCU
{
public struct FrameGroup
{
public FObject RootFrame { get; set; }
public List<FObject> Childs { get; set; }
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c589e027140671a49b63dba9d7e40fb5

Some files were not shown because too many files have changed in this diff Show More