Update
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64678fa5b8e8e874299d3c5ac35e17ec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f31a46c41260d614db82e28e732a85bd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using UnityEngine.UI;
|
||||
using static UnityEngine.UI.AspectRatioFitter;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class AspectRatioFitterDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
AspectRatioFitter arf;
|
||||
|
||||
switch (monoBeh.Settings.ImageSpritesSettings.PreserveRatioMode)
|
||||
{
|
||||
case PreserveRatioMode.WidthControlsHeight:
|
||||
fobject.Data.GameObject.TryAddComponent(out arf);
|
||||
arf.aspectMode = ConvertMode(monoBeh.Settings.ImageSpritesSettings.PreserveRatioMode);
|
||||
break;
|
||||
case PreserveRatioMode.HeightControlsWidth:
|
||||
fobject.Data.GameObject.TryAddComponent(out arf);
|
||||
arf.aspectMode = ConvertMode(monoBeh.Settings.ImageSpritesSettings.PreserveRatioMode);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private AspectMode ConvertMode(PreserveRatioMode mode)
|
||||
{
|
||||
AspectMode newMode = AspectMode.None;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case PreserveRatioMode.WidthControlsHeight:
|
||||
newMode = AspectMode.WidthControlsHeight;
|
||||
break;
|
||||
case PreserveRatioMode.HeightControlsWidth:
|
||||
newMode = AspectMode.HeightControlsWidth;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return newMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f8174de32811eb41bd63175d8801af7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,60 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class AutoLayoutDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
foreach (int index in fobject.Data.ChildIndexes)
|
||||
{
|
||||
if (monoBeh.CurrentProject.TryGetByIndex(index, out FObject child))
|
||||
{
|
||||
this.LayoutElementDrawer.Draw(child);
|
||||
}
|
||||
}
|
||||
|
||||
if (fobject.Data.GameObject.TryGetComponentSafe(out LayoutGroup oldLayoutGroup))
|
||||
{
|
||||
oldLayoutGroup.Destroy();
|
||||
}
|
||||
|
||||
if (fobject.LayoutWrap == LayoutWrap.WRAP)
|
||||
{
|
||||
this.GridLayoutDrawer.Draw(fobject);
|
||||
}
|
||||
else if (fobject.LayoutMode == LayoutMode.HORIZONTAL)
|
||||
{
|
||||
this.HorLayoutDrawer.Draw(fobject);
|
||||
}
|
||||
else if (fobject.LayoutMode == LayoutMode.VERTICAL)
|
||||
{
|
||||
this.VertLayoutDrawer.Draw(fobject);
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] GridLayoutDrawer gridLayoutDrawer;
|
||||
[SerializeProperty(nameof(gridLayoutDrawer))]
|
||||
public GridLayoutDrawer GridLayoutDrawer => monoBeh.Link(ref gridLayoutDrawer);
|
||||
|
||||
[SerializeField] VertLayoutDrawer vertLayoutDrawer;
|
||||
[SerializeProperty(nameof(vertLayoutDrawer))]
|
||||
public VertLayoutDrawer VertLayoutDrawer => monoBeh.Link(ref vertLayoutDrawer);
|
||||
|
||||
[SerializeField] HorLayoutDrawer horLayoutDrawer;
|
||||
[SerializeProperty(nameof(horLayoutDrawer))]
|
||||
public HorLayoutDrawer HorLayoutDrawer => monoBeh.Link(ref horLayoutDrawer);
|
||||
|
||||
[SerializeField] LayoutElementDrawer layoutElementDrawer;
|
||||
[SerializeProperty(nameof(layoutElementDrawer))]
|
||||
public LayoutElementDrawer LayoutElementDrawer => monoBeh.Link(ref layoutElementDrawer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e18876aabaa2c4c4a91a235467f5d185
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using System;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class ContentSizeFitterDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
if (fobject.Style.TextAutoResize == "WIDTH_AND_HEIGHT")
|
||||
{
|
||||
fobject.Data.GameObject.TryAddComponent(out ContentSizeFitter csf);
|
||||
|
||||
csf.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
csf.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1218aaa03749409429df5e68c615fdb7
|
||||
@@ -0,0 +1,60 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using UnityEngine.UI;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
|
||||
#if UNITY_UI_EXTENSIONS_EXISTS
|
||||
using UnityEngine.UI.Extensions;
|
||||
#endif
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class GridLayoutDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
if (fobject.Data.GameObject.TryGetComponentSafe(out LayoutGroup oldLayoutGroup))
|
||||
{
|
||||
oldLayoutGroup.Destroy();
|
||||
}
|
||||
|
||||
#if UNITY_UI_EXTENSIONS_EXISTS
|
||||
fobject.Data.GameObject.TryAddComponent(out FlowLayoutGroup layoutGroup);
|
||||
|
||||
layoutGroup.childAlignment = fobject.GetHorLayoutAnchor();
|
||||
layoutGroup.padding = fobject.GetPadding();
|
||||
|
||||
float spacingX;
|
||||
float spacingY;
|
||||
|
||||
if (fobject.PrimaryAxisAlignItems == PrimaryAxisAlignItem.SPACE_BETWEEN)
|
||||
{
|
||||
layoutGroup.ChildForceExpandWidth = true;
|
||||
spacingX = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
layoutGroup.ChildForceExpandWidth = false;
|
||||
spacingX = fobject.ItemSpacing.ToFloat();
|
||||
}
|
||||
|
||||
if (fobject.CounterAxisAlignContent == "SPACE_BETWEEN")
|
||||
{
|
||||
layoutGroup.ChildForceExpandHeight = true;
|
||||
spacingY = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
layoutGroup.ChildForceExpandHeight = false;
|
||||
spacingY = fobject.CounterAxisSpacing.ToFloat();
|
||||
}
|
||||
|
||||
layoutGroup.SpacingX = spacingX;
|
||||
layoutGroup.SpacingY = spacingY;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0ae7bea13f984a41b651033c26f47fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,57 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class HorLayoutDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
fobject.Data.GameObject.TryAddComponent(out HorizontalLayoutGroup layoutGroup);
|
||||
|
||||
layoutGroup.childAlignment = fobject.GetHorLayoutAnchor();
|
||||
layoutGroup.padding = fobject.GetPadding();
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
layoutGroup.reverseArrangement = false;
|
||||
#endif
|
||||
layoutGroup.childScaleWidth = false;
|
||||
layoutGroup.childScaleHeight = false;
|
||||
|
||||
layoutGroup.childControlWidth = fobject.IsNeedStretchByX();
|
||||
layoutGroup.childControlHeight = fobject.IsNeedStretchByY();
|
||||
|
||||
layoutGroup.spacing = fobject.GetHorSpacing();
|
||||
|
||||
if (layoutGroup.childControlWidth)
|
||||
{
|
||||
layoutGroup.childForceExpandWidth = true;
|
||||
}
|
||||
else if (fobject.PrimaryAxisAlignItems == PrimaryAxisAlignItem.SPACE_BETWEEN)
|
||||
{
|
||||
layoutGroup.childForceExpandWidth = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
layoutGroup.childForceExpandWidth = false;
|
||||
}
|
||||
|
||||
if (layoutGroup.childControlHeight)
|
||||
{
|
||||
layoutGroup.childForceExpandHeight = true;
|
||||
}
|
||||
else if (fobject.CounterAxisAlignItems == CounterAxisAlignItem.SPACE_BETWEEN)
|
||||
{
|
||||
layoutGroup.childForceExpandHeight = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
layoutGroup.childForceExpandHeight = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4be28e9a8f7689d4483e6afe6878cf9d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using System;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class LayoutElementDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
fobject.Data.GameObject.TryAddComponent(out LayoutElement layoutElement);
|
||||
|
||||
layoutElement.minWidth = fobject.Size.x;
|
||||
layoutElement.minHeight = fobject.Size.y;
|
||||
|
||||
layoutElement.preferredWidth = fobject.Size.x;
|
||||
layoutElement.preferredHeight = fobject.Size.y;
|
||||
|
||||
if (fobject.LayoutPositioning == LayoutPositioning.ABSOLUTE)
|
||||
{
|
||||
layoutElement.ignoreLayout = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
layoutElement.ignoreLayout = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01f2d41f57c794b44a6bad6482d42e05
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,57 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class VertLayoutDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
fobject.Data.GameObject.TryAddComponent(out VerticalLayoutGroup layoutGroup);
|
||||
|
||||
layoutGroup.childAlignment = fobject.GetVertLayoutAnchor();
|
||||
layoutGroup.padding = fobject.GetPadding();
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
layoutGroup.reverseArrangement = false;
|
||||
#endif
|
||||
layoutGroup.childScaleWidth = false;
|
||||
layoutGroup.childScaleHeight = false;
|
||||
|
||||
layoutGroup.childControlWidth = fobject.IsNeedStretchByX();
|
||||
layoutGroup.childControlHeight = fobject.IsNeedStretchByY();
|
||||
|
||||
layoutGroup.spacing = fobject.GetVertSpacing();
|
||||
|
||||
if (layoutGroup.childControlWidth)
|
||||
{
|
||||
layoutGroup.childForceExpandWidth = true;
|
||||
}
|
||||
else if (fobject.PrimaryAxisAlignItems == PrimaryAxisAlignItem.SPACE_BETWEEN)
|
||||
{
|
||||
layoutGroup.childForceExpandWidth = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
layoutGroup.childForceExpandWidth = false;
|
||||
}
|
||||
|
||||
if (layoutGroup.childControlHeight)
|
||||
{
|
||||
layoutGroup.childForceExpandHeight = true;
|
||||
}
|
||||
else if (fobject.CounterAxisAlignItems == CounterAxisAlignItem.SPACE_BETWEEN)
|
||||
{
|
||||
layoutGroup.childForceExpandHeight = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
layoutGroup.childForceExpandHeight = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6dba50223415c7e45a317bb7b846611c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efe0e4e4c485d7f48bfff01971b1dd5c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,90 @@
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class ButtonDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
[SerializeField] List<FObject> buttons = new List<FObject>();
|
||||
public List<FObject> Buttons => buttons;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
buttons.Clear();
|
||||
}
|
||||
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
fobject.Data.ButtonComponent = monoBeh.Settings.ButtonSettings.ButtonComponent;
|
||||
|
||||
switch (monoBeh.Settings.ButtonSettings.ButtonComponent)
|
||||
{
|
||||
/*case ButtonComponent.DAButton:
|
||||
{
|
||||
#if DABUTTON_EXISTS
|
||||
fobject.Data.GameObject.TryAddComponent(out DAButton _);
|
||||
#endif
|
||||
}
|
||||
break;*/
|
||||
case ButtonComponent.FcuButton:
|
||||
{
|
||||
fobject.Data.GameObject.TryAddComponent(out FcuButton _);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
fobject.Data.GameObject.TryAddComponent(out UnityEngine.UI.Button _);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
buttons.Add(fobject);
|
||||
}
|
||||
|
||||
public async Task SetTargetGraphics()
|
||||
{
|
||||
foreach (FObject fobject in buttons)
|
||||
{
|
||||
switch (fobject.Data.ButtonComponent)
|
||||
{
|
||||
case ButtonComponent.FcuButton:
|
||||
{
|
||||
this.FcuButtonDrawer.SetupFcuButton(fobject.Data);
|
||||
}
|
||||
break;
|
||||
/*case ButtonComponent.DAButton:
|
||||
{
|
||||
this.DAButtonDrawer.SetupDaButton(fobject.Data);
|
||||
}
|
||||
break;*/
|
||||
default:
|
||||
{
|
||||
this.UnityButtonDrawer.SetupUnityButton(fobject.Data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
await Task.Yield();
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] DAButtonDrawer dabDrawer;
|
||||
[SerializeProperty(nameof(dabDrawer))]
|
||||
public DAButtonDrawer DAButtonDrawer => monoBeh.Link(ref dabDrawer);
|
||||
|
||||
[SerializeField] FcuButtonDrawer fcubDrawer;
|
||||
[SerializeProperty(nameof(fcubDrawer))]
|
||||
public FcuButtonDrawer FcuButtonDrawer => monoBeh.Link(ref fcubDrawer);
|
||||
|
||||
[SerializeField] UnityButtonDrawer ubDrawer;
|
||||
[SerializeProperty(nameof(ubDrawer))]
|
||||
public UnityButtonDrawer UnityButtonDrawer => monoBeh.Link(ref ubDrawer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f6add19d9f04b14bab625a62c68053a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,170 @@
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
|
||||
#if DABUTTON_EXISTS
|
||||
using DA_Assets.DAB;
|
||||
#endif
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class DAButtonDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void SetupDaButton(SyncData btnSyncData)
|
||||
{
|
||||
#if DABUTTON_EXISTS
|
||||
DAButton daButton = btnSyncData.GameObject.GetComponent<DAButton>();
|
||||
// daButton.BlendMode = monoBeh.Settings.DabSettings.BlendMode;
|
||||
// daButton.BlendIntensity = monoBeh.Settings.DabSettings.BlendIntensity;
|
||||
|
||||
SyncHelper[] syncHelpers = btnSyncData.GameObject.GetComponentsInChildren<SyncHelper>(true).Skip(1).ToArray();
|
||||
Dictionary<int, List<SyncHelper>> graphics = new Dictionary<int, List<SyncHelper>>();
|
||||
|
||||
foreach (SyncHelper syncHelper in syncHelpers)
|
||||
{
|
||||
bool exists = syncHelper.TryGetComponentSafe(out Graphic gr);
|
||||
|
||||
if (!exists)
|
||||
continue;
|
||||
|
||||
bool success = TryGetNumberBeforeDash(syncHelper.Data.Names.ObjectName, out int number);
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (!graphics.ContainsKey(number))
|
||||
{
|
||||
graphics[number] = new List<SyncHelper>();
|
||||
}
|
||||
|
||||
graphics[number].Add(syncHelper);
|
||||
}
|
||||
}
|
||||
|
||||
daButton.TargetGraphics.Clear();
|
||||
|
||||
foreach (var item in graphics)
|
||||
{
|
||||
// DATargetGraphic tg = DAButtonDefaults.Instance.CopyTargetGraphic(monoBeh.Settings.DabSettings.DefaultTargetGraphic);
|
||||
|
||||
foreach (SyncHelper sh in item.Value)
|
||||
{
|
||||
sh.TryGetComponentSafe(out Graphic gr);
|
||||
|
||||
bool sprite = sh.gameObject.TryGetComponentSafe(out Image img) && img.sprite != null;
|
||||
|
||||
if (sh.Data.Tags.Contains(FcuTag.BtnDefault))
|
||||
{
|
||||
// tg.TargetGraphic = gr;
|
||||
// AnimationItem n = tg.NormalState;
|
||||
|
||||
if (sprite)
|
||||
{
|
||||
// TProp<Sprite> sp = n.Sprite;
|
||||
// sp.Value = img.sprite;
|
||||
// n.Sprite = sp;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TProp<Color> sp = n.Color;
|
||||
// if (daButton.BlendMode == DAG.DAColorBlendMode.Overlay)
|
||||
{
|
||||
// sp.Value = gr.color;
|
||||
}
|
||||
// else
|
||||
{
|
||||
// sp.Value = Color.white;
|
||||
}
|
||||
// n.Color = sp;
|
||||
}
|
||||
|
||||
// tg.NormalState = n;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sh.Data.Tags.Contains(FcuTag.BtnDisabled))
|
||||
{
|
||||
// UpdateAnimationColor(DAPointerEvent.OnDisable);
|
||||
}
|
||||
else if (sh.Data.Tags.Contains(FcuTag.BtnHover))
|
||||
{
|
||||
// UpdateAnimationColor(DAPointerEvent.OnPointerEnter);
|
||||
}
|
||||
else if (sh.Data.Tags.Contains(FcuTag.BtnPressed))
|
||||
{
|
||||
// UpdateAnimationColor(DAPointerEvent.OnPointerClick);
|
||||
}
|
||||
else if (sh.Data.Tags.Contains(FcuTag.BtnLooped))
|
||||
{
|
||||
// UpdateAnimationColor(DAPointerEvent.OnLoopStart);
|
||||
}
|
||||
else if (sh.Data.Tags.Contains(FcuTag.BtnSelected))
|
||||
{
|
||||
//TODO: add BtnSelected
|
||||
}
|
||||
/*
|
||||
void UpdateAnimationColor(DAPointerEvent pointerEvent)
|
||||
{
|
||||
for (int i = 0; i < tg.AnimationBlocks.Count; i++)
|
||||
{
|
||||
if (tg.AnimationBlocks[i].Event != pointerEvent)
|
||||
continue;
|
||||
|
||||
AnimationBlock animBlock = tg.AnimationBlocks[i];
|
||||
|
||||
for (int j = 0; j < animBlock.AnimationItems.Count; j++)
|
||||
{
|
||||
AnimationItem tempItem = animBlock.AnimationItems[j];
|
||||
|
||||
if (sprite)
|
||||
{
|
||||
TProp<Sprite> sp = tempItem.Sprite;
|
||||
sp.Value = img.sprite;
|
||||
tempItem.Sprite = sp;
|
||||
}
|
||||
else
|
||||
{
|
||||
TProp<Color> sp = tempItem.Color;
|
||||
sp.Value = gr.color;
|
||||
tempItem.Color = sp;
|
||||
}
|
||||
|
||||
animBlock.AnimationItems[j] = tempItem;
|
||||
}
|
||||
|
||||
tg.AnimationBlocks[i] = animBlock;
|
||||
}
|
||||
}*/
|
||||
|
||||
gr.gameObject.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
// daButton.TargetGraphics.Add(tg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private bool TryGetNumberBeforeDash(string input, out int number)
|
||||
{
|
||||
string pattern = @"\d+(?=\s*-)";
|
||||
Match match = Regex.Match(input, pattern);
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
number = int.Parse(match.Value);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
number = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f53b8061122470748aaa74c9547ad1f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,109 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.UI;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class FcuButtonDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void SetupFcuButton(SyncData btnSyncData)
|
||||
{
|
||||
monoBeh.CanvasDrawer.ButtonDrawer.UnityButtonDrawer.SetupSelectable(btnSyncData, out SyncHelper[] btnChilds, out bool hasCustomButtonBackgrounds);
|
||||
|
||||
FcuButton btn = btnSyncData.GameObject.GetComponent<FcuButton>();
|
||||
|
||||
if (hasCustomButtonBackgrounds)
|
||||
{
|
||||
SetCustomTargetGraphics(btnChilds, btn);
|
||||
}
|
||||
else
|
||||
{
|
||||
monoBeh.CanvasDrawer.ButtonDrawer.UnityButtonDrawer.SetDefaultTargetGraphic(btnChilds, btn);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCustomTargetGraphics(SyncHelper[] syncHelpers, FcuButton btn)
|
||||
{
|
||||
foreach (SyncHelper syncHelper in syncHelpers)
|
||||
{
|
||||
if (syncHelper.ContainsTag(FcuTag.Image))
|
||||
{
|
||||
if (btn.transition == Selectable.Transition.SpriteSwap)
|
||||
{
|
||||
monoBeh.CanvasDrawer.ButtonDrawer.UnityButtonDrawer.SetSprite(btn, syncHelper);
|
||||
}
|
||||
else
|
||||
{
|
||||
monoBeh.CanvasDrawer.ButtonDrawer.UnityButtonDrawer.SetImageColor(btn, syncHelper);
|
||||
}
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.Text))
|
||||
{
|
||||
SetText(btn, syncHelper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetText(FcuButton btn, SyncHelper syncHelper)
|
||||
{
|
||||
if (syncHelper.TryGetComponentSafe(out Graphic graphic))
|
||||
{
|
||||
if (syncHelper.ContainsAnyTag(
|
||||
FcuTag.BtnDefault,
|
||||
FcuTag.BtnDisabled,
|
||||
FcuTag.BtnHover,
|
||||
FcuTag.BtnPressed,
|
||||
FcuTag.BtnSelected))
|
||||
{
|
||||
btn.ChangeTextColor = true;
|
||||
}
|
||||
|
||||
if (syncHelper.ContainsTag(FcuTag.BtnDefault))
|
||||
{
|
||||
btn.TextDefaultColor = graphic.color;
|
||||
|
||||
switch (monoBeh.Settings.TextFontsSettings.TextComponent)
|
||||
{
|
||||
case TextComponent.UnityText:
|
||||
btn.ButtonText = syncHelper.GetComponent<Text>();
|
||||
break;
|
||||
case TextComponent.TextMeshPro:
|
||||
#if TextMeshPro
|
||||
btn.ButtonText = syncHelper.GetComponent<TMP_Text>();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (syncHelper.ContainsTag(FcuTag.BtnPressed))
|
||||
{
|
||||
btn.TextPressedColor = graphic.color;
|
||||
syncHelper.gameObject.Destroy();
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnHover))
|
||||
{
|
||||
btn.TextHoverColor = graphic.color;
|
||||
syncHelper.gameObject.Destroy();
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnSelected))
|
||||
{
|
||||
btn.TextSelectedColor = graphic.color;
|
||||
syncHelper.gameObject.Destroy();
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnDisabled))
|
||||
{
|
||||
btn.TextDisabledColor = graphic.color;
|
||||
syncHelper.gameObject.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea6482563d801244f9280791fb64355d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,233 @@
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class UnityButtonDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void SetupUnityButton(SyncData btnSyncData)
|
||||
{
|
||||
SetupSelectable(btnSyncData, out SyncHelper[] btnChilds, out bool hasCustomButtonBackgrounds);
|
||||
|
||||
Button btn = btnSyncData.GameObject.GetComponent<Button>();
|
||||
|
||||
if (hasCustomButtonBackgrounds)
|
||||
{
|
||||
SetCustomTargetGraphics(btnChilds, btn);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDefaultTargetGraphic(btnChilds, btn);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetupSelectable(SyncData btnSyncData, out SyncHelper[] btnChilds, out bool hasCustomButtonBackgrounds)
|
||||
{
|
||||
btnChilds = btnSyncData.GameObject.GetComponentsInChildren<SyncHelper>(true).Skip(1).ToArray();
|
||||
|
||||
hasCustomButtonBackgrounds = false;
|
||||
|
||||
List<FObject> backgrounds = new List<FObject>();
|
||||
|
||||
foreach (int cindex in btnSyncData.ChildIndexes)
|
||||
{
|
||||
if (monoBeh.CurrentProject.TryGetByIndex(cindex, out FObject child))
|
||||
{
|
||||
if (child.ContainsTag(FcuTag.Image))
|
||||
{
|
||||
backgrounds.Add(child);
|
||||
}
|
||||
|
||||
if (child.ContainsAnyTag(
|
||||
FcuTag.BtnDefault,
|
||||
FcuTag.BtnDisabled,
|
||||
FcuTag.BtnHover,
|
||||
FcuTag.BtnPressed,
|
||||
FcuTag.BtnSelected))
|
||||
{
|
||||
hasCustomButtonBackgrounds = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool allSprites = btnChilds.Where(x => x.ContainsTag(FcuTag.Image)).Count(x => x.Data.IsSprite()) > 1;
|
||||
|
||||
if (monoBeh.IsUGUI())
|
||||
{
|
||||
Selectable btn = btnSyncData.GameObject.GetComponent<Selectable>();
|
||||
|
||||
if (allSprites)
|
||||
{
|
||||
btn.transition = Selectable.Transition.SpriteSwap;
|
||||
}
|
||||
else
|
||||
{
|
||||
btn.transition = Selectable.Transition.ColorTint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCustomTargetGraphics(SyncHelper[] syncHelpers, Button btn)
|
||||
{
|
||||
foreach (SyncHelper syncHelper in syncHelpers)
|
||||
{
|
||||
if (syncHelper.ContainsTag(FcuTag.Image))
|
||||
{
|
||||
if (btn.transition == Selectable.Transition.SpriteSwap)
|
||||
{
|
||||
SetSprite(btn, syncHelper);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetImageColor(btn, syncHelper);
|
||||
}
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.Text))
|
||||
{
|
||||
SetText(syncHelper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetText(SyncHelper syncHelper)
|
||||
{
|
||||
if (syncHelper.ContainsAnyTag(
|
||||
FcuTag.BtnDisabled,
|
||||
FcuTag.BtnHover,
|
||||
FcuTag.BtnPressed,
|
||||
FcuTag.BtnSelected))
|
||||
{
|
||||
syncHelper.gameObject.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSprite(Selectable selectable, SyncHelper syncHelper)
|
||||
{
|
||||
selectable.transition = Selectable.Transition.SpriteSwap;
|
||||
SpriteState spriteState = selectable.spriteState;
|
||||
|
||||
if (syncHelper.ContainsTag(FcuTag.BtnDefault))
|
||||
{
|
||||
if (syncHelper.TryGetComponentSafe(out Graphic graphic))
|
||||
{
|
||||
selectable.targetGraphic = graphic;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (syncHelper.TryGetComponentSafe(out Image img))
|
||||
{
|
||||
if (syncHelper.ContainsTag(FcuTag.BtnPressed))
|
||||
{
|
||||
spriteState.pressedSprite = img.sprite;
|
||||
syncHelper.gameObject.Destroy();
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnHover))
|
||||
{
|
||||
spriteState.highlightedSprite = img.sprite;
|
||||
syncHelper.gameObject.Destroy();
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnSelected))
|
||||
{
|
||||
spriteState.selectedSprite = img.sprite;
|
||||
syncHelper.gameObject.Destroy();
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnDisabled))
|
||||
{
|
||||
spriteState.disabledSprite = img.sprite;
|
||||
syncHelper.gameObject.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
selectable.spriteState = spriteState;
|
||||
}
|
||||
|
||||
public void SetImageColor(Selectable selectable, SyncHelper syncHelper)
|
||||
{
|
||||
selectable.transition = Selectable.Transition.ColorTint;
|
||||
ColorBlock colorBlock = selectable.colors;
|
||||
|
||||
if (syncHelper.TryGetComponentSafe(out Graphic graphic))
|
||||
{
|
||||
if (syncHelper.ContainsTag(FcuTag.BtnDefault))
|
||||
{
|
||||
selectable.targetGraphic = graphic;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (syncHelper.ContainsTag(FcuTag.BtnPressed))
|
||||
{
|
||||
colorBlock.pressedColor = graphic.color;
|
||||
syncHelper.gameObject.Destroy();
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnHover))
|
||||
{
|
||||
colorBlock.highlightedColor = graphic.color;
|
||||
syncHelper.gameObject.Destroy();
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnSelected))
|
||||
{
|
||||
colorBlock.selectedColor = graphic.color;
|
||||
syncHelper.gameObject.Destroy();
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnDisabled))
|
||||
{
|
||||
colorBlock.disabledColor = graphic.color;
|
||||
syncHelper.gameObject.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
selectable.colors = colorBlock;
|
||||
}
|
||||
|
||||
public void SetDefaultTargetGraphic(SyncHelper[] syncHelpers, Selectable btn)
|
||||
{
|
||||
Graphic gr1 = null;
|
||||
bool exists = !syncHelpers.IsEmpty() && syncHelpers.First().TryGetComponentSafe(out gr1);
|
||||
|
||||
//If the first element of the hierarchy can be used as a target graphic.
|
||||
if (exists)
|
||||
{
|
||||
btn.targetGraphic = gr1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//If there is at least some image, assign it to the targetGraphic.
|
||||
foreach (SyncHelper meta in syncHelpers)
|
||||
{
|
||||
if (meta.TryGetComponentSafe(out Image gr2))
|
||||
{
|
||||
btn.targetGraphic = gr2;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//If there is at least some graphic, assign it to the targetGraphic.
|
||||
foreach (SyncHelper meta in syncHelpers)
|
||||
{
|
||||
if (meta.TryGetComponentSafe(out Graphic gr3))
|
||||
{
|
||||
btn.targetGraphic = gr3;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//If there is a graphic on the button itself, assign it to the targetGraphic.
|
||||
if (btn.TryGetComponentSafe(out Graphic gr4))
|
||||
{
|
||||
btn.targetGraphic = gr4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 464bdced9f5d399419493f3cdd1da157
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class CanvasGroupDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
if (fobject.Data.FcuImageType == FcuImageType.Downloadable)
|
||||
return;
|
||||
|
||||
fobject.Data.GameObject.TryAddComponent(out CanvasGroup canvasGroup);
|
||||
canvasGroup.alpha = (float)fobject.Opacity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c05e0259861ea48489ae137fe5d6d6c9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,246 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.Logging;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class GameObjectDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
List<GameObject> tempRectFrames = new List<GameObject>();
|
||||
|
||||
public void ClearTempRectFrames()
|
||||
{
|
||||
foreach (var item in tempRectFrames)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
item.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
tempRectFrames.Clear();
|
||||
}
|
||||
|
||||
public void Draw(FObject parent)
|
||||
{
|
||||
DALogger.Log(FcuLocKey.log_instantiate_game_objects.Localize());
|
||||
DrawFObject(parent);
|
||||
}
|
||||
|
||||
public void DrawFObject(FObject parent)
|
||||
{
|
||||
for (int i = 0; i < parent.Children.Count; i++)
|
||||
{
|
||||
if (monoBeh.IsCancellationRequested(TokenType.Import))
|
||||
return;
|
||||
|
||||
FObject fobject = parent.Children[i];
|
||||
|
||||
if (fobject.Data.IsEmpty)
|
||||
{
|
||||
FcuLogger.Debug($"InstantiateGameObjects | continue | {fobject.Data.NameHierarchy}");
|
||||
continue;
|
||||
}
|
||||
|
||||
SyncHelper syncHelper;
|
||||
|
||||
if (monoBeh.SyncHelpers.IsExistsOnCurrentCanvas(fobject, out syncHelper))
|
||||
{
|
||||
FcuLogger.Debug($"InstantiateGameObjects | 1 | {fobject.Data.NameHierarchy}", FcuLogType.GameObjectDrawer);
|
||||
}
|
||||
else if (monoBeh.CurrentProject.HasLocalPrefab(fobject.Data, out SyncHelper localPrefab))
|
||||
{
|
||||
FcuLogger.Debug($"InstantiateGameObjects | 2 | {fobject.Data.NameHierarchy}", FcuLogType.GameObjectDrawer);
|
||||
#if UNITY_EDITOR
|
||||
syncHelper = (SyncHelper)UnityEditor.PrefabUtility.InstantiatePrefab(localPrefab);
|
||||
#endif
|
||||
int counter = 0;
|
||||
monoBeh.SyncHelpers.SetFcuToAllChilds(syncHelper.gameObject, ref counter);
|
||||
|
||||
SetFigmaIds(fobject, syncHelper);
|
||||
monoBeh.Events.OnObjectInstantiate?.Invoke(monoBeh, fobject.Data.GameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
FcuLogger.Debug($"InstantiateGameObjects | 3 | {fobject.Data.NameHierarchy}", FcuLogType.GameObjectDrawer);
|
||||
syncHelper = MonoBehExtensions.CreateEmptyGameObject().AddComponent<SyncHelper>();
|
||||
monoBeh.Events.OnObjectInstantiate?.Invoke(monoBeh, fobject.Data.GameObject);
|
||||
}
|
||||
|
||||
fobject.SetData(syncHelper, monoBeh);
|
||||
fobject.Data.GameObject.name = fobject.Data.Names.ObjectName;
|
||||
|
||||
if (monoBeh.IsUGUI())
|
||||
{
|
||||
fobject.Data.GameObject.TryAddComponent(out RectTransform _1);
|
||||
}
|
||||
|
||||
AddRectGameObject(fobject);
|
||||
|
||||
int goLayer;
|
||||
|
||||
if (fobject.ContainsTag(FcuTag.Blur))
|
||||
{
|
||||
goLayer = LayerTools.AddLayer(FcuConfig.Instance.BlurredObjectTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
goLayer = monoBeh.Settings.MainSettings.GameObjectLayer;
|
||||
}
|
||||
|
||||
fobject.Data.GameObject.layer = goLayer;
|
||||
|
||||
SetParent(fobject, parent);
|
||||
SetParentRect(fobject, parent);
|
||||
|
||||
if (fobject.Children.IsEmpty())
|
||||
continue;
|
||||
|
||||
DrawFObject(fobject);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddRectGameObject(FObject fobject)
|
||||
{
|
||||
GameObject rectGameObject = MonoBehExtensions.CreateEmptyGameObject();
|
||||
rectGameObject.name = fobject.Data.GameObject.name + " | RectTransform";
|
||||
|
||||
if (fobject.ContainsTag(FcuTag.Frame))
|
||||
{
|
||||
tempRectFrames.Add(rectGameObject);
|
||||
}
|
||||
|
||||
fobject.Data.RectGameObject = rectGameObject;
|
||||
fobject.Data.RectGameObject.TryAddComponent(out RectTransform _2);
|
||||
|
||||
fobject.Data.RectGameObject.TryAddComponent(out Image rectImg);
|
||||
rectImg.color = monoBeh.GraphicHelpers.GetRectTransformColor(fobject);
|
||||
}
|
||||
|
||||
private void SetParent(FObject fobject, FObject parent)
|
||||
{
|
||||
if (!fobject.Data.GameObject.transform.parent.IsPartOfAnyPrefab())
|
||||
{
|
||||
Transform pt = parent.Data.GameObject.transform;
|
||||
fobject.Data.GameObject.transform.SetParent(pt);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetParentRect(FObject fobject, FObject parent)
|
||||
{
|
||||
if (!fobject.Data.RectGameObject.transform.parent.IsPartOfAnyPrefab())
|
||||
{
|
||||
Transform pt = parent.Data.RectGameObject.transform;
|
||||
fobject.Data.RectGameObject.transform.SetParent(pt);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetFigmaIds(FObject rootFObject, SyncHelper rootSyncObject)
|
||||
{
|
||||
Dictionary<string, int> items = new Dictionary<string, int>();
|
||||
|
||||
foreach (var childIndex in rootFObject.Data.ChildIndexes)
|
||||
{
|
||||
if (monoBeh.CurrentProject.TryGetByIndex(childIndex, out FObject childFO))
|
||||
{
|
||||
items.Add(childFO.Id, childFO.Data.Hash);
|
||||
}
|
||||
}
|
||||
|
||||
SyncHelper[] soChilds = rootSyncObject.GetComponentsInChildren<SyncHelper>(true);
|
||||
|
||||
foreach (var soChild in soChilds)
|
||||
{
|
||||
string idToRemove = null;
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item.Value == soChild.Data.Hash)
|
||||
{
|
||||
idToRemove = item.Key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (idToRemove == null)
|
||||
continue;
|
||||
|
||||
items.Remove(idToRemove);
|
||||
soChild.Data.Id = idToRemove;
|
||||
|
||||
if (monoBeh.CurrentProject.TryGetById(idToRemove, out FObject gbi))
|
||||
{
|
||||
SetFigmaIds(gbi, soChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DestroyMissing(IEnumerable<SyncData> diffCheckResult)
|
||||
{
|
||||
foreach (SyncData item in diffCheckResult)
|
||||
{
|
||||
try
|
||||
{
|
||||
FcuLogger.Debug($"DestroyMissing | {item.NameHierarchy}");
|
||||
item.GameObject.Destroy();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning(ex);
|
||||
}
|
||||
|
||||
await Task.Yield();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DestroyMissing(List<FObject> fobjects)
|
||||
{
|
||||
SyncHelper[] syncHelpers = monoBeh.SyncHelpers.GetAllSyncHelpers();
|
||||
|
||||
ConcurrentBag<SyncHelper> toDestroy = new ConcurrentBag<SyncHelper>();
|
||||
|
||||
Parallel.ForEach(syncHelpers, syncHelper =>
|
||||
{
|
||||
bool find = false;
|
||||
|
||||
foreach (FObject fobject in fobjects)
|
||||
{
|
||||
if (syncHelper.Data.Id == fobject.Data.Id)
|
||||
{
|
||||
find = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (find == false)
|
||||
{
|
||||
FcuLogger.Debug($"DestroyMissing | {syncHelper.Data.NameHierarchy}");
|
||||
toDestroy.Add(syncHelper);
|
||||
}
|
||||
});
|
||||
|
||||
foreach (SyncHelper sh in toDestroy)
|
||||
{
|
||||
try
|
||||
{
|
||||
sh.gameObject.Destroy();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
await Task.Yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc69891ee0f89894fb15b5c758c02440
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9a54d865378f0a4cb0e54b4fc86a361
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,147 @@
|
||||
#if PROCEDURAL_UI_ASSET_STORE_RELEASE
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DTT.UI.ProceduralUI;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using DA_Assets.Logging;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class DttPuiDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject, Sprite sprite, GameObject target)
|
||||
{
|
||||
target.TryAddGraphic(out RoundedImage img);
|
||||
|
||||
img.sprite = sprite;
|
||||
img.type = monoBeh.Settings.DttPuiSettings.Type;
|
||||
img.raycastTarget = monoBeh.Settings.DttPuiSettings.RaycastTarget;
|
||||
img.preserveAspect = monoBeh.Settings.DttPuiSettings.PreserveAspect;
|
||||
img.DistanceFalloff = monoBeh.Settings.DttPuiSettings.FalloffDistance;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
img.raycastPadding = monoBeh.Settings.DttPuiSettings.RaycastPadding;
|
||||
#endif
|
||||
|
||||
SetCorners(fobject, img);
|
||||
SetColor(fobject, img);
|
||||
}
|
||||
|
||||
public void SetColor(FObject fobject, RoundedImage img)
|
||||
{
|
||||
FGraphic graphic = fobject.Data.Graphic;
|
||||
|
||||
FcuLogger.Debug($"SetUnityImageColor | {fobject.Data.NameHierarchy} | {fobject.Data.FcuImageType} | hasFills: {graphic.HasFill} | hasStroke: {graphic.HasStroke}", FcuLogType.ComponentDrawer);
|
||||
|
||||
SetBorderThickness(0, img);
|
||||
|
||||
if (fobject.IsDrawableType())
|
||||
{
|
||||
monoBeh.CanvasDrawer.ImageDrawer.SetProceduralColor(fobject, img,
|
||||
setStrokeOnlyWidth: () =>
|
||||
{
|
||||
SetBorderThickness(fobject.StrokeWeight, img);
|
||||
},
|
||||
setStroke: () =>
|
||||
{
|
||||
switch (graphic.Stroke.Align)
|
||||
{
|
||||
case StrokeAlign.OUTSIDE:
|
||||
{
|
||||
monoBeh.CanvasDrawer.ImageDrawer.AddUnityOutline(fobject);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
fobject.Data.GameObject.TryDestroyComponent<UnityEngine.UI.Outline>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
monoBeh.CanvasDrawer.ImageDrawer.UnityImageDrawer.SetColor(fobject, img);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCorners(FObject fobject, RoundedImage img)
|
||||
{
|
||||
img.RoundingUnit = RoundingUnit.WORLD;
|
||||
|
||||
Type objectType = img.GetType();
|
||||
FieldInfo fieldInfo = objectType.GetField("_cornerMode", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
Vector4 radius = monoBeh.GraphicHelpers.GetCornerRadius(fobject);
|
||||
|
||||
if (!radius.IsDefault())
|
||||
{
|
||||
if (fieldInfo != null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
fieldInfo.SetValue(img, (int)RoundingCornerMode.INDIVIDUAL);
|
||||
#endif
|
||||
}
|
||||
|
||||
SetByIndex(0, img, objectType, "_roundingAmount", radius[0]);
|
||||
SetByIndex(1, img, objectType, "_roundingAmount", radius[1]);
|
||||
SetByIndex(2, img, objectType, "_roundingAmount", radius[2]);
|
||||
SetByIndex(3, img, objectType, "_roundingAmount", radius[3]);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetByIndex(int index, object classInstance, Type type, string arrayFieldName, float value)
|
||||
{
|
||||
FieldInfo fieldInfo = type.GetField(arrayFieldName, BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (fieldInfo == null)
|
||||
{
|
||||
DALogger.LogError($"Field '{arrayFieldName}' not found in type '{type}'.");
|
||||
return;
|
||||
}
|
||||
|
||||
float[] array = fieldInfo.GetValue(classInstance) as float[];
|
||||
if (array == null)
|
||||
{
|
||||
DALogger.LogError($"Field '{arrayFieldName}' is not an array or is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (index < 0 || index >= array.Length)
|
||||
{
|
||||
DALogger.LogError($"Index '{index}' is out of bounds for array '{arrayFieldName}'.");
|
||||
return;
|
||||
}
|
||||
|
||||
array[index] = value;
|
||||
|
||||
fieldInfo.SetValue(classInstance, array);
|
||||
|
||||
FcuLogger.Debug($"Value {value} was set at index {index} of array '{arrayFieldName}'.");
|
||||
}
|
||||
|
||||
public void SetBorderThickness(float thickness, RoundedImage img)
|
||||
{
|
||||
if (thickness > 0)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
img.Mode = RoundingMode.BORDER;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
img.Mode = RoundingMode.FILL;
|
||||
#endif
|
||||
}
|
||||
|
||||
Type objectType = img.GetType();
|
||||
FieldInfo fieldInfo = objectType.GetField("_borderThickness", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
fieldInfo.SetValue(img, (float)thickness);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20197d33d01812743b7bee2600f312e3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,365 @@
|
||||
using DA_Assets.CR;
|
||||
using DA_Assets.DAG;
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class ImageDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject, GameObject customGameObject = null)
|
||||
{
|
||||
GameObject target = customGameObject == null ? fobject.Data.GameObject : customGameObject;
|
||||
|
||||
if (fobject.Data.GameObject.IsPartOfAnyPrefab() == false)
|
||||
{
|
||||
if (target.TryGetComponentSafe(out Graphic oldGraphic))
|
||||
{
|
||||
Type curType = monoBeh.GetCurrentImageType();
|
||||
|
||||
if (oldGraphic.GetType().Equals(curType) == false)
|
||||
{
|
||||
oldGraphic.RemoveComponentsDependingOn();
|
||||
oldGraphic.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Sprite sprite = monoBeh.SpriteProcessor.GetSprite(fobject);
|
||||
|
||||
if (sprite == null)
|
||||
{
|
||||
if (fobject.IsSingleImageOrVideoOrEmojiType() || fobject.IsSprite())
|
||||
{
|
||||
sprite = FcuConfig.Instance.MissingImageTexture128px;
|
||||
}
|
||||
}
|
||||
|
||||
if (monoBeh.IsNova())
|
||||
{
|
||||
#if NOVA_UI_EXISTS
|
||||
this.NovaImageDrawer.Draw(fobject, sprite, target);
|
||||
#endif
|
||||
}
|
||||
else if (monoBeh.UsingUnityImage() || monoBeh.UsingRawImage() || fobject.IsObjectMask() || fobject.CanUseUnityImage(monoBeh))
|
||||
{
|
||||
this.UnityImageDrawer.Draw(fobject, sprite, target);
|
||||
}
|
||||
else if (monoBeh.UsingSvgImage())
|
||||
{
|
||||
#if VECTOR_GRAPHICS_EXISTS
|
||||
this.SvgImageDrawer.Draw(fobject, sprite, target);
|
||||
#endif
|
||||
}
|
||||
else if (monoBeh.UsingSpriteRenderer())
|
||||
{
|
||||
this.SpriteRendererDrawer.Draw(fobject, sprite, target);
|
||||
}
|
||||
else if (monoBeh.UsingShapes2D())
|
||||
{
|
||||
#if SUBC_SHAPES_EXISTS
|
||||
this.Shapes2DDrawer.Draw(fobject, sprite, target);
|
||||
#endif
|
||||
}
|
||||
else if (monoBeh.UsingJoshPui())
|
||||
{
|
||||
#if JOSH_PUI_EXISTS
|
||||
this.JoshPuiDrawer.Draw(fobject, sprite, target);
|
||||
#endif
|
||||
}
|
||||
else if (monoBeh.UsingDttPui())
|
||||
{
|
||||
#if PROCEDURAL_UI_ASSET_STORE_RELEASE
|
||||
this.DttPuiDrawer.Draw(fobject, sprite, target);
|
||||
#endif
|
||||
}
|
||||
else if (monoBeh.UsingMPUIKit())
|
||||
{
|
||||
#if MPUIKIT_EXISTS
|
||||
this.MPUIKitDrawer.Draw(fobject, sprite, target);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (fobject.ContainsTag(FcuTag.Slice9))
|
||||
{
|
||||
if (!monoBeh.IsNova())
|
||||
{
|
||||
if (target.TryGetComponent(out Image img))
|
||||
{
|
||||
img.type = Image.Type.Sliced;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddUnityOutline(FObject fobject)
|
||||
{
|
||||
FGraphic graphic = fobject.Data.Graphic;
|
||||
|
||||
fobject.Data.GameObject.TryAddComponent(out UnityEngine.UI.Outline outline);
|
||||
outline.useGraphicAlpha = false;
|
||||
outline.effectDistance = new Vector2(fobject.StrokeWeight, -fobject.StrokeWeight);
|
||||
|
||||
if (graphic.Stroke.HasSolid)
|
||||
{
|
||||
outline.effectColor = graphic.Stroke.SolidPaint.Color;
|
||||
}
|
||||
else if (graphic.Stroke.HasGradient)
|
||||
{
|
||||
outline.effectColor = graphic.Stroke.SingleColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
outline.effectColor = default;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddGradient(FObject fobject, Paint gradientColor, bool strokeOnly = false)
|
||||
{
|
||||
GameObject gameObject = fobject.Data.GameObject;
|
||||
List<GradientColorKey> gradientColorKeys = gradientColor.ToGradientColorKeys();
|
||||
List<GradientAlphaKey> gradientAlphaKeys = gradientColor.ToGradientAlphaKeys();
|
||||
|
||||
float angle;
|
||||
|
||||
switch (gradientColor.Type)
|
||||
{
|
||||
case PaintType.GRADIENT_RADIAL:
|
||||
angle = monoBeh.GraphicHelpers.ToRadialAngle(fobject, gradientColor.GradientHandlePositions);
|
||||
break;
|
||||
default:
|
||||
angle = monoBeh.GraphicHelpers.ToLinearAngle(fobject, gradientColor.GradientHandlePositions);
|
||||
break;
|
||||
}
|
||||
|
||||
if (monoBeh.UsingShapes2D() && !strokeOnly)
|
||||
{
|
||||
AddDAGradient();
|
||||
}
|
||||
else if (monoBeh.UsingMPUIKit())
|
||||
{
|
||||
#if MPUIKIT_EXISTS
|
||||
if (gameObject.TryGetComponentSafe(out MPUIKIT.MPImage img))
|
||||
{
|
||||
Gradient gradient = new Gradient
|
||||
{
|
||||
mode = GradientMode.Blend,
|
||||
};
|
||||
|
||||
MPUIKIT.GradientEffect ge = new MPUIKIT.GradientEffect();
|
||||
ge.Enabled = true;
|
||||
|
||||
switch (gradientColor.Type)
|
||||
{
|
||||
case PaintType.GRADIENT_RADIAL:
|
||||
ge.GradientType = MPUIKIT.GradientType.Radial;
|
||||
break;
|
||||
default:
|
||||
ge.GradientType = MPUIKIT.GradientType.Linear;
|
||||
break;
|
||||
}
|
||||
|
||||
ge.Gradient = gradient;
|
||||
ge.Rotation = angle;
|
||||
img.GradientEffect = ge;
|
||||
|
||||
gradient.colorKeys = gradientColorKeys.ToArray();
|
||||
gradient.alphaKeys = gradientAlphaKeys.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
AddDAGradient();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (monoBeh.UsingDttPui())
|
||||
{
|
||||
#if PROCEDURAL_UI_ASSET_STORE_RELEASE
|
||||
if (gameObject.TryGetComponentSafe(out DTT.UI.ProceduralUI.RoundedImage roundedImage))
|
||||
{
|
||||
gameObject.TryAddComponent(out DTT.UI.ProceduralUI.GradientEffect gradient);
|
||||
|
||||
Gradient newGradient = new Gradient();
|
||||
newGradient.colorKeys = gradientColorKeys.ToArray();
|
||||
newGradient.alphaKeys = gradientAlphaKeys.ToArray();
|
||||
|
||||
Type objectType = gradient.GetType();
|
||||
System.Reflection.FieldInfo fieldInfo = objectType.GetField("_gradient", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
|
||||
if (fieldInfo != null)
|
||||
{
|
||||
fieldInfo.SetValue(gradient, newGradient);
|
||||
}
|
||||
|
||||
System.Reflection.FieldInfo fieldInfo1 = objectType.GetField("_type", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
|
||||
if (fieldInfo1 != null)
|
||||
{
|
||||
DTT.UI.ProceduralUI.GradientEffect.GradientType gt;
|
||||
|
||||
/// At the time of writing this code in the <see cref="DTT.UI.ProceduralUI"/> asset,
|
||||
/// the enums <see cref="DTT.UI.ProceduralUI.GradientEffect.GradientType.RADIAL"/>
|
||||
/// and <see cref="DTT.UI.ProceduralUI.GradientEffect.GradientType.ANGULAR"/> were swapped.
|
||||
switch (gradientColor.Type)
|
||||
{
|
||||
case PaintType.GRADIENT_RADIAL:
|
||||
gt = DTT.UI.ProceduralUI.GradientEffect.GradientType.ANGULAR;
|
||||
break;
|
||||
case PaintType.GRADIENT_ANGULAR:
|
||||
gt = DTT.UI.ProceduralUI.GradientEffect.GradientType.RADIAL;
|
||||
break;
|
||||
default:
|
||||
gt = DTT.UI.ProceduralUI.GradientEffect.GradientType.LINEAR;
|
||||
break;
|
||||
}
|
||||
|
||||
fieldInfo1.SetValue(gradient, gt);
|
||||
}
|
||||
|
||||
System.Reflection.FieldInfo fieldInfo3 = objectType.GetField("_rotation", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
|
||||
if (fieldInfo3 != null)
|
||||
{
|
||||
fieldInfo3.SetValue(gradient, angle);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddDAGradient();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
AddDAGradient();
|
||||
}
|
||||
|
||||
void AddDAGradient()
|
||||
{
|
||||
gameObject.TryAddComponent(out DAGradient gradient);
|
||||
|
||||
gradient.Angle = angle;
|
||||
gradient.BlendMode = DAColorBlendMode.Multiply;
|
||||
|
||||
gradient.Gradient.colorKeys = gradientColorKeys.ToArray();
|
||||
gradient.Gradient.alphaKeys = gradientAlphaKeys.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryAddCornerRounder(FObject fobject, GameObject target)
|
||||
{
|
||||
if (fobject.IsSprite())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fobject.ContainsRoundedCorners())
|
||||
{
|
||||
target.TryAddComponent(out CornerRounder cornerRounder);
|
||||
Vector4 cr = monoBeh.GraphicHelpers.GetCornerRadius(fobject);
|
||||
cornerRounder.SetRadii(cr);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetProceduralColor(FObject fobject, Image img, Action setStrokeOnlyWidth, Action setStroke)
|
||||
{
|
||||
FGraphic graphic = fobject.Data.Graphic;
|
||||
|
||||
FcuLogger.Debug($"SetUnityImageColor | {fobject.Data.NameHierarchy} | {fobject.Data.FcuImageType} | hasFills: {graphic.HasFill} | hasStroke: {graphic.HasStroke}", FcuLogType.ComponentDrawer);
|
||||
|
||||
bool strokeOnly = graphic.HasStroke && !graphic.HasFill;
|
||||
|
||||
if (strokeOnly)
|
||||
{
|
||||
setStrokeOnlyWidth();
|
||||
|
||||
if (graphic.Stroke.HasSolid)
|
||||
{
|
||||
img.color = graphic.Stroke.SolidPaint.Color;
|
||||
}
|
||||
else if (graphic.Stroke.HasGradient)
|
||||
{
|
||||
img.color = Color.white;
|
||||
monoBeh.CanvasDrawer.ImageDrawer.AddGradient(fobject, graphic.Stroke.GradientPaint);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (graphic.Fill.HasSolid)
|
||||
{
|
||||
img.color = graphic.Fill.SolidPaint.Color;
|
||||
}
|
||||
else if (graphic.Fill.HasGradient)
|
||||
{
|
||||
img.color = Color.white;
|
||||
monoBeh.CanvasDrawer.ImageDrawer.AddGradient(fobject, graphic.Fill.GradientPaint);
|
||||
}
|
||||
|
||||
if (graphic.HasStroke)
|
||||
{
|
||||
setStroke();
|
||||
}
|
||||
}
|
||||
|
||||
if (!graphic.HasStroke)
|
||||
{
|
||||
fobject.Data.GameObject.TryDestroyComponent<UnityEngine.UI.Outline>();
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] UnityImageDrawer unityImageDrawer;
|
||||
[SerializeProperty(nameof(unityImageDrawer))]
|
||||
public UnityImageDrawer UnityImageDrawer => monoBeh.Link(ref unityImageDrawer);
|
||||
|
||||
[SerializeField] SpriteRendererDrawer spriteRendererDrawer;
|
||||
[SerializeProperty(nameof(spriteRendererDrawer))]
|
||||
public SpriteRendererDrawer SpriteRendererDrawer => monoBeh.Link(ref spriteRendererDrawer);
|
||||
|
||||
#if SUBC_SHAPES_EXISTS
|
||||
[SerializeField] Shapes2DDrawer shapes2DDrawer;
|
||||
[SerializeProperty(nameof(shapes2DDrawer))]
|
||||
public Shapes2DDrawer Shapes2DDrawer => monoBeh.Link(ref shapes2DDrawer);
|
||||
#endif
|
||||
|
||||
#if JOSH_PUI_EXISTS
|
||||
[SerializeField] JoshPuiDrawer joshPuiDrawer;
|
||||
[SerializeProperty(nameof(joshPuiDrawer))]
|
||||
public JoshPuiDrawer JoshPuiDrawer => monoBeh.Link(ref joshPuiDrawer);
|
||||
#endif
|
||||
|
||||
#if PROCEDURAL_UI_ASSET_STORE_RELEASE
|
||||
[SerializeField] DttPuiDrawer dttPuiDrawer;
|
||||
[SerializeProperty(nameof(dttPuiDrawer))]
|
||||
public DttPuiDrawer DttPuiDrawer => monoBeh.Link(ref dttPuiDrawer);
|
||||
#endif
|
||||
|
||||
#if MPUIKIT_EXISTS
|
||||
[SerializeField] MPUIKitDrawer mpuikitDrawer;
|
||||
[SerializeProperty(nameof(mpuikitDrawer))]
|
||||
public MPUIKitDrawer MPUIKitDrawer => monoBeh.Link(ref mpuikitDrawer);
|
||||
#endif
|
||||
|
||||
#if VECTOR_GRAPHICS_EXISTS
|
||||
[SerializeField] SvgImageDrawer svgImageDrawer;
|
||||
[SerializeProperty(nameof(svgImageDrawer))]
|
||||
public SvgImageDrawer SvgImageDrawer => monoBeh.Link(ref svgImageDrawer);
|
||||
#endif
|
||||
|
||||
#if NOVA_UI_EXISTS
|
||||
[SerializeField] NovaImageDrawer novaImageDrawer;
|
||||
[SerializeProperty(nameof(novaImageDrawer))]
|
||||
public NovaImageDrawer NovaImageDrawer => monoBeh.Link(ref novaImageDrawer);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f03aa5e1e4188b7419ae7c7a982d1f82
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
#if JOSH_PUI_EXISTS
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI.ProceduralImage;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class JoshPuiDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject, Sprite sprite, GameObject target)
|
||||
{
|
||||
target.TryAddGraphic(out ProceduralImage img);
|
||||
|
||||
img.sprite = sprite;
|
||||
img.type = monoBeh.Settings.JoshPuiSettings.Type;
|
||||
img.raycastTarget = monoBeh.Settings.JoshPuiSettings.RaycastTarget;
|
||||
img.preserveAspect = monoBeh.Settings.JoshPuiSettings.PreserveAspect;
|
||||
img.FalloffDistance = monoBeh.Settings.JoshPuiSettings.FalloffDistance;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
img.raycastPadding = monoBeh.Settings.JoshPuiSettings.RaycastPadding;
|
||||
#endif
|
||||
if (fobject.Type == NodeType.ELLIPSE)
|
||||
{
|
||||
target.TryAddComponent(out RoundModifier roundModifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fobject.CornerRadiuses != null)
|
||||
{
|
||||
target.TryAddComponent(out FreeModifier freeModifier);
|
||||
freeModifier.Radius = monoBeh.GraphicHelpers.GetCornerRadius(fobject);
|
||||
}
|
||||
else
|
||||
{
|
||||
target.TryAddComponent(out UniformModifier uniformModifier);
|
||||
uniformModifier.Radius = fobject.CornerRadius.ToFloat();
|
||||
}
|
||||
}
|
||||
|
||||
SetColor(fobject, img);
|
||||
}
|
||||
|
||||
public void SetColor(FObject fobject, ProceduralImage img)
|
||||
{
|
||||
FGraphic graphic = fobject.Data.Graphic;
|
||||
|
||||
FcuLogger.Debug($"SetUnityImageColor | {fobject.Data.NameHierarchy} | {fobject.Data.FcuImageType} | hasFills: {graphic.HasFill} | hasStroke: {graphic.HasStroke}", FcuLogType.ComponentDrawer);
|
||||
|
||||
if (fobject.IsDrawableType())
|
||||
{
|
||||
monoBeh.CanvasDrawer.ImageDrawer.SetProceduralColor(fobject, img,
|
||||
setStrokeOnlyWidth: () =>
|
||||
{
|
||||
img.BorderWidth = fobject.StrokeWeight;
|
||||
},
|
||||
setStroke: () =>
|
||||
{
|
||||
switch (graphic.Stroke.Align)
|
||||
{
|
||||
case StrokeAlign.OUTSIDE:
|
||||
{
|
||||
monoBeh.CanvasDrawer.ImageDrawer.AddUnityOutline(fobject);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
fobject.Data.GameObject.TryDestroyComponent<UnityEngine.UI.Outline>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
monoBeh.CanvasDrawer.ImageDrawer.UnityImageDrawer.SetColor(fobject, img);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dca7183436af37c47b39f064a37c809d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,111 @@
|
||||
#if MPUIKIT_EXISTS
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using MPUIKIT;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class MPUIKitDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject, Sprite sprite, GameObject target)
|
||||
{
|
||||
target.TryAddGraphic(out MPImage img);
|
||||
SetCorners(fobject, img);
|
||||
|
||||
SetColor(fobject, img);
|
||||
|
||||
img.sprite = sprite;
|
||||
img.type = monoBeh.Settings.MPUIKitSettings.Type;
|
||||
img.raycastTarget = monoBeh.Settings.MPUIKitSettings.RaycastTarget;
|
||||
img.preserveAspect = monoBeh.Settings.MPUIKitSettings.PreserveAspect;
|
||||
img.FalloffDistance = monoBeh.Settings.MPUIKitSettings.FalloffDistance;
|
||||
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
img.raycastPadding = monoBeh.Settings.MPUIKitSettings.RaycastPadding;
|
||||
#endif
|
||||
|
||||
MethodInfo initMethod = typeof(MPImage).GetMethod("Init", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
initMethod.Invoke(img, null);
|
||||
}
|
||||
|
||||
public void SetColor(FObject fobject, MPImage img)
|
||||
{
|
||||
FGraphic graphic = fobject.Data.Graphic;
|
||||
|
||||
FcuLogger.Debug($"SetUnityImageColor | {fobject.Data.Hierarchy} | {fobject.Data.FcuImageType} | hasFills: {graphic.HasFill} | hasStroke: {graphic.HasStroke}", FcuLogType.ComponentDrawer);
|
||||
|
||||
img.GradientEffect = new GradientEffect
|
||||
{
|
||||
Enabled = false,
|
||||
GradientType = MPUIKIT.GradientType.Linear,
|
||||
Gradient = null
|
||||
};
|
||||
|
||||
if (fobject.IsDrawableType())
|
||||
{
|
||||
monoBeh.CanvasDrawer.ImageDrawer.SetProceduralColor(fobject, img,
|
||||
setStrokeOnlyWidth: () =>
|
||||
{
|
||||
img.StrokeWidth = fobject.StrokeWeight;
|
||||
},
|
||||
setStroke: () =>
|
||||
{
|
||||
switch (graphic.Stroke.Align)
|
||||
{
|
||||
case StrokeAlign.INSIDE:
|
||||
{
|
||||
img.OutlineColor = graphic.Stroke.SingleColor;
|
||||
img.OutlineWidth = fobject.StrokeWeight;
|
||||
fobject.Data.GameObject.TryDestroyComponent<UnityEngine.UI.Outline>();
|
||||
}
|
||||
break;
|
||||
case StrokeAlign.OUTSIDE:
|
||||
{
|
||||
monoBeh.CanvasDrawer.ImageDrawer.AddUnityOutline(fobject);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
fobject.Data.GameObject.TryDestroyComponent<UnityEngine.UI.Outline>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
monoBeh.CanvasDrawer.ImageDrawer.UnityImageDrawer.SetColor(fobject, img);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCorners(FObject fobject, MPImage img)
|
||||
{
|
||||
if (fobject.Type == NodeType.ELLIPSE)
|
||||
{
|
||||
img.DrawShape = DrawShape.Circle;
|
||||
img.Circle = new Circle
|
||||
{
|
||||
FitToRect = true
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
img.DrawShape = DrawShape.Rectangle;
|
||||
|
||||
img.Rectangle = new Rectangle
|
||||
{
|
||||
CornerRadius = monoBeh.GraphicHelpers.GetCornerRadius(fobject)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2bef7dba345a354d9275e0887be0646
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,183 @@
|
||||
#if SUBC_SHAPES_EXISTS
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using Shapes2D;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Shape = Shapes2D.Shape;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class Shapes2DDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject, Sprite sprite, GameObject target)
|
||||
{
|
||||
if (sprite != null)
|
||||
{
|
||||
if (target.TryGetComponentSafe(out Shape oldShape))
|
||||
{
|
||||
oldShape.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
target.TryAddGraphic(out Image img);
|
||||
img.sprite = sprite;
|
||||
img.material = null;
|
||||
img.type = monoBeh.Settings.Shapes2DSettings.Type;
|
||||
img.raycastTarget = monoBeh.Settings.Shapes2DSettings.RaycastTarget;
|
||||
img.preserveAspect = monoBeh.Settings.Shapes2DSettings.PreserveAspect;
|
||||
img.raycastTarget = monoBeh.Settings.Shapes2DSettings.RaycastTarget;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
img.raycastPadding = monoBeh.Settings.Shapes2DSettings.RaycastPadding;
|
||||
#endif
|
||||
|
||||
if (sprite == null)
|
||||
{
|
||||
target.TryAddComponent(out Shape shape);
|
||||
|
||||
SetColor(fobject, shape);
|
||||
SetCorners(fobject, shape);
|
||||
SetBlur(fobject, shape);
|
||||
}
|
||||
else
|
||||
{
|
||||
monoBeh.CanvasDrawer.ImageDrawer.UnityImageDrawer.SetColor(fobject, img);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetColor(FObject fobject, Shape shape)
|
||||
{
|
||||
FGraphic graphic = fobject.Data.Graphic;
|
||||
|
||||
FcuLogger.Debug($"SetUnityImageColor | {fobject.Data.Hierarchy} | {fobject.Data.FcuImageType} | hasFills: {graphic.HasFill} | hasStroke: {graphic.HasStroke}", FcuLogType.ComponentDrawer);
|
||||
|
||||
shape.settings.fillType = FillType.SolidColor;
|
||||
|
||||
if (graphic.Fill.HasGradient)
|
||||
{
|
||||
shape.settings.blur = 0.1f;
|
||||
}
|
||||
|
||||
if (fobject.IsDrawableType())
|
||||
{
|
||||
bool strokeOnly = graphic.HasStroke && !graphic.HasFill;
|
||||
|
||||
if (strokeOnly)
|
||||
{
|
||||
Color tr = Color.white;
|
||||
tr.a = 0;
|
||||
shape.settings.fillColor = tr;
|
||||
|
||||
if (graphic.Stroke.HasSolid)
|
||||
{
|
||||
shape.settings.outlineColor = graphic.Stroke.SolidPaint.Color;
|
||||
}
|
||||
else if (graphic.Stroke.HasGradient)
|
||||
{
|
||||
shape.settings.outlineColor = Color.white;
|
||||
monoBeh.CanvasDrawer.ImageDrawer.AddGradient(fobject, graphic.Stroke.GradientPaint, strokeOnly: true);
|
||||
}
|
||||
|
||||
shape.settings.outlineSize = fobject.StrokeWeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (graphic.Fill.HasSolid)
|
||||
{
|
||||
shape.settings.fillColor = graphic.Fill.SolidPaint.Color;
|
||||
}
|
||||
else if (graphic.Fill.HasGradient)
|
||||
{
|
||||
shape.settings.fillColor = Color.white;
|
||||
monoBeh.CanvasDrawer.ImageDrawer.AddGradient(fobject, graphic.Fill.GradientPaint);
|
||||
}
|
||||
|
||||
switch (graphic.Stroke.Align)
|
||||
{
|
||||
case StrokeAlign.INSIDE:
|
||||
{
|
||||
shape.settings.outlineColor = graphic.Stroke.SingleColor;
|
||||
shape.settings.outlineSize = fobject.StrokeWeight;
|
||||
fobject.Data.GameObject.TryDestroyComponent<UnityEngine.UI.Outline>();
|
||||
}
|
||||
break;
|
||||
case StrokeAlign.OUTSIDE:
|
||||
{
|
||||
monoBeh.CanvasDrawer.ImageDrawer.AddUnityOutline(fobject);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
shape.settings.outlineSize = 0;
|
||||
fobject.Data.GameObject.TryDestroyComponent<UnityEngine.UI.Outline>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!graphic.HasStroke)
|
||||
{
|
||||
shape.settings.outlineSize = 0;
|
||||
fobject.Data.GameObject.TryDestroyComponent<UnityEngine.UI.Outline>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCorners(FObject fobject, Shape shape)
|
||||
{
|
||||
if (fobject.Type == NodeType.ELLIPSE)
|
||||
{
|
||||
shape.settings.shapeType = ShapeType.Ellipse;
|
||||
}
|
||||
else
|
||||
{
|
||||
shape.settings.shapeType = ShapeType.Rectangle;
|
||||
|
||||
if (fobject.CornerRadiuses != null)
|
||||
{
|
||||
Vector4 cr = monoBeh.GraphicHelpers.GetCornerRadius(fobject);
|
||||
|
||||
shape.settings.roundnessPerCorner = true;
|
||||
|
||||
shape.settings.roundnessBottomLeft = cr.x;
|
||||
shape.settings.roundnessBottomRight = cr.y;
|
||||
shape.settings.roundnessTopRight = cr.z;
|
||||
shape.settings.roundnessTopLeft = cr.w;
|
||||
}
|
||||
else if (fobject.CornerRadius.ToFloat() != 0)
|
||||
{
|
||||
shape.settings.roundnessPerCorner = true;
|
||||
|
||||
shape.settings.roundnessBottomLeft = fobject.CornerRadius.ToFloat();
|
||||
shape.settings.roundnessBottomRight = fobject.CornerRadius.ToFloat();
|
||||
shape.settings.roundnessTopRight = fobject.CornerRadius.ToFloat();
|
||||
shape.settings.roundnessTopLeft = fobject.CornerRadius.ToFloat();
|
||||
|
||||
//For new Shape versions only.
|
||||
//shape.settings.roundnessPerCorner = false;
|
||||
//shape.settings.roundness = source.CornerRadius;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetBlur(FObject fobject, Shape shape)
|
||||
{
|
||||
foreach (Effect effect in fobject.Effects)
|
||||
{
|
||||
if (!effect.IsVisible())
|
||||
continue;
|
||||
|
||||
if (effect.Type != EffectType.LAYER_BLUR)
|
||||
continue;
|
||||
|
||||
shape.settings.blur = effect.Radius;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 237fa397aedcd2549877f765126e43c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,118 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.UI;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class SpriteRendererDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject, Sprite sprite, GameObject target)
|
||||
{
|
||||
target.TryAddComponent(out SpriteRenderer sr);
|
||||
sr.sprite = sprite;
|
||||
sr.sortingOrder = target.transform.GetSiblingIndex();
|
||||
|
||||
if (sprite == null)
|
||||
{
|
||||
sr.sprite = FcuConfig.Instance.WhiteSprite32px;
|
||||
sr.drawMode = SpriteDrawMode.Tiled;
|
||||
Vector2 size = target.GetComponent<RectTransform>().rect.size;
|
||||
sr.size = size;
|
||||
SetColor(fobject, sr);
|
||||
}
|
||||
else
|
||||
{
|
||||
sr.drawMode = SpriteDrawMode.Simple;
|
||||
|
||||
if (fobject.Data.FcuImageType == FcuImageType.Generative || fobject.Data.Graphic.SpriteSingleColor.IsDefault() == false)
|
||||
{
|
||||
SetColor(fobject, sr);
|
||||
}
|
||||
else
|
||||
{
|
||||
sr.color = Color.white;
|
||||
}
|
||||
}
|
||||
|
||||
sr.flipX = monoBeh.Settings.SpriteRendererSettings.FlipX;
|
||||
sr.flipY = monoBeh.Settings.SpriteRendererSettings.FlipY;
|
||||
sr.maskInteraction = monoBeh.Settings.SpriteRendererSettings.MaskInteraction;
|
||||
sr.spriteSortPoint = monoBeh.Settings.SpriteRendererSettings.SortPoint;
|
||||
sr.sortingLayerName = monoBeh.Settings.SpriteRendererSettings.SortingLayer;
|
||||
}
|
||||
|
||||
public void SetColor(FObject fobject, SpriteRenderer img)
|
||||
{
|
||||
FGraphic graphic = fobject.Data.Graphic;
|
||||
|
||||
FcuLogger.Debug($"SetUnityImageColor | {fobject.Data.NameHierarchy} | {fobject.Data.FcuImageType} | graphic.HasFills: {graphic.HasFill} | graphic.HasStrokes: {graphic.HasStroke}", FcuLogType.ComponentDrawer);
|
||||
|
||||
void AddOutline(float strokeWeight, float cornerRadius, Color color)
|
||||
{
|
||||
img.gameObject.TryAddComponent(out SpriteOutline uiOutline);
|
||||
uiOutline.OutlineWidth = strokeWeight;
|
||||
uiOutline.CornerSegments = 10;
|
||||
uiOutline.CornerRadius = cornerRadius;
|
||||
uiOutline.FillCenter = false;
|
||||
uiOutline.color = color;
|
||||
}
|
||||
|
||||
if (fobject.IsDrawableType())
|
||||
{
|
||||
Vector4 radius = monoBeh.GraphicHelpers.GetCornerRadius(fobject);
|
||||
|
||||
bool strokeOnly = graphic.HasStroke && !graphic.HasFill;
|
||||
|
||||
if (strokeOnly)
|
||||
{
|
||||
Color tr = Color.white;
|
||||
tr.a = 0;
|
||||
img.color = tr;
|
||||
|
||||
AddOutline(fobject.StrokeWeight, radius.x, graphic.Stroke.SingleColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
img.color = graphic.Fill.SingleColor;
|
||||
|
||||
if (graphic.HasStroke)
|
||||
{
|
||||
AddOutline(fobject.StrokeWeight, radius.x, graphic.Stroke.SingleColor);
|
||||
}
|
||||
}
|
||||
|
||||
if (!graphic.HasStroke)
|
||||
{
|
||||
fobject.Data.GameObject.TryDestroyComponent<SpriteOutline>();
|
||||
}
|
||||
}
|
||||
else if (fobject.IsGenerativeType())
|
||||
{
|
||||
if (graphic.HasFill)
|
||||
{
|
||||
img.color = graphic.Fill.SingleColor;
|
||||
}
|
||||
else if (graphic.HasStroke)
|
||||
{
|
||||
img.color = graphic.Stroke.SingleColor;
|
||||
}
|
||||
}
|
||||
else if (fobject.IsDownloadableType())
|
||||
{
|
||||
if (fobject.Data.Graphic.SpriteSingleColor.IsDefault() == false)
|
||||
{
|
||||
img.color = fobject.Data.Graphic.SpriteSingleColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
img.color = Color.white;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: baad81db531380e408108358bfa490de
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
#if VECTOR_GRAPHICS_EXISTS
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Unity.VectorGraphics;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class SvgImageDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject, Sprite sprite, GameObject target)
|
||||
{
|
||||
target.TryAddGraphic(out SVGImage img);
|
||||
|
||||
img.sprite = sprite;
|
||||
img.material = FcuConfig.Instance.VectorMaterials.UnlitVectorGradientUI;
|
||||
img.raycastTarget = monoBeh.Settings.SvgImageSettings.RaycastTarget;
|
||||
img.preserveAspect = monoBeh.Settings.SvgImageSettings.PreserveAspect;
|
||||
img.raycastPadding = monoBeh.Settings.SvgImageSettings.RaycastPadding;
|
||||
|
||||
monoBeh.CanvasDrawer.ImageDrawer.UnityImageDrawer.SetColor(fobject, img);
|
||||
monoBeh.CanvasDrawer.ImageDrawer.TryAddCornerRounder(fobject, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff4f7115a728b93428442379fee081fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,146 @@
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class UnityImageDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject, Sprite sprite, GameObject target)
|
||||
{
|
||||
MaskableGraphic graphic;
|
||||
|
||||
if (monoBeh.UsingRawImage())
|
||||
{
|
||||
target.TryAddGraphic(out RawImage img);
|
||||
graphic = img;
|
||||
|
||||
if (sprite != null)
|
||||
{
|
||||
img.texture = sprite.texture;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
target.TryAddGraphic(out Image img);
|
||||
graphic = img;
|
||||
|
||||
img.sprite = sprite;
|
||||
img.type = monoBeh.Settings.UnityImageSettings.Type;
|
||||
img.preserveAspect = monoBeh.Settings.UnityImageSettings.PreserveAspect;
|
||||
}
|
||||
|
||||
graphic.raycastTarget = monoBeh.Settings.UnityImageSettings.RaycastTarget;
|
||||
graphic.maskable = monoBeh.Settings.UnityImageSettings.Maskable;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
graphic.raycastPadding = monoBeh.Settings.UnityImageSettings.RaycastPadding;
|
||||
#endif
|
||||
|
||||
if (monoBeh.UseImageLinearMaterial())
|
||||
{
|
||||
graphic.material = FcuConfig.Instance.ImageLinearMaterial;
|
||||
}
|
||||
else
|
||||
{
|
||||
graphic.material = null;
|
||||
}
|
||||
|
||||
SetColor(fobject, graphic);
|
||||
monoBeh.CanvasDrawer.ImageDrawer.TryAddCornerRounder(fobject, target);
|
||||
}
|
||||
|
||||
public void SetColor(FObject fobject, MaskableGraphic img)
|
||||
{
|
||||
FGraphic graphic = fobject.Data.Graphic;
|
||||
|
||||
FcuLogger.Debug($"SetUnityImageColor | {fobject.Data.NameHierarchy} | {fobject.Data.FcuImageType} | graphic.HasFills: {graphic.HasFill} | graphic.HasStrokes: {graphic.HasStroke}", FcuLogType.ComponentDrawer);
|
||||
|
||||
if (fobject.IsDrawableType())
|
||||
{
|
||||
bool strokeOnly = graphic.HasStroke && !graphic.HasFill;
|
||||
|
||||
if (strokeOnly)
|
||||
{
|
||||
img.color = default;
|
||||
}
|
||||
else if (graphic.Fill.HasSolid)
|
||||
{
|
||||
img.color = graphic.Fill.SolidPaint.Color;
|
||||
}
|
||||
else if (graphic.HasStroke && graphic.Fill.HasGradient)
|
||||
{
|
||||
img.color = graphic.Fill.SingleColor;
|
||||
}
|
||||
else if (graphic.Fill.HasGradient)
|
||||
{
|
||||
img.color = Color.white;
|
||||
monoBeh.CanvasDrawer.ImageDrawer.AddGradient(fobject, graphic.Fill.GradientPaint);
|
||||
}
|
||||
|
||||
if (graphic.HasStroke)
|
||||
{
|
||||
if (graphic.HasStroke)
|
||||
{
|
||||
monoBeh.CanvasDrawer.ImageDrawer.AddUnityOutline(fobject);
|
||||
}
|
||||
}
|
||||
|
||||
if (!graphic.HasStroke)
|
||||
{
|
||||
fobject.Data.GameObject.TryDestroyComponent<UnityEngine.UI.Outline>();
|
||||
}
|
||||
}
|
||||
else if (fobject.IsGenerativeType())
|
||||
{
|
||||
if (graphic.HasFill && graphic.HasStroke)//no need colorize
|
||||
{
|
||||
monoBeh.CanvasDrawer.ImageDrawer.AddUnityOutline(fobject);
|
||||
}
|
||||
else if (graphic.HasFill)
|
||||
{
|
||||
if (graphic.Fill.HasSolid)
|
||||
{
|
||||
img.color = graphic.Fill.SolidPaint.Color;
|
||||
}
|
||||
else if (graphic.Fill.HasGradient)
|
||||
{
|
||||
img.color = Color.white;
|
||||
monoBeh.CanvasDrawer.ImageDrawer.AddGradient(fobject, graphic.Fill.GradientPaint);
|
||||
}
|
||||
}
|
||||
else if (graphic.HasStroke)
|
||||
{
|
||||
if (graphic.Stroke.HasSolid)
|
||||
{
|
||||
img.color = graphic.Stroke.SolidPaint.Color;
|
||||
}
|
||||
else
|
||||
{
|
||||
img.color = Color.white;
|
||||
monoBeh.CanvasDrawer.ImageDrawer.AddGradient(fobject, graphic.Stroke.GradientPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fobject.IsDownloadableType())
|
||||
{
|
||||
if (!fobject.Data.Graphic.SpriteSingleColor.IsDefault())
|
||||
{
|
||||
img.color = fobject.Data.Graphic.SpriteSingleColor;
|
||||
}
|
||||
else if (!fobject.Data.Graphic.SpriteSingleLinearGradient.IsDefault())
|
||||
{
|
||||
monoBeh.CanvasDrawer.ImageDrawer.AddGradient(fobject, fobject.Data.Graphic.SpriteSingleLinearGradient);
|
||||
}
|
||||
else
|
||||
{
|
||||
img.color = Color.white;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0d00cee3b6cc1140a6cfc9c75d58fd9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,209 @@
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
#if TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class InputFieldDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
private List<FObject> inputFields;
|
||||
public List<FObject> InputFields => inputFields;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
inputFields = new List<FObject>();
|
||||
}
|
||||
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
switch (monoBeh.Settings.TextFontsSettings.TextComponent)
|
||||
{
|
||||
case TextComponent.UnityText:
|
||||
fobject.Data.GameObject.TryAddComponent(out InputField inputField);
|
||||
break;
|
||||
#if TextMeshPro
|
||||
case TextComponent.TextMeshPro:
|
||||
fobject.Data.GameObject.TryAddComponent(out TMP_InputField tmpInputField);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
inputFields.Add(fobject);
|
||||
}
|
||||
|
||||
public async Task SetTargetGraphics()
|
||||
{
|
||||
switch (monoBeh.Settings.TextFontsSettings.TextComponent)
|
||||
{
|
||||
case TextComponent.UnityText:
|
||||
await SetTargetGraphicsInputFields();
|
||||
break;
|
||||
case TextComponent.TextMeshPro:
|
||||
await SetTargetGraphicsTmpInputFields();
|
||||
break;
|
||||
}
|
||||
|
||||
inputFields.Clear();
|
||||
}
|
||||
|
||||
private async Task SetTargetGraphicsInputFields()
|
||||
{
|
||||
foreach (FObject fobject in inputFields)
|
||||
{
|
||||
if (!fobject.Data.GameObject.TryGetComponentSafe(out InputField inputField))
|
||||
continue;
|
||||
|
||||
InputFieldModel ifm = GetGraphics(fobject.Data);
|
||||
|
||||
if (ifm.TextArea.TryGetComponentSafe(out RectTransform textArea))
|
||||
{
|
||||
textArea.SetSmartAnchor(AnchorType.StretchAll);
|
||||
}
|
||||
|
||||
if (ifm.Background.TryGetComponentSafe(out Graphic bg))
|
||||
{
|
||||
inputField.targetGraphic = bg;
|
||||
}
|
||||
|
||||
if (ifm.Placeholder.TryGetComponentSafe(out Graphic ph))
|
||||
{
|
||||
ph.gameObject.SetActive(true);
|
||||
inputField.placeholder = ph;
|
||||
}
|
||||
|
||||
if (ifm.TextComponent.TryGetComponentSafe(out Text text))
|
||||
{
|
||||
text.gameObject.SetActive(true);
|
||||
inputField.textComponent = text;
|
||||
inputField.textComponent.supportRichText = false;
|
||||
text.resizeTextForBestFit = false;
|
||||
}
|
||||
|
||||
if (fobject.ContainsTag(FcuTag.PasswordField))
|
||||
{
|
||||
inputField.contentType = InputField.ContentType.Password;
|
||||
inputField.asteriskChar = FcuConfig.AsterisksChar;
|
||||
}
|
||||
else
|
||||
{
|
||||
inputField.contentType = InputField.ContentType.Standard;
|
||||
}
|
||||
|
||||
inputField.enabled = false;
|
||||
await Task.Delay(10);
|
||||
inputField.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SetTargetGraphicsTmpInputFields()
|
||||
{
|
||||
#if TextMeshPro
|
||||
foreach (FObject fobject in inputFields)
|
||||
{
|
||||
if (!fobject.Data.GameObject.TryGetComponentSafe(out TMP_InputField inputField))
|
||||
continue;
|
||||
|
||||
InputFieldModel ifm = GetGraphics(fobject.Data);
|
||||
|
||||
if (ifm.TextArea.TryGetComponentSafe(out RectTransform textArea))
|
||||
{
|
||||
textArea.SetSmartAnchor(AnchorType.StretchAll);
|
||||
|
||||
inputField.textViewport = textArea;
|
||||
textArea.gameObject.TryAddComponent(out RectMask2D mask);
|
||||
}
|
||||
|
||||
if (ifm.Background.TryGetComponentSafe(out Graphic bg))
|
||||
{
|
||||
inputField.targetGraphic = bg;
|
||||
}
|
||||
|
||||
if (ifm.Placeholder.TryGetComponentSafe(out Graphic ph))
|
||||
{
|
||||
ph.gameObject.SetActive(true);
|
||||
inputField.placeholder = ph;
|
||||
}
|
||||
|
||||
if (ifm.TextComponent.TryGetComponentSafe(out TMP_Text text))
|
||||
{
|
||||
text.gameObject.SetActive(true);
|
||||
inputField.textComponent = text;
|
||||
text.enableAutoSizing = false;
|
||||
}
|
||||
|
||||
if (fobject.ContainsTag(FcuTag.PasswordField))
|
||||
{
|
||||
inputField.contentType = TMP_InputField.ContentType.Password;
|
||||
inputField.asteriskChar = FcuConfig.AsterisksChar;
|
||||
}
|
||||
else
|
||||
{
|
||||
inputField.contentType = TMP_InputField.ContentType.Standard;
|
||||
}
|
||||
|
||||
inputField.enabled = false;
|
||||
await Task.Delay(10);
|
||||
inputField.enabled = true;
|
||||
}
|
||||
#endif
|
||||
await Task.Yield();
|
||||
}
|
||||
|
||||
private InputFieldModel GetGraphics(SyncData syncData)
|
||||
{
|
||||
SyncHelper[] syncHelpers = syncData.GameObject.GetChilds<SyncHelper>();
|
||||
|
||||
InputFieldModel field = new InputFieldModel();
|
||||
|
||||
foreach (SyncHelper item in syncHelpers)
|
||||
{
|
||||
if (field.Background == null && item.ContainsTag(FcuTag.Background))
|
||||
{
|
||||
field.Background = item.gameObject;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (SyncHelper item in syncHelpers)
|
||||
{
|
||||
if (field.TextArea == null && item.name.IsInputTextArea())
|
||||
{
|
||||
field.TextArea = item.gameObject;
|
||||
}
|
||||
else if (field.TextComponent == null && item.ContainsTag(FcuTag.Text) && !item.ContainsTag(FcuTag.Placeholder))
|
||||
{
|
||||
field.TextComponent = item.gameObject;
|
||||
}
|
||||
else if (field.Placeholder == null && item.ContainsTag(FcuTag.Placeholder))
|
||||
{
|
||||
field.Placeholder = item.gameObject;
|
||||
}
|
||||
else if (field.Background == null && item.ContainsTag(FcuTag.Image))
|
||||
{
|
||||
field.Background = item.gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
return field;
|
||||
}
|
||||
}
|
||||
|
||||
internal struct InputFieldModel
|
||||
{
|
||||
public GameObject TextArea { get; set; }
|
||||
public GameObject Background { get; set; }
|
||||
public GameObject TextComponent { get; set; }
|
||||
public GameObject Placeholder { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b5d8b9bcd055684d83338dda9c978b2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b127fce6eca7fc4b81c02c334fc8a15
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.Logging;
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using Resources = UnityEngine.Resources;
|
||||
|
||||
#if DALOC_EXISTS
|
||||
using DA_Assets.DAL;
|
||||
#endif
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class DALocalizatorDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ConnectTable(string filePath)
|
||||
{
|
||||
if (monoBeh.Settings.LocalizationSettings.Localizator == null)
|
||||
{
|
||||
DALogger.LogError("Localizator is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
string fileNameNoExt = Path.GetFileNameWithoutExtension(filePath);
|
||||
|
||||
TextAsset localizationFile = Resources.Load<TextAsset>(fileNameNoExt);
|
||||
|
||||
if (localizationFile != null)
|
||||
{
|
||||
#if DALOC_EXISTS
|
||||
ILocalizator localizator = monoBeh.Settings.LocalizationSettings.Localizator as ILocalizator;
|
||||
localizator.TableConfigs[0].TextAsset = localizationFile;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Localization file could not be loaded!");
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(string locKey, FObject fobject)
|
||||
{
|
||||
#if DALOC_EXISTS
|
||||
if (monoBeh.UsingTextMesh())
|
||||
{
|
||||
fobject.Data.GameObject.TryAddComponent(out TextMeshLocalizator tmpText);
|
||||
tmpText.Key = locKey;
|
||||
}
|
||||
else if (monoBeh.UsingUnityText())
|
||||
{
|
||||
fobject.Data.GameObject.TryAddComponent(out UITextLocalizator uiTextLoc);
|
||||
uiTextLoc.Key = locKey;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 817223195a849f14a949d8f4f605a44f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,60 @@
|
||||
#if I2LOC_EXISTS && UNITY_EDITOR
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using I2.Loc;
|
||||
using System;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class I2LocalizationDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
[SerializeField] LanguageSource languageSource;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
if (languageSource == null)
|
||||
{
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
languageSource = MonoBehaviour.FindFirstObjectByType<LanguageSource>();
|
||||
#else
|
||||
languageSource = MonoBehaviour.FindObjectOfType<LanguageSource>();
|
||||
#endif
|
||||
|
||||
if (languageSource == null)
|
||||
{
|
||||
GameObject _gameObject = MonoBehExtensions.CreateEmptyGameObject();
|
||||
_gameObject.name = FcuConfig.Instance.I2LocGameObjectName;
|
||||
languageSource = _gameObject.AddComponent<LanguageSource>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ConnectTable(string filePath)
|
||||
{
|
||||
ImportCSV(filePath, eSpreadsheetUpdateMode.Replace);
|
||||
}
|
||||
|
||||
public void Draw(string locKey, FObject fobject)
|
||||
{
|
||||
fobject.Data.GameObject.TryAddComponent(out I2.Loc.Localize i2l);
|
||||
i2l.Source = languageSource;
|
||||
i2l.Term = locKey;
|
||||
}
|
||||
|
||||
private void ImportCSV(string FileName, eSpreadsheetUpdateMode updateMode)
|
||||
{
|
||||
languageSource.mSource.Import_CSV(
|
||||
"",
|
||||
LocalizationReader.ReadCSVfile(FileName, Encoding.UTF8),
|
||||
updateMode,
|
||||
(char)monoBeh.Settings.LocalizationSettings.CsvSeparator);
|
||||
|
||||
languageSource.mSource.Awake();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d4bcf421a605b347aef896367e53077
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,149 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
#if DALOC_EXISTS
|
||||
using DA_Assets.MiniExcelLibs;
|
||||
using DA_Assets.MiniExcelLibs.Csv;
|
||||
#endif
|
||||
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable IDE0003
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class LocalizationDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
private Dictionary<string, string> _localizationDictionary = new Dictionary<string, string>();
|
||||
public Dictionary<string, string> LocalizationDictionary => _localizationDictionary;
|
||||
|
||||
private string _filePath;
|
||||
public string FilePath => _filePath;
|
||||
|
||||
internal void Init()
|
||||
{
|
||||
_localizationDictionary.Clear();
|
||||
|
||||
string folderPath = Path.GetDirectoryName(monoBeh.Settings.LocalizationSettings.LocFolderPath);
|
||||
string fileName = Path.GetFileName(monoBeh.Settings.LocalizationSettings.LocFileName);
|
||||
|
||||
_filePath = Path.Combine(folderPath, fileName);
|
||||
|
||||
switch (monoBeh.Settings.LocalizationSettings.LocalizationComponent)
|
||||
{
|
||||
case LocalizationComponent.DALocalizator:
|
||||
this.DALocalizatorDrawer.Init();
|
||||
break;
|
||||
case LocalizationComponent.I2Localization:
|
||||
#if I2LOC_EXISTS && UNITY_EDITOR
|
||||
this.I2LocalizationDrawer.Init();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
|
||||
string locKey = fobject.Data.Names.LocKey;
|
||||
|
||||
if (locKey.IsEmpty())
|
||||
return;
|
||||
|
||||
string text = fobject.GetText();
|
||||
|
||||
if (text.IsEmpty())
|
||||
return;
|
||||
|
||||
_localizationDictionary.TryAddValue(locKey, text);
|
||||
|
||||
switch (monoBeh.Settings.LocalizationSettings.LocalizationComponent)
|
||||
{
|
||||
case LocalizationComponent.DALocalizator:
|
||||
this.DALocalizatorDrawer.Draw(locKey, fobject);
|
||||
break;
|
||||
case LocalizationComponent.I2Localization:
|
||||
#if I2LOC_EXISTS && UNITY_EDITOR
|
||||
this.I2LocalizationDrawer.Draw(locKey, fobject);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public string SaveTable()
|
||||
{
|
||||
DataTable dataTable = new DataTable();
|
||||
dataTable.Columns.Add("Key", typeof(string));
|
||||
dataTable.Columns.Add(monoBeh.Settings.LocalizationSettings.CurrentFigmaLayoutCulture, typeof(string));
|
||||
|
||||
foreach (var kvp in _localizationDictionary)
|
||||
{
|
||||
dataTable.Rows.Add(kvp.Key, kvp.Value);
|
||||
}
|
||||
|
||||
string folderPath = monoBeh.Settings.LocalizationSettings.LocFolderPath;
|
||||
string fileNameNoExt = Path.GetFileNameWithoutExtension(monoBeh.Settings.LocalizationSettings.LocFileName);
|
||||
string fileExt = Path.GetExtension(monoBeh.Settings.LocalizationSettings.LocFileName);
|
||||
|
||||
if (!Directory.Exists(folderPath))
|
||||
{
|
||||
Directory.CreateDirectory(folderPath);
|
||||
}
|
||||
|
||||
string[] files = Directory.GetFiles(folderPath, $"{fileNameNoExt}*{fileExt}");
|
||||
int fileCount = files.Length;
|
||||
string newFileName = $"{fileNameNoExt}-{fileCount + 1}{fileExt}";
|
||||
string filePath = Path.Combine(folderPath, newFileName);
|
||||
|
||||
#if DALOC_EXISTS
|
||||
CsvConfiguration config = new CsvConfiguration()
|
||||
{
|
||||
Seperator = (char)monoBeh.Settings.LocalizationSettings.CsvSeparator
|
||||
};
|
||||
|
||||
MiniExcel.SaveAs(filePath, dataTable, configuration: config);
|
||||
#endif
|
||||
#if UNITY_EDITOR
|
||||
AssetDatabase.Refresh();
|
||||
#endif
|
||||
return filePath;
|
||||
}
|
||||
|
||||
internal void ConnectTable(string filePath)
|
||||
{
|
||||
switch (monoBeh.Settings.LocalizationSettings.LocalizationComponent)
|
||||
{
|
||||
case LocalizationComponent.DALocalizator:
|
||||
{
|
||||
this.DALocalizatorDrawer.ConnectTable(filePath);
|
||||
}
|
||||
break;
|
||||
case LocalizationComponent.I2Localization:
|
||||
{
|
||||
#if I2LOC_EXISTS && UNITY_EDITOR
|
||||
this.I2LocalizationDrawer.ConnectTable(filePath);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if I2LOC_EXISTS && UNITY_EDITOR
|
||||
[SerializeField] I2LocalizationDrawer i2lDrawer;
|
||||
[SerializeProperty(nameof(i2lDrawer))]
|
||||
public I2LocalizationDrawer I2LocalizationDrawer => monoBeh.Link(ref i2lDrawer);
|
||||
#endif
|
||||
|
||||
[SerializeField] DALocalizatorDrawer dalDrawer;
|
||||
[SerializeProperty(nameof(dalDrawer))]
|
||||
public DALocalizatorDrawer DALocalizatorDrawer => monoBeh.Link(ref dalDrawer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4402ff8739520dc4988e5616ce325021
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,77 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class MaskDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
bool get = monoBeh.CurrentProject.TryGetByIndex(fobject.Data.ParentIndex, out FObject target);
|
||||
|
||||
if (get == false && fobject.ContainsTag(FcuTag.Frame) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject targetGo;
|
||||
|
||||
if (fobject.IsObjectMask())
|
||||
{
|
||||
targetGo = target.Data.GameObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetGo = fobject.Data.GameObject;
|
||||
|
||||
if (!fobject.ContainsTag(FcuTag.Container))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (fobject.IsFrameMask() || fobject.IsClipMask())
|
||||
{
|
||||
if (monoBeh.IsNova())
|
||||
{
|
||||
#if NOVA_UI_EXISTS
|
||||
targetGo.TryAddComponent(out Nova.ClipMask unityMask);
|
||||
#endif
|
||||
}
|
||||
else if (monoBeh.UseImageLinearMaterial())
|
||||
{
|
||||
targetGo.TryAddComponent(out Mask unityMask);
|
||||
}
|
||||
else if (!monoBeh.UsingSpriteRenderer())
|
||||
{
|
||||
targetGo.TryAddComponent(out RectMask2D unityMask);
|
||||
}
|
||||
}
|
||||
else if (fobject.IsObjectMask())
|
||||
{
|
||||
if (monoBeh.IsNova())
|
||||
{
|
||||
#if NOVA_UI_EXISTS
|
||||
targetGo.TryAddComponent(out Nova.ClipMask unityMask);
|
||||
Sprite sprite = monoBeh.SpriteProcessor.GetSprite(fobject);
|
||||
unityMask.Mask = sprite.texture;
|
||||
#endif
|
||||
}
|
||||
else if (!monoBeh.UsingSpriteRenderer())
|
||||
{
|
||||
monoBeh.CanvasDrawer.ImageDrawer.Draw(fobject, targetGo);
|
||||
targetGo.TryAddComponent(out Mask unityMask);
|
||||
unityMask.showMaskGraphic = false;
|
||||
}
|
||||
|
||||
fobject.Data.GameObject.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d156a90906bf8ae419390d93a9488cc1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,121 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class ScrollViewDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
private List<FObject> scrollViews;
|
||||
public List<FObject> ScrollViews => scrollViews;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
scrollViews = new List<FObject>();
|
||||
}
|
||||
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
fobject.Data.GameObject.TryAddComponent(out ScrollRect scrollRect);
|
||||
scrollViews.Add(fobject);
|
||||
}
|
||||
|
||||
public async Task SetTargetGraphics()
|
||||
{
|
||||
await SetTargetGraphicsScrollViews();
|
||||
scrollViews.Clear();
|
||||
}
|
||||
|
||||
private async Task SetTargetGraphicsScrollViews()
|
||||
{
|
||||
foreach (FObject scrollViewFObject in scrollViews)
|
||||
{
|
||||
if (!scrollViewFObject.Data.GameObject.TryGetComponentSafe(out ScrollRect scrollRect))
|
||||
continue;
|
||||
|
||||
ScrollViewModel svm = GetGraphics(scrollViewFObject.Data);
|
||||
|
||||
if (svm.Viewport.TryGetComponentSafe(out RectTransform viewport))
|
||||
{
|
||||
viewport.gameObject.TryAddComponent(out RectMask2D viewportMask2D);
|
||||
viewport.SetSmartAnchor(AnchorType.StretchAll);
|
||||
viewport.SetSmartPivot(PivotType.TopLeft);
|
||||
|
||||
viewport.TryGetComponent(out SyncHelper viewportSyncHelper);
|
||||
monoBeh.CurrentProject.TryGetById(viewportSyncHelper.Data.Id, out FObject viewportFObject);
|
||||
|
||||
scrollRect.viewport = viewport;
|
||||
|
||||
if (viewport != null)
|
||||
{
|
||||
switch (viewportFObject.OverflowDirection)
|
||||
{
|
||||
case OverflowDirection.HORIZONTAL_SCROLLING:
|
||||
scrollRect.horizontal = true;
|
||||
scrollRect.vertical = false;
|
||||
break;
|
||||
case OverflowDirection.VERTICAL_SCROLLING:
|
||||
scrollRect.horizontal = false;
|
||||
scrollRect.vertical = true;
|
||||
break;
|
||||
case OverflowDirection.HORIZONTAL_AND_VERTICAL_SCROLLING:
|
||||
scrollRect.horizontal = true;
|
||||
scrollRect.vertical = true;
|
||||
break;
|
||||
default:
|
||||
scrollRect.horizontal = false;
|
||||
scrollRect.vertical = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (svm.Content.TryGetComponentSafe(out RectTransform content))
|
||||
{
|
||||
content.gameObject.TryDestroyComponent<RectMask2D>();
|
||||
content.SetSmartAnchor(AnchorType.HorStretchTop);
|
||||
content.SetSmartPivot(PivotType.TopLeft);
|
||||
|
||||
scrollRect.content = content;
|
||||
}
|
||||
|
||||
scrollRect.enabled = false;
|
||||
await Task.Delay(10);
|
||||
scrollRect.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private ScrollViewModel GetGraphics(SyncData syncData)
|
||||
{
|
||||
SyncHelper[] syncHelpers = syncData.GameObject.GetChilds<SyncHelper>();
|
||||
|
||||
ScrollViewModel scroll = new ScrollViewModel();
|
||||
|
||||
foreach (SyncHelper item in syncHelpers)
|
||||
{
|
||||
if (scroll.Viewport == null && item.name.IsScrollViewport())
|
||||
{
|
||||
scroll.Viewport = item.gameObject;
|
||||
}
|
||||
else if (scroll.Content == null && item.name.IsScrollContent())
|
||||
{
|
||||
scroll.Content = item.gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
return scroll;
|
||||
}
|
||||
}
|
||||
|
||||
internal struct ScrollViewModel
|
||||
{
|
||||
public GameObject Viewport { get; set; }
|
||||
public GameObject Content { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 184502488b6bb674a83f53f37d61b715
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,141 @@
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
#if TRUESHADOW_EXISTS
|
||||
using LeTai.TrueShadow;
|
||||
#endif
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class ShadowDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
switch (monoBeh.Settings.ShadowSettings.ShadowComponent)
|
||||
{
|
||||
case ShadowComponent.TrueShadow:
|
||||
DrawTrueShadow(fobject);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawTrueShadow(FObject fobject)
|
||||
{
|
||||
#if TRUESHADOW_EXISTS
|
||||
TrueShadow[] oldShadows = fobject.Data.GameObject.GetComponents<TrueShadow>();
|
||||
|
||||
if (fobject.IsDownloadableType())
|
||||
{
|
||||
foreach (TrueShadow item in oldShadows)
|
||||
{
|
||||
item.enabled = false;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
IEnumerable<Effect> newShadows = fobject.Effects.Where(x => x.IsShadowType()).ToArray();
|
||||
|
||||
int newShadowCount = newShadows.Count();
|
||||
int oldShadowCount = oldShadows.Length;
|
||||
|
||||
FcuLogger.Debug($"DrawTrueShadow | {fobject.Data.NameHierarchy} | newShadowCount: {newShadowCount} | oldShadowCount: {oldShadowCount}", FcuLogType.ComponentDrawer);
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (TrueShadow oldShadow in oldShadows)
|
||||
{
|
||||
if (i < newShadowCount)
|
||||
{
|
||||
AssignShadowEffect(oldShadow, newShadows.ElementAt(i));
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldShadow.Destroy(); // Remove unnecessary TrueShadows.
|
||||
}
|
||||
}
|
||||
|
||||
// If shadows are more than oldShadows - add new TrueShadows.
|
||||
for (; i < newShadowCount; i++)
|
||||
{
|
||||
fobject.Data.GameObject.TryAddGraphic(out Image img);
|
||||
fobject.Data.GameObject.TryAddComponent(out TrueShadow trueShadow, supportMultiInstance: true);
|
||||
|
||||
if (!fobject.ContainsTag(FcuTag.Image) && !fobject.ContainsTag(FcuTag.Text))
|
||||
{
|
||||
fobject.Data.GameObject.TryGetComponentSafe(out Graphic gr);
|
||||
gr.enabled = false;
|
||||
}
|
||||
|
||||
|
||||
AssignShadowEffect(trueShadow, newShadows.ElementAt(i));
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TRUESHADOW_EXISTS
|
||||
void AssignShadowEffect(TrueShadow trueShadow, Effect effect)
|
||||
{
|
||||
ShadowData shadowData = GetShadowData(effect);
|
||||
|
||||
trueShadow.OffsetAngle = shadowData.Angle;
|
||||
trueShadow.OffsetDistance = shadowData.Distance;
|
||||
trueShadow.Spread = shadowData.Spread;
|
||||
trueShadow.Color = shadowData.Color;
|
||||
trueShadow.Size = shadowData.Radius;
|
||||
|
||||
trueShadow.BlendMode = BlendMode.Multiply;
|
||||
|
||||
if (effect.Type.ToString().Contains("DROP"))
|
||||
trueShadow.Inset = false;
|
||||
else
|
||||
trueShadow.Inset = true;
|
||||
|
||||
trueShadow.enabled = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
internal ShadowData GetShadowData(Effect effect)
|
||||
{
|
||||
ShadowData shadowData = new ShadowData();
|
||||
shadowData.Offset = effect.Offset;
|
||||
shadowData.EffectType = effect.Type;
|
||||
|
||||
float x = effect.Offset.x;
|
||||
float y = effect.Offset.y;
|
||||
|
||||
float angle = Mathf.Atan2(y, x) * (180.0f / Mathf.PI);
|
||||
float distance = Mathf.Sqrt(x * x + y * y);
|
||||
|
||||
shadowData.Angle = angle;
|
||||
shadowData.Distance = distance;
|
||||
shadowData.Spread = effect.Spread.ToFloat();
|
||||
|
||||
shadowData.Color = effect.Color;
|
||||
shadowData.Radius = effect.Radius;
|
||||
|
||||
return shadowData;
|
||||
}
|
||||
}
|
||||
|
||||
internal struct ShadowData
|
||||
{
|
||||
public EffectType EffectType { get; set; }
|
||||
public Vector2 Offset { get; set; }
|
||||
public float Angle { get; set; }
|
||||
public float Distance { get; set; }
|
||||
public float Spread { get; set; }
|
||||
public Color Color { get; set; }
|
||||
public float Radius { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 936eaea9f88f06a4d8e153270bc0a0b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94d4a2077a978b74aa5bca75e1c2bef9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class TextDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
[SerializeField] List<FObject> texts;
|
||||
public List<FObject> Texts => texts;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
texts = new List<FObject>();
|
||||
}
|
||||
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
if (fobject.Data.GameObject.IsPartOfAnyPrefab() == false)
|
||||
{
|
||||
if (fobject.Data.GameObject.TryGetComponentSafe(out Graphic oldGraphic))
|
||||
{
|
||||
Type curType = monoBeh.GetCurrentTextType();
|
||||
|
||||
if (oldGraphic.GetType().Equals(curType) == false)
|
||||
{
|
||||
//TODO
|
||||
//oldGraphic.RemoveComponentsDependingOn();
|
||||
oldGraphic.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (monoBeh.IsNova())
|
||||
{
|
||||
this.TextMeshDrawer.DrawNovaTMP(fobject);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (monoBeh.Settings.TextFontsSettings.TextComponent)
|
||||
{
|
||||
case TextComponent.TextMeshPro:
|
||||
this.TextMeshDrawer.DrawTMP(fobject);
|
||||
break;
|
||||
case TextComponent.RTLTextMeshPro:
|
||||
this.TextMeshDrawer.DrawRTL(fobject);
|
||||
break;
|
||||
case TextComponent.UnityText:
|
||||
this.UnityTextDrawer.Draw(fobject);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
texts.Add(fobject);
|
||||
}
|
||||
|
||||
[SerializeField] UnityTextDrawer unityTextDrawer;
|
||||
[SerializeProperty(nameof(unityTextDrawer))]
|
||||
public UnityTextDrawer UnityTextDrawer => monoBeh.Link(ref unityTextDrawer);
|
||||
|
||||
[SerializeField] TextMeshDrawer textMeshDrawer;
|
||||
[SerializeProperty(nameof(textMeshDrawer))]
|
||||
public TextMeshDrawer TextMeshDrawer => monoBeh.Link(ref textMeshDrawer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a065f90017f34554fb5e83387cdfe07d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,292 @@
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
#if TextMeshPro && RTLTMP_EXISTS
|
||||
using RTLTMPro;
|
||||
#endif
|
||||
|
||||
#if TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
#if NOVA_UI_EXISTS
|
||||
using Nova.TMP;
|
||||
#endif
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class TextMeshDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
[SerializeField] List<FObject> texts;
|
||||
public List<FObject> Texts => texts;
|
||||
|
||||
public void DrawRTL(FObject fobject)
|
||||
{
|
||||
#if TextMeshPro && RTLTMP_EXISTS
|
||||
fobject.Data.GameObject.TryAddGraphic(out RTLTextMeshPro text);
|
||||
|
||||
text.Farsi = monoBeh.Settings.TextMeshSettings.Farsi;
|
||||
text.ForceFix = monoBeh.Settings.TextMeshSettings.ForceFix;
|
||||
text.PreserveNumbers = monoBeh.Settings.TextMeshSettings.PreserveNumbers;
|
||||
text.FixTags = monoBeh.Settings.TextMeshSettings.FixTags;
|
||||
|
||||
Draw(fobject, text);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void DrawTMP(FObject fobject)
|
||||
{
|
||||
#if TextMeshPro
|
||||
TMP_Text text;
|
||||
|
||||
fobject.Data.GameObject.TryAddGraphic(out TextMeshProUGUI uguiText);
|
||||
text = uguiText;
|
||||
|
||||
Draw(fobject, text);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void DrawNovaTMP(FObject fobject)
|
||||
{
|
||||
#if TextMeshPro && NOVA_UI_EXISTS
|
||||
TMP_Text text;
|
||||
|
||||
fobject.Data.GameObject.TryAddGraphic(out TextMeshProTextBlock novaText);
|
||||
text = novaText;
|
||||
|
||||
Draw(fobject, text);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TextMeshPro
|
||||
private void Draw(FObject fobject, TMP_Text text)
|
||||
{
|
||||
string str = fobject.GetText();
|
||||
|
||||
text.text = str;
|
||||
|
||||
text.overrideColorTags = monoBeh.Settings.TextMeshSettings.OverrideTags;
|
||||
text.enableAutoSizing = monoBeh.Settings.TextMeshSettings.AutoSize;
|
||||
|
||||
#if UNITY_2023_1_OR_NEWER
|
||||
if (monoBeh.Settings.TextMeshSettings.Wrapping)
|
||||
{
|
||||
text.textWrappingMode = TextWrappingModes.Normal;
|
||||
}
|
||||
else
|
||||
{
|
||||
text.textWrappingMode = TextWrappingModes.NoWrap;
|
||||
}
|
||||
#else
|
||||
text.enableWordWrapping = monoBeh.Settings.TextMeshSettings.Wrapping;
|
||||
#endif
|
||||
|
||||
if (monoBeh.IsNova())
|
||||
{
|
||||
text.isOrthographic = monoBeh.Settings.TextMeshSettings.OrthographicMode;
|
||||
}
|
||||
|
||||
text.richText = monoBeh.Settings.TextMeshSettings.RichText;
|
||||
text.raycastTarget = monoBeh.Settings.TextMeshSettings.RaycastTarget;
|
||||
text.parseCtrlCharacters = monoBeh.Settings.TextMeshSettings.ParseEscapeCharacters;
|
||||
text.useMaxVisibleDescender = monoBeh.Settings.TextMeshSettings.VisibleDescender;
|
||||
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
var fontFeatures = new List<UnityEngine.TextCore.OTL_FeatureTag>();
|
||||
if (monoBeh.Settings.TextMeshSettings.Kerning)
|
||||
{
|
||||
fontFeatures.Add(UnityEngine.TextCore.OTL_FeatureTag.kern);
|
||||
}
|
||||
text.fontFeatures = fontFeatures;
|
||||
#elif UNITY_2023_4_OR_NEWER == false
|
||||
text.enableKerning = monoBeh.Settings.TextMeshSettings.Kerning;
|
||||
#endif
|
||||
|
||||
text.extraPadding = monoBeh.Settings.TextMeshSettings.ExtraPadding;
|
||||
text.horizontalMapping = monoBeh.Settings.TextMeshSettings.HorizontalMapping;
|
||||
text.verticalMapping = monoBeh.Settings.TextMeshSettings.VerticalMapping;
|
||||
text.geometrySortingOrder = monoBeh.Settings.TextMeshSettings.GeometrySorting;
|
||||
|
||||
if (monoBeh.Settings.TextMeshSettings.Shader != null)
|
||||
{
|
||||
text.fontMaterial.shader = monoBeh.Settings.TextMeshSettings.Shader;
|
||||
}
|
||||
|
||||
SetFont(text, fobject);
|
||||
|
||||
text.alignment = fobject.GetTextAnchor().ToTextMeshAnchor();
|
||||
|
||||
SetFontSize(text, fobject);
|
||||
SetFontCase(text, fobject);
|
||||
SetOverflowMode(text, fobject);
|
||||
SetColor(text, fobject);
|
||||
}
|
||||
|
||||
private const float _sizeFixForNonOrthographicNovaText = 10f;
|
||||
|
||||
private void SetFontSize(TMP_Text text, FObject fobject)
|
||||
{
|
||||
if (monoBeh.Settings.TextMeshSettings.AutoSize)
|
||||
{
|
||||
text.fontSizeMin = 1;
|
||||
text.fontSizeMax = fobject.Style.FontSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
text.fontSize = fobject.Style.FontSize;
|
||||
}
|
||||
|
||||
if (monoBeh.IsNova())
|
||||
{
|
||||
if (monoBeh.Settings.TextMeshSettings.OrthographicMode == false)
|
||||
{
|
||||
text.fontSize *= _sizeFixForNonOrthographicNovaText;
|
||||
}
|
||||
}
|
||||
|
||||
if (monoBeh.Settings.TextFontsSettings.OverrideLetterSpacing)
|
||||
{
|
||||
if (!fobject.Style.FontFamily.IsEmpty())
|
||||
{
|
||||
float textMeshProLetterSpacing = fobject.Style.LetterSpacing / text.fontSize * 100;
|
||||
text.characterSpacing = textMeshProLetterSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
if (monoBeh.Settings.TextFontsSettings.OverrideLineSpacingPx)
|
||||
{
|
||||
if (!fobject.Style.FontFamily.IsEmpty())
|
||||
{
|
||||
text.lineSpacing = ((fobject.Style.LineHeightPx - fobject.Style.FontSize) / fobject.Style.FontSize) * 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetFont(TMP_Text text, FObject fobject)
|
||||
{
|
||||
TMP_FontAsset font = monoBeh.FontLoader.GetFontFromArray(fobject, monoBeh.FontLoader.TmpFonts);
|
||||
text.font = font;
|
||||
}
|
||||
|
||||
private void SetFontCase(TMP_Text text, FObject fobject)
|
||||
{
|
||||
FontStyles textDecoration = FontStyles.Normal;
|
||||
FontStyles textCase = FontStyles.Normal;
|
||||
FontStyles textItalic = FontStyles.Normal;
|
||||
FontStyles textBold = FontStyles.Normal;
|
||||
|
||||
if (fobject.Data.HasFontAsset == false)
|
||||
{
|
||||
if (fobject.Style.Italic.ToBoolNullFalse())
|
||||
{
|
||||
textItalic = FontStyles.Italic;
|
||||
}
|
||||
|
||||
if (fobject.Style.FontWeight > 600)
|
||||
{
|
||||
textBold = FontStyles.Bold;
|
||||
}
|
||||
}
|
||||
|
||||
switch (fobject.Style.TextDecoration)
|
||||
{
|
||||
case "UNDERLINE":
|
||||
textDecoration = FontStyles.Underline;
|
||||
break;
|
||||
case "STRIKETHROUGH":
|
||||
textDecoration = FontStyles.Strikethrough;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (fobject.Style.TextCase)
|
||||
{
|
||||
case "UPPER":
|
||||
textCase = FontStyles.UpperCase;
|
||||
break;
|
||||
case "LOWER":
|
||||
textCase = FontStyles.LowerCase;
|
||||
break;
|
||||
case "TITLE":
|
||||
textCase = FontStyles.Normal;
|
||||
break;
|
||||
case "SMALL_CAPS":
|
||||
textCase = FontStyles.SmallCaps;
|
||||
break;
|
||||
}
|
||||
|
||||
FontStyles final = textDecoration | textCase | textItalic | textBold;
|
||||
|
||||
text.fontStyle = final;
|
||||
}
|
||||
|
||||
private void SetOverflowMode(TMP_Text text, FObject fobject)
|
||||
{
|
||||
TextOverflowModes textTurncate = monoBeh.Settings.TextMeshSettings.Overflow;
|
||||
|
||||
if (fobject.Style.TextAutoResize.IsEmpty() == false)
|
||||
{
|
||||
switch (fobject.Style.TextCase)
|
||||
{
|
||||
case "ENDING":
|
||||
textTurncate = TextOverflowModes.Ellipsis;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
text.overflowMode = textTurncate;
|
||||
}
|
||||
|
||||
private void SetColor(TMP_Text text, FObject fobject)
|
||||
{
|
||||
FGraphic graphic = fobject.Data.Graphic;
|
||||
|
||||
text.enableVertexGradient = false;
|
||||
|
||||
if (graphic.Fill.HasSolid)
|
||||
{
|
||||
text.color = graphic.Fill.SolidPaint.Color;
|
||||
}
|
||||
else if (graphic.Fill.HasGradient)
|
||||
{
|
||||
List<GradientColorKey> gradientColorKeys = graphic.Fill.GradientPaint.ToGradientColorKeys();
|
||||
|
||||
if (!gradientColorKeys.IsEmpty())
|
||||
{
|
||||
text.color = gradientColorKeys.First().color;
|
||||
}
|
||||
}
|
||||
|
||||
if (graphic.HasStroke && fobject.StrokeAlign == StrokeAlign.INSIDE)
|
||||
{
|
||||
float normalizedWidth = fobject.StrokeWeight / text.preferredHeight;
|
||||
text.outlineWidth = normalizedWidth;
|
||||
|
||||
if (graphic.Stroke.HasSolid)
|
||||
{
|
||||
text.outlineColor = graphic.Stroke.SolidPaint.Color;
|
||||
}
|
||||
else if (graphic.Stroke.HasGradient)
|
||||
{
|
||||
List<GradientColorKey> gradientColorKeys = graphic.Stroke.GradientPaint.ToGradientColorKeys();
|
||||
|
||||
if (!gradientColorKeys.IsEmpty())
|
||||
{
|
||||
text.outlineColor = gradientColorKeys.First().color;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
text.outlineWidth = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81b17a04539814846b18cdde3e55a1be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,61 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class UnityTextDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public Text Draw(FObject fobject)
|
||||
{
|
||||
fobject.Data.GameObject.TryAddGraphic(out Text text);
|
||||
|
||||
SetStyle(text, fobject);
|
||||
SetFont(text, fobject);
|
||||
|
||||
text.fontStyle = fobject.GetFontWeight();
|
||||
text.alignment = fobject.GetTextAnchor();
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
private void SetFont(Text text, FObject fobject)
|
||||
{
|
||||
Font font = monoBeh.FontLoader.GetFontFromArray(fobject, monoBeh.FontLoader.TtfFonts);
|
||||
text.font = font;
|
||||
}
|
||||
|
||||
private void SetStyle(Text text, FObject fobject)
|
||||
{
|
||||
text.resizeTextForBestFit = monoBeh.Settings.UnityTextSettings.BestFit;
|
||||
text.text = fobject.GetText();
|
||||
text.resizeTextMinSize = 1;
|
||||
|
||||
text.resizeTextMaxSize = Convert.ToInt32(fobject.Style.FontSize);
|
||||
text.fontSize = Convert.ToInt32(fobject.Style.FontSize);
|
||||
|
||||
text.verticalOverflow = monoBeh.Settings.UnityTextSettings.VerticalWrapMode;
|
||||
text.horizontalOverflow = monoBeh.Settings.UnityTextSettings.HorizontalWrapMode;
|
||||
text.lineSpacing = monoBeh.Settings.UnityTextSettings.FontLineSpacing;
|
||||
|
||||
FGraphic graphic = fobject.Data.Graphic;
|
||||
|
||||
if (graphic.HasFill)
|
||||
{
|
||||
if (graphic.Fill.HasGradient)
|
||||
{
|
||||
text.color = graphic.Fill.GradientPaint.Color;
|
||||
}
|
||||
else
|
||||
{
|
||||
text.color = graphic.Fill.SolidPaint.Color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2900e9dc8b36a644ca0064209fb1f0de
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,119 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers.CanvasDrawers
|
||||
{
|
||||
[Serializable]
|
||||
public class ToggleDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
private List<FObject> toggles;
|
||||
public List<FObject> Toggles => toggles;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
toggles = new List<FObject>();
|
||||
}
|
||||
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
if (fobject.ContainsTag(FcuTag.Toggle))
|
||||
{
|
||||
fobject.Data.GameObject.TryAddComponent(out Toggle toggle);
|
||||
toggles.Add(fobject);
|
||||
}
|
||||
else if (fobject.ContainsTag(FcuTag.ToggleGroup))
|
||||
{
|
||||
fobject.Data.GameObject.TryAddComponent(out ToggleGroup toggleGroup);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SetTargetGraphics()
|
||||
{
|
||||
foreach (FObject fobject in toggles)
|
||||
{
|
||||
if (!fobject.Data.GameObject.TryGetComponentSafe(out Toggle toggle))
|
||||
continue;
|
||||
|
||||
ToggleModel tm = GetGraphics(fobject.Data);
|
||||
|
||||
if (tm.Checkmark.TryGetComponentSafe(out Graphic checkmark))
|
||||
{
|
||||
toggle.graphic = checkmark;
|
||||
}
|
||||
|
||||
if (tm.Background.TryGetComponentSafe(out Graphic bg))
|
||||
{
|
||||
toggle.targetGraphic = bg;
|
||||
}
|
||||
|
||||
if (tm.ToggleGroup.TryGetComponentSafe(out ToggleGroup group))
|
||||
{
|
||||
toggle.group = group;
|
||||
}
|
||||
|
||||
toggle.enabled = false;
|
||||
await Task.Delay(10);
|
||||
toggle.enabled = true;
|
||||
}
|
||||
|
||||
toggles.Clear();
|
||||
}
|
||||
|
||||
private ToggleModel GetGraphics(SyncData syncData)
|
||||
{
|
||||
SyncHelper[] childs = syncData.GameObject.GetChilds<SyncHelper>();
|
||||
List<Transform> parents = syncData.GameObject.transform.GetAllParents();
|
||||
|
||||
ToggleModel toggle = new ToggleModel();
|
||||
|
||||
foreach (SyncHelper child in childs)
|
||||
{
|
||||
if (toggle.Background == null && child.ContainsTag(FcuTag.Background))
|
||||
{
|
||||
toggle.Background = child.gameObject;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Transform item in parents)
|
||||
{
|
||||
if (!item.TryGetComponentSafe(out SyncHelper parentSyncHelper))
|
||||
continue;
|
||||
|
||||
if (parentSyncHelper.ContainsTag(FcuTag.ToggleGroup))
|
||||
{
|
||||
toggle.ToggleGroup = item.gameObject;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (SyncHelper item in childs)
|
||||
{
|
||||
if (toggle.Checkmark == null && item.name.IsCheckmark())
|
||||
{
|
||||
toggle.Checkmark = item.gameObject;
|
||||
}
|
||||
else if (toggle.Background == null && item.ContainsTag(FcuTag.Image))
|
||||
{
|
||||
toggle.Background = item.gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
return toggle;
|
||||
}
|
||||
}
|
||||
|
||||
internal struct ToggleModel
|
||||
{
|
||||
public GameObject Checkmark { get; set; }
|
||||
public GameObject Background { get; set; }
|
||||
public GameObject ToggleGroup { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f449ccb0912cf1d4399c64c925e5aa27
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,412 @@
|
||||
using DA_Assets.FCU.Drawers.CanvasDrawers;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Threading.Tasks;
|
||||
using DA_Assets.Logging;
|
||||
|
||||
#if TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
#pragma warning disable IDE0003
|
||||
|
||||
namespace DA_Assets.FCU.Drawers
|
||||
{
|
||||
[Serializable]
|
||||
public class CanvasDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public async Task DrawToCanvas(List<FObject> fobjects)
|
||||
{
|
||||
monoBeh.AssetTools.SelectFcu();
|
||||
|
||||
this.TextDrawer.Init();
|
||||
this.ButtonDrawer.Init();
|
||||
this.ToggleDrawer.Init();
|
||||
this.InputFieldDrawer.Init();
|
||||
this.ScrollViewDrawer.Init();
|
||||
this.LocalizationDrawer.Init();
|
||||
|
||||
await DrawComponents(fobjects, DrawByTag);
|
||||
|
||||
await this.ButtonDrawer.SetTargetGraphics();
|
||||
await this.ToggleDrawer.SetTargetGraphics();
|
||||
await this.InputFieldDrawer.SetTargetGraphics();
|
||||
await this.ScrollViewDrawer.SetTargetGraphics();
|
||||
|
||||
string filePath = this.LocalizationDrawer.SaveTable();
|
||||
this.LocalizationDrawer.ConnectTable(filePath);
|
||||
|
||||
await FixAutolayoutMargins(fobjects);
|
||||
}
|
||||
|
||||
private async Task DrawByTag(FObject fobject, FcuTag tag, Action onDraw)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (fobject.Data.GameObject == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case FcuTag.Shadow:
|
||||
this.ShadowDrawer.Draw(fobject);
|
||||
break;
|
||||
case FcuTag.AutoLayoutGroup:
|
||||
this.AutoLayoutDrawer.Draw(fobject);
|
||||
break;
|
||||
case FcuTag.ContentSizeFitter:
|
||||
this.ContentSizeFitterDrawer.Draw(fobject);
|
||||
break;
|
||||
case FcuTag.AspectRatioFitter:
|
||||
this.AspectRatioFitterDrawer.Draw(fobject);
|
||||
break;
|
||||
case FcuTag.InputField:
|
||||
case FcuTag.PasswordField:
|
||||
this.InputFieldDrawer.Draw(fobject);
|
||||
break;
|
||||
case FcuTag.ScrollView:
|
||||
this.ScrollViewDrawer.Draw(fobject);
|
||||
break;
|
||||
case FcuTag.Toggle:
|
||||
case FcuTag.ToggleGroup:
|
||||
this.ToggleDrawer.Draw(fobject);
|
||||
break;
|
||||
case FcuTag.Button:
|
||||
this.ButtonDrawer.Draw(fobject);
|
||||
break;
|
||||
case FcuTag.Mask:
|
||||
this.MaskDrawer.Draw(fobject);
|
||||
break;
|
||||
case FcuTag.CanvasGroup:
|
||||
this.CanvasGroupDrawer.Draw(fobject);
|
||||
break;
|
||||
case FcuTag.Placeholder:
|
||||
case FcuTag.Text:
|
||||
this.TextDrawer.Draw(fobject);
|
||||
this.LocalizationDrawer.Draw(fobject);
|
||||
break;
|
||||
case FcuTag.Image:
|
||||
this.ImageDrawer.Draw(fobject);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DALogger.LogError(FcuLocKey.log_cant_draw_object.Localize(fobject.Data.NameHierarchy));
|
||||
Debug.LogException(ex);
|
||||
}
|
||||
|
||||
onDraw.Invoke();
|
||||
await Task.Yield();
|
||||
}
|
||||
|
||||
public async Task FixSpriteRenderers(List<FObject> fobjects)
|
||||
{
|
||||
List<Transform> frames = monoBeh.transform.GetTopLevelChilds();
|
||||
|
||||
int maxOrder = 32767;
|
||||
|
||||
foreach (Transform frame in frames)
|
||||
{
|
||||
int initialOrder = 0;
|
||||
SetOrderInLayerRecursively(frame, ref initialOrder);
|
||||
}
|
||||
|
||||
void SetOrderInLayerRecursively(Transform trans, ref int order)
|
||||
{
|
||||
SpriteRenderer spriteRenderer = trans.GetComponent<SpriteRenderer>();
|
||||
if (spriteRenderer != null)
|
||||
{
|
||||
spriteRenderer.sortingOrder = order;
|
||||
order += monoBeh.Settings.SpriteRendererSettings.NextOrderStep;
|
||||
if (order > maxOrder)
|
||||
{
|
||||
order = maxOrder;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < trans.childCount; i++)
|
||||
{
|
||||
SetOrderInLayerRecursively(trans.GetChild(i), ref order);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (FObject fobject in fobjects)
|
||||
{
|
||||
if (fobject.Data.GameObject == null)
|
||||
continue;
|
||||
|
||||
if (!fobject.ContainsTag(FcuTag.Image))
|
||||
continue;
|
||||
|
||||
if (!fobject.Data.GameObject.TryGetComponentSafe(out SpriteRenderer _))
|
||||
continue;
|
||||
|
||||
fobject.Data.GameObject.SetActive(false);
|
||||
await Task.Delay(10);
|
||||
fobject.Data.GameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task FixDttImages(List<FObject> fobjects)
|
||||
{
|
||||
foreach (FObject fobject in fobjects)
|
||||
{
|
||||
if (fobject.Data.GameObject == null)
|
||||
continue;
|
||||
|
||||
if (!fobject.ContainsTag(FcuTag.Image))
|
||||
continue;
|
||||
|
||||
#if PROCEDURAL_UI_ASSET_STORE_RELEASE
|
||||
if (!fobject.Data.GameObject.TryGetComponentSafe(out DTT.UI.ProceduralUI.GradientEffect _))
|
||||
continue;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.Selection.activeGameObject = fobject.Data.GameObject;
|
||||
#endif
|
||||
await Task.Delay(100);
|
||||
#endif
|
||||
}
|
||||
|
||||
monoBeh.AssetTools.SelectFcu();
|
||||
Scene activeScene = SceneManager.GetActiveScene();
|
||||
activeScene.SetExpanded(false);
|
||||
await Task.Yield();
|
||||
}
|
||||
|
||||
private async Task FixAutolayoutMargins(List<FObject> fobjects)
|
||||
{
|
||||
foreach (FObject fobject in fobjects)
|
||||
{
|
||||
if (fobject.Data.GameObject == null)
|
||||
continue;
|
||||
|
||||
HorizontalOrVerticalLayoutGroup layoutGroup;
|
||||
|
||||
if (monoBeh.CurrentProject.TryGetByIndex(fobject.Data.ParentIndex, out FObject parent))
|
||||
{
|
||||
if (!parent.IsInsideAutoLayout(out layoutGroup))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int leftp = layoutGroup.padding.left;
|
||||
int rightp = layoutGroup.padding.right;
|
||||
|
||||
float newX = fobject.Size.x;
|
||||
float newY = fobject.Size.y;
|
||||
|
||||
float parentSize = parent.Data.Size.x;
|
||||
|
||||
if (leftp + rightp + newX > parentSize)
|
||||
{
|
||||
float excess = (leftp + rightp + newX) - parentSize;
|
||||
float totalPadding = leftp + rightp;
|
||||
|
||||
float leftFactor = leftp / totalPadding;
|
||||
float rightFactor = rightp / totalPadding;
|
||||
|
||||
int newLeft = leftp - (int)Math.Floor(excess * leftFactor);
|
||||
int newRight = rightp - (int)Math.Floor(excess * rightFactor);
|
||||
|
||||
if (newLeft > 0 && newRight > 0)
|
||||
{
|
||||
layoutGroup.padding.left = newLeft;
|
||||
layoutGroup.padding.right = newRight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await Task.Yield();
|
||||
}
|
||||
|
||||
private async Task FixTextSizes(List<FObject> fobjects)
|
||||
{
|
||||
foreach (FObject fobject in fobjects)
|
||||
{
|
||||
if (!fobject.ContainsTag(FcuTag.Text))
|
||||
continue;
|
||||
|
||||
if (fobject.Data.GameObject == null)
|
||||
continue;
|
||||
|
||||
RectTransform rt = fobject.Data.GameObject.GetComponent<RectTransform>();
|
||||
|
||||
Vector2 rectSize = new Vector2(rt.rect.width, rt.rect.height);
|
||||
Vector2 m = new Vector2((fobject.Size.x - rectSize.x) / 2f, (fobject.Size.y - rectSize.y) / 2f);
|
||||
|
||||
Vector4 marginV4 = new Vector4();
|
||||
|
||||
if (fobject.Size.y > rectSize.y && fobject.Size.x > rectSize.x)
|
||||
{
|
||||
marginV4 = new Vector4(m.x, m.y, m.x, m.y);
|
||||
}
|
||||
else if (fobject.Size.y > rectSize.y)
|
||||
{
|
||||
marginV4 = new Vector4(0, m.y, 0, m.y);
|
||||
}
|
||||
else if (fobject.Size.x > rectSize.x)
|
||||
{
|
||||
marginV4 = new Vector4(m.x, 0, m.x, 0);
|
||||
}
|
||||
|
||||
#if TextMeshPro
|
||||
if (fobject.Data.GameObject.TryGetComponentSafe(out TMP_Text text))
|
||||
text.margin = marginV4;
|
||||
#endif
|
||||
}
|
||||
|
||||
await Task.Yield();
|
||||
}
|
||||
|
||||
public async Task DrawComponents(List<FObject> fobjects, DrawByTag drawByTag)
|
||||
{
|
||||
Array fcuTags = Enum.GetValues(typeof(FcuTag));
|
||||
|
||||
foreach (FcuTag tag in fcuTags)
|
||||
{
|
||||
if (tag.GetTagConfig().HasComponent == false)
|
||||
continue;
|
||||
|
||||
int drawnObjectsCount = 0;
|
||||
int objectsToDrawCount = monoBeh.TagSetter.TagsCounter[tag];
|
||||
|
||||
if (objectsToDrawCount < 1)
|
||||
continue;
|
||||
|
||||
_ = DACycles.ForEach(fobjects, fobject =>
|
||||
{
|
||||
if (fobject.ContainsTag(tag) == false)
|
||||
return;
|
||||
|
||||
Action onDraw = () =>
|
||||
{
|
||||
drawnObjectsCount++;
|
||||
monoBeh.Events.OnAddComponent?.Invoke(monoBeh, fobject.Data, tag);
|
||||
};
|
||||
|
||||
_ = drawByTag(fobject, tag, onDraw);
|
||||
|
||||
}, 0.01f, 150);
|
||||
|
||||
int tempCount = -1;
|
||||
while (FcuLogger.WriteLogBeforeEqual(
|
||||
ref drawnObjectsCount,
|
||||
ref objectsToDrawCount,
|
||||
FcuLocKey.log_drawn_count.Localize($"{tag}", drawnObjectsCount, objectsToDrawCount),
|
||||
ref tempCount))
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: add referenceResolution
|
||||
public void AddCanvasComponent()
|
||||
{
|
||||
monoBeh.gameObject.TryAddComponent(out Canvas c);
|
||||
c.renderMode = RenderMode.ScreenSpaceOverlay;
|
||||
|
||||
if (monoBeh.gameObject.TryGetComponentSafe(out CanvasScaler cs))
|
||||
cs.enabled = false;
|
||||
|
||||
monoBeh.gameObject.TryAddComponent(out GraphicRaycaster gr);
|
||||
|
||||
if (MonoBehExtensions.IsExistsOnScene<EventSystem>() == false)
|
||||
{
|
||||
GameObject go = MonoBehExtensions.CreateEmptyGameObject();
|
||||
go.AddComponent<EventSystem>();
|
||||
go.AddComponent<StandaloneInputModule>();
|
||||
go.name = nameof(EventSystem);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task FixJoshPui()
|
||||
{
|
||||
List<Transform> frames = monoBeh.transform.GetTopLevelChilds();
|
||||
|
||||
foreach (Transform frame in frames)
|
||||
{
|
||||
frame.gameObject.SetActive(false);
|
||||
await Task.Delay(100);
|
||||
frame.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] ImageDrawer imageDrawer;
|
||||
[SerializeProperty(nameof(imageDrawer))]
|
||||
public ImageDrawer ImageDrawer => monoBeh.Link(ref imageDrawer);
|
||||
|
||||
[SerializeField] TextDrawer textDrawer;
|
||||
[SerializeProperty(nameof(textDrawer))]
|
||||
public TextDrawer TextDrawer => monoBeh.Link(ref textDrawer);
|
||||
|
||||
[SerializeField] AutoLayoutDrawer autoLayoutDrawer;
|
||||
[SerializeProperty(nameof(autoLayoutDrawer))]
|
||||
public AutoLayoutDrawer AutoLayoutDrawer => monoBeh.Link(ref autoLayoutDrawer);
|
||||
|
||||
[SerializeField] ContentSizeFitterDrawer contentSizeFitterDrawer;
|
||||
[SerializeProperty(nameof(contentSizeFitterDrawer))]
|
||||
public ContentSizeFitterDrawer ContentSizeFitterDrawer => monoBeh.Link(ref contentSizeFitterDrawer);
|
||||
|
||||
[SerializeField] AspectRatioFitterDrawer aspectRatioFitterDrawer;
|
||||
[SerializeProperty(nameof(aspectRatioFitterDrawer))]
|
||||
public AspectRatioFitterDrawer AspectRatioFitterDrawer => monoBeh.Link(ref aspectRatioFitterDrawer);
|
||||
|
||||
[SerializeField] MaskDrawer maskDrawer;
|
||||
[SerializeProperty(nameof(maskDrawer))]
|
||||
public MaskDrawer MaskDrawer => monoBeh.Link(ref maskDrawer);
|
||||
|
||||
[SerializeField] ToggleDrawer toggleDrawer;
|
||||
[SerializeProperty(nameof(toggleDrawer))]
|
||||
public ToggleDrawer ToggleDrawer => monoBeh.Link(ref toggleDrawer);
|
||||
|
||||
[SerializeField] ButtonDrawer buttonDrawer;
|
||||
[SerializeProperty(nameof(buttonDrawer))]
|
||||
public ButtonDrawer ButtonDrawer => monoBeh.Link(ref buttonDrawer);
|
||||
|
||||
[SerializeField] ScriptGenerator scriptGenerator;
|
||||
[SerializeProperty(nameof(scriptGenerator))]
|
||||
public ScriptGenerator ScriptGenerator => monoBeh.Link(ref scriptGenerator);
|
||||
|
||||
[SerializeField] InputFieldDrawer inputFieldDrawer;
|
||||
[SerializeProperty(nameof(inputFieldDrawer))]
|
||||
public InputFieldDrawer InputFieldDrawer => monoBeh.Link(ref inputFieldDrawer);
|
||||
|
||||
[SerializeField] ScrollViewDrawer scrollViewDrawer;
|
||||
[SerializeProperty(nameof(scrollViewDrawer))]
|
||||
public ScrollViewDrawer ScrollViewDrawer => monoBeh.Link(ref scrollViewDrawer);
|
||||
|
||||
[SerializeField] LocalizationDrawer localizationDrawer;
|
||||
[SerializeProperty(nameof(localizationDrawer))]
|
||||
public LocalizationDrawer LocalizationDrawer => monoBeh.Link(ref localizationDrawer);
|
||||
|
||||
[SerializeField] ShadowDrawer shadowDrawer;
|
||||
[SerializeProperty(nameof(shadowDrawer))]
|
||||
public ShadowDrawer ShadowDrawer => monoBeh.Link(ref shadowDrawer);
|
||||
|
||||
[SerializeField] CanvasGroupDrawer canvasGroupDrawer;
|
||||
[SerializeProperty(nameof(canvasGroupDrawer))]
|
||||
public CanvasGroupDrawer CanvasGroupDrawer => monoBeh.Link(ref canvasGroupDrawer);
|
||||
|
||||
[SerializeField] GameObjectDrawer gameObjectDrawer;
|
||||
[SerializeProperty(nameof(gameObjectDrawer))]
|
||||
public GameObjectDrawer GameObjectDrawer => monoBeh.Link(ref gameObjectDrawer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd6c9e8e57177a746803379c925c002e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,112 @@
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers
|
||||
{
|
||||
[Serializable]
|
||||
public class InspectorDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
//maxDepth = 2, because [Project (0) > Page (1) > Frame (2)]
|
||||
public SelectableFObject FillSelectableFramesArray(FObject document, int maxDepth = 2)
|
||||
{
|
||||
_selectableHambItems.Clear();
|
||||
|
||||
SelectableFObject doc = new SelectableFObject();
|
||||
|
||||
FillNewSelectableItemRecursively(doc, document, 0, maxDepth);
|
||||
|
||||
bool same = CompareIdsRecursively(_document, doc);
|
||||
|
||||
if (!same)
|
||||
{
|
||||
_document = doc;
|
||||
_document.SetAllSelected(true);
|
||||
}
|
||||
|
||||
monoBeh.DelegateHolder.UpdateScrollContent();
|
||||
|
||||
return _document;
|
||||
}
|
||||
|
||||
|
||||
public void FillNewSelectableItemRecursively(SelectableFObject parentItem, FObject parent, int currentDepth, int maxDepth)
|
||||
{
|
||||
if (currentDepth > maxDepth)
|
||||
return;
|
||||
|
||||
parentItem.Id = parent.Id;
|
||||
parentItem.Type = parent.Type;
|
||||
parentItem.Name = parent.Name;
|
||||
|
||||
if (parent.Children.IsEmpty())
|
||||
return;
|
||||
|
||||
foreach (FObject child in parent.Children)
|
||||
{
|
||||
bool isAllowed = IsAllowed(child, parent);
|
||||
|
||||
if (!isAllowed)
|
||||
continue;
|
||||
|
||||
SelectableFObject childItem = new SelectableFObject();
|
||||
FillNewSelectableItemRecursively(childItem, child, currentDepth + 1, maxDepth);
|
||||
parentItem.Childs.Add(childItem);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsAllowed(FObject fobject, FObject parent)
|
||||
{
|
||||
monoBeh.TagSetter.GetManualTag(fobject, out FcuTag manualTag);
|
||||
|
||||
if (manualTag == FcuTag.Ignore)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!fobject.IsVisible())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fobject.Type == NodeType.CANVAS)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (parent.Type == NodeType.CANVAS)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool CompareIdsRecursively(SelectableFObject item1, SelectableFObject item2)
|
||||
{
|
||||
if (item1.Id != item2.Id)
|
||||
return false;
|
||||
|
||||
if (item1.Childs.Count != item2.Childs.Count)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < item1.Childs.Count; i++)
|
||||
{
|
||||
if (!CompareIdsRecursively(item1.Childs[i], item2.Childs[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[SerializeField] List<HamburgerItem> _selectableHambItems = new List<HamburgerItem>();
|
||||
public List<HamburgerItem> SelectableHamburgerItems => _selectableHambItems;
|
||||
|
||||
[SerializeField] SelectableFObject _document = new SelectableFObject();
|
||||
public SelectableFObject SelectableDocument => _document;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 974323b9c19b7264fb27f055b44e6c94
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba7a81d72660baf4a89ed2d2b833a86c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,79 @@
|
||||
#if NOVA_UI_EXISTS
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.FCU.Model;
|
||||
using Nova;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers
|
||||
{
|
||||
[Serializable]
|
||||
public class NovaAutoLayoutDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
#if false
|
||||
fobject.Data.GameObject.TryGetComponentSafe(out UIBlock2D uIBlock2D);
|
||||
|
||||
AutoLayout autoLayout = new AutoLayout();
|
||||
|
||||
TextAnchor childAlignment = TextAnchor.UpperLeft;
|
||||
|
||||
if (fobject.LayoutWrap == LayoutWrap.WRAP)
|
||||
{
|
||||
return;
|
||||
//this.GridLayoutDrawer.Draw(fobject);
|
||||
}
|
||||
else if (fobject.LayoutMode == LayoutMode.HORIZONTAL)
|
||||
{
|
||||
autoLayout.Axis = Axis.X;
|
||||
childAlignment = fobject.GetHorLayoutAnchor();
|
||||
}
|
||||
else if (fobject.LayoutMode == LayoutMode.VERTICAL)
|
||||
{
|
||||
autoLayout.Axis = Axis.Y;
|
||||
childAlignment = fobject.GetVertLayoutAnchor();
|
||||
}
|
||||
|
||||
SetAligment(childAlignment, ref autoLayout);
|
||||
|
||||
autoLayout.SpacingMinMax = new MinMax(-Mathf.Infinity, Mathf.Infinity);
|
||||
|
||||
if (fobject.PrimaryAxisAlignItems == PrimaryAxisAlignItem.SPACE_BETWEEN ||
|
||||
fobject.CounterAxisAlignItems == CounterAxisAlignItem.SPACE_BETWEEN)
|
||||
{
|
||||
autoLayout.Spacing = 0f;
|
||||
autoLayout.AutoSpace = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
autoLayout.AutoSpace = false;
|
||||
autoLayout.Spacing = fobject.GetHorSpacing();
|
||||
}
|
||||
|
||||
uIBlock2D.AutoLayout = autoLayout;
|
||||
#endif
|
||||
}
|
||||
|
||||
private void SetAligment(TextAnchor childAlignment, ref AutoLayout autoLayout)
|
||||
{
|
||||
int al = -1;
|
||||
|
||||
switch (childAlignment)
|
||||
{
|
||||
case TextAnchor.MiddleLeft:
|
||||
al = -1;
|
||||
break;
|
||||
case TextAnchor.MiddleCenter:
|
||||
al = 0;
|
||||
break;
|
||||
case TextAnchor.MiddleRight:
|
||||
al = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
autoLayout.Alignment = al;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26d12169f24447e45a7f1b508b16073e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,58 @@
|
||||
#if NOVA_UI_EXISTS
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.FCU.Model;
|
||||
using NovaSamples.Effects;
|
||||
using System;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers
|
||||
{
|
||||
[Serializable]
|
||||
public class NovaBlurDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
#if false
|
||||
fobject.Data.GameObject.TryGetComponentSafe(out UIBlock2D uIBlock2D);
|
||||
|
||||
foreach (Effect effect in fobject.Effects)
|
||||
{
|
||||
if (!effect.Type.ToString().Contains("BLUR"))
|
||||
continue;
|
||||
|
||||
fobject.Data.GameObject.TryAddComponent(out BlurEffect blurEffect);
|
||||
|
||||
blurEffect.BlurMode = ConvertBlurType(effect.Type);
|
||||
|
||||
float radius = effect.Radius;
|
||||
blurEffect.BlurRadius = radius;
|
||||
blurEffect.InputTexture = monoBeh.Settings.NovaSettings.InputTexture;
|
||||
|
||||
if (monoBeh.TryGetComponentSafe(out BackgroundBlurGroup blurGroup))
|
||||
{
|
||||
blurGroup.BlurEffects.Add(blurEffect);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private BlurMode ConvertBlurType(EffectType effectType)
|
||||
{
|
||||
switch (effectType)
|
||||
{
|
||||
case EffectType.LAYER_BLUR:
|
||||
{
|
||||
return BlurMode.LayerBlur;
|
||||
}
|
||||
case EffectType.BACKGROUND_BLUR:
|
||||
{
|
||||
return BlurMode.BackgroundBlur;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return BlurMode.LayerBlur;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 545f5e3a3e5be9d45b34ac9442dd5015
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,251 @@
|
||||
#if NOVA_UI_EXISTS
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using DA_Assets.Logging;
|
||||
using Nova;
|
||||
using NovaSamples.UIControls;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers
|
||||
{
|
||||
[Serializable]
|
||||
public class NovaButtonDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
fobject.Data.GameObject.TryGetComponentSafe(out UIBlock2D uIBlock2D);
|
||||
fobject.Data.GameObject.TryAddComponent(out Button btn);
|
||||
fobject.Data.GameObject.TryAddComponent(out Interactable interactable);
|
||||
fobject.Data.GameObject.TryAddComponent(out ItemView itemView);
|
||||
|
||||
Type itemViewType = typeof(ItemView);
|
||||
|
||||
string fieldName = "visuals";
|
||||
|
||||
FieldInfo visualsField = itemViewType.GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
ButtonVisuals newVisuals = new ButtonVisuals();
|
||||
|
||||
if (visualsField != null)
|
||||
{
|
||||
visualsField.SetValue(itemView, newVisuals);
|
||||
}
|
||||
else
|
||||
{
|
||||
DALogger.LogError($"{fieldName} not found in '{itemViewType.Name}'");
|
||||
}
|
||||
|
||||
SetupNovaButton(fobject, newVisuals);
|
||||
}
|
||||
|
||||
public void SetupNovaButton(FObject fobject, ButtonVisuals btn)
|
||||
{
|
||||
monoBeh.CanvasDrawer.ButtonDrawer.UnityButtonDrawer.SetupSelectable(fobject.Data, out SyncHelper[] btnChilds, out bool hasCustomButtonBackgrounds);
|
||||
|
||||
if (hasCustomButtonBackgrounds)
|
||||
{
|
||||
SetCustomTargetGraphics(btnChilds, btn);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDefaultTargetGraphic(fobject, btnChilds, btn);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDefaultTargetGraphic(FObject fobject, SyncHelper[] syncHelpers, ButtonVisuals btnVisuals)
|
||||
{
|
||||
UIBlock gr1 = null;
|
||||
bool exists = !syncHelpers.IsEmpty() && syncHelpers.First().TryGetComponentSafe(out gr1);
|
||||
|
||||
//If the first element of the hierarchy can be used as a target graphic.
|
||||
if (exists)
|
||||
{
|
||||
btnVisuals.TransitionTarget = gr1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//If there is at least some image, assign it to the targetGraphic.
|
||||
foreach (SyncHelper meta in syncHelpers)
|
||||
{
|
||||
if (meta.TryGetComponentSafe(out UIBlock2D gr2))
|
||||
{
|
||||
btnVisuals.TransitionTarget = gr2;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//If there is at least some graphic, assign it to the targetGraphic.
|
||||
foreach (SyncHelper meta in syncHelpers)
|
||||
{
|
||||
if (meta.TryGetComponentSafe(out UIBlock gr3))
|
||||
{
|
||||
btnVisuals.TransitionTarget = gr3;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//If there is a graphic on the button itself, assign it to the targetGraphic.
|
||||
if (fobject.Data.GameObject.TryGetComponentSafe(out UIBlock gr4))
|
||||
{
|
||||
btnVisuals.TransitionTarget = gr4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCustomTargetGraphics(SyncHelper[] syncHelpers, ButtonVisuals btn)
|
||||
{
|
||||
foreach (SyncHelper syncHelper in syncHelpers)
|
||||
{
|
||||
if (syncHelper.ContainsTag(FcuTag.Image))
|
||||
{
|
||||
if (btn.TransitionType == TransitionType.SpriteSwap)
|
||||
{
|
||||
SetSprite(btn, syncHelper);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetImageColor(syncHelper, btn);
|
||||
}
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.Text))
|
||||
{
|
||||
SetText(syncHelper, btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSprite(ButtonVisuals selectable, SyncHelper syncHelper)
|
||||
{
|
||||
selectable.TransitionType = TransitionType.SpriteSwap;
|
||||
SpriteStates spriteState = selectable.Sprites;
|
||||
|
||||
if (syncHelper.ContainsTag(FcuTag.BtnDefault))
|
||||
{
|
||||
if (syncHelper.TryGetComponentSafe(out UIBlock2D graphic))
|
||||
{
|
||||
selectable.TransitionTarget = graphic;
|
||||
spriteState.DefaultSprite = graphic.Sprite;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (syncHelper.TryGetComponentSafe(out UIBlock2D img))
|
||||
{
|
||||
if (syncHelper.ContainsTag(FcuTag.BtnPressed))
|
||||
{
|
||||
spriteState.PressedSprite = img.Sprite;
|
||||
DisableBody(syncHelper.gameObject);
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnHover))
|
||||
{
|
||||
spriteState.HoveredSprite = img.Sprite;
|
||||
DisableBody(syncHelper.gameObject);
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnSelected))
|
||||
{
|
||||
DisableBody(syncHelper.gameObject);
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnDisabled))
|
||||
{
|
||||
DisableBody(syncHelper.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
selectable.Sprites = spriteState;
|
||||
}
|
||||
|
||||
public void SetImageColor(SyncHelper syncHelper, ButtonVisuals selectable)
|
||||
{
|
||||
selectable.TransitionType = TransitionType.ColorChange;
|
||||
|
||||
if (syncHelper.TryGetComponentSafe(out UIBlock graphic))
|
||||
{
|
||||
if (syncHelper.ContainsTag(FcuTag.BtnDefault))
|
||||
{
|
||||
selectable.TransitionTarget = graphic;
|
||||
selectable.DefaultColor = graphic.Color;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (syncHelper.ContainsTag(FcuTag.BtnPressed))
|
||||
{
|
||||
selectable.PressedColor = graphic.Color;
|
||||
DisableBody(syncHelper.gameObject);
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnHover))
|
||||
{
|
||||
selectable.HoveredColor = graphic.Color;
|
||||
DisableBody(syncHelper.gameObject);
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnSelected))
|
||||
{
|
||||
DisableBody(syncHelper.gameObject);
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnDisabled))
|
||||
{
|
||||
DisableBody(syncHelper.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetText(SyncHelper syncHelper, ButtonVisuals btn)
|
||||
{
|
||||
if (syncHelper.TryGetComponentSafe(out TextBlock textBlock))
|
||||
{
|
||||
if (syncHelper.ContainsTag(FcuTag.BtnDefault))
|
||||
{
|
||||
btn.Label = textBlock;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (syncHelper.ContainsTag(FcuTag.BtnPressed))
|
||||
{
|
||||
DisableText(syncHelper.gameObject);
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnHover))
|
||||
{
|
||||
DisableText(syncHelper.gameObject);
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnSelected))
|
||||
{
|
||||
DisableText(syncHelper.gameObject);
|
||||
}
|
||||
else if (syncHelper.ContainsTag(FcuTag.BtnDisabled))
|
||||
{
|
||||
DisableText(syncHelper.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DisableBody(GameObject go)
|
||||
{
|
||||
if (go.TryGetComponentSafe(out UIBlock2D uiBlock2D))
|
||||
{
|
||||
uiBlock2D.BodyEnabled = false;
|
||||
}
|
||||
|
||||
//TODO: crash when destroying Nova component.
|
||||
//go.Destroy();
|
||||
}
|
||||
|
||||
private void DisableText(GameObject go)
|
||||
{
|
||||
if (go.TryGetComponentSafe(out TextBlock textBlock))
|
||||
{
|
||||
textBlock.Text = "";
|
||||
}
|
||||
|
||||
//TODO: crash when destroying Nova component.
|
||||
//go.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbe2f3e7ea93fda48947d678287b5ced
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,122 @@
|
||||
#if NOVA_UI_EXISTS
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using Nova;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers
|
||||
{
|
||||
[Serializable]
|
||||
public class NovaImageDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject, Sprite sprite, GameObject target)
|
||||
{
|
||||
target.TryGetComponentSafe(out UIBlock2D uIBlock2D);
|
||||
|
||||
uIBlock2D.SetImage(sprite);
|
||||
|
||||
if (fobject.ContainsTag(FcuTag.Slice9))
|
||||
{
|
||||
uIBlock2D.ImageAdjustment = new ImageAdjustment
|
||||
{
|
||||
ScaleMode = ImageScaleMode.Sliced
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
uIBlock2D.ImageAdjustment = new ImageAdjustment
|
||||
{
|
||||
ScaleMode = ImageScaleMode.Fit
|
||||
};
|
||||
}
|
||||
|
||||
if (fobject.IsDrawableType())
|
||||
{
|
||||
SetCorners(fobject, uIBlock2D);
|
||||
}
|
||||
|
||||
SetColor(fobject, uIBlock2D);
|
||||
}
|
||||
|
||||
private BorderDirection ConvertStrokeType(StrokeAlign strokeAlign)
|
||||
{
|
||||
switch (strokeAlign)
|
||||
{
|
||||
case StrokeAlign.INSIDE:
|
||||
return BorderDirection.In;
|
||||
case StrokeAlign.OUTSIDE:
|
||||
return BorderDirection.Out;
|
||||
case StrokeAlign.CENTER:
|
||||
return BorderDirection.Center;
|
||||
default:
|
||||
return BorderDirection.Out;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetColor(FObject fobject, UIBlock2D sr)
|
||||
{
|
||||
FGraphic graphic = fobject.Data.Graphic;
|
||||
|
||||
FcuLogger.Debug($"SetUnityImageColor | {fobject.Data.NameHierarchy} | {fobject.Data.FcuImageType} | graphic.HasFills: {graphic.HasFill} | graphic.HasStrokes: {graphic.HasStroke}", FcuLogType.ComponentDrawer);
|
||||
|
||||
if (fobject.IsDrawableType() || fobject.IsGenerativeType())
|
||||
{
|
||||
if (graphic.HasFill)
|
||||
{
|
||||
sr.Color = graphic.Fill.SingleColor;
|
||||
}
|
||||
|
||||
if (sr.Sprite != null && sr.Color == default)
|
||||
{
|
||||
sr.Color = Color.white;
|
||||
}
|
||||
|
||||
if (graphic.HasStroke && !fobject.IsGenerativeType())
|
||||
{
|
||||
Color strokeColor = graphic.Stroke.SingleColor;
|
||||
|
||||
sr.Border = new Border
|
||||
{
|
||||
Enabled = true,
|
||||
Color = strokeColor,
|
||||
Width = fobject.StrokeWeight,
|
||||
Direction = ConvertStrokeType(fobject.StrokeAlign)
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
sr.Border = new Border
|
||||
{
|
||||
Enabled = false
|
||||
};
|
||||
}
|
||||
}
|
||||
else if (fobject.IsDownloadableType())
|
||||
{
|
||||
if (fobject.Data.Graphic.SpriteSingleColor.IsDefault() == false)
|
||||
{
|
||||
sr.Color = fobject.Data.Graphic.SpriteSingleColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
sr.Color = Color.white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCorners(FObject fobject, UIBlock2D img)
|
||||
{
|
||||
Vector4 cr = monoBeh.GraphicHelpers.GetCornerRadius(fobject);
|
||||
|
||||
img.CornerRadius = new Length
|
||||
{
|
||||
Type = LengthType.Value,
|
||||
Value = cr.x
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8376d43d30f6874a9b26e4c8aecf5c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,61 @@
|
||||
#if NOVA_UI_EXISTS
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Drawers.CanvasDrawers;
|
||||
using DA_Assets.FCU.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using Nova;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DA_Assets.FCU.Drawers
|
||||
{
|
||||
[Serializable]
|
||||
public class NovaShadowDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public void Draw(FObject fobject)
|
||||
{
|
||||
if (fobject.IsDownloadableType())
|
||||
return;
|
||||
|
||||
if (!fobject.Data.GameObject.TryGetComponentSafe(out UIBlock2D uIBlock2D))
|
||||
return;
|
||||
|
||||
if (fobject.Effects.IsEmpty())
|
||||
return;
|
||||
|
||||
var visibleShadows = fobject.Effects.Where(x => x.IsVisible());
|
||||
|
||||
if (visibleShadows.IsEmpty())
|
||||
return;
|
||||
|
||||
var shadowDatas = visibleShadows.Select(x => monoBeh.CanvasDrawer.ShadowDrawer.GetShadowData(x));
|
||||
|
||||
ShadowData highestAlphaShadow = shadowDatas.OrderByDescending(x => x.Color.a).First();
|
||||
AddShadow(uIBlock2D, highestAlphaShadow);
|
||||
}
|
||||
|
||||
private void AddShadow(UIBlock2D uIBlock2D, ShadowData shadowData)
|
||||
{
|
||||
Shadow s = new Shadow();
|
||||
s.Enabled = true;
|
||||
|
||||
if (shadowData.EffectType == EffectType.DROP_SHADOW)
|
||||
{
|
||||
s.Direction = ShadowDirection.Out;
|
||||
}
|
||||
else
|
||||
{
|
||||
s.Direction = ShadowDirection.In;
|
||||
}
|
||||
|
||||
s.Color = shadowData.Color;
|
||||
s.Blur = shadowData.Radius;
|
||||
s.Width = shadowData.Spread;
|
||||
s.Offset = new Length2(shadowData.Offset.x, -shadowData.Offset.y);
|
||||
|
||||
uIBlock2D.Shadow = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a5e9f364a32e444b950cf1171c819c4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,150 @@
|
||||
#if NOVA_UI_EXISTS
|
||||
using DA_Assets.DAI;
|
||||
using DA_Assets.Extensions;
|
||||
using DA_Assets.FCU.Model;
|
||||
using Nova;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
#pragma warning disable IDE0003
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace DA_Assets.FCU.Drawers
|
||||
{
|
||||
[Serializable]
|
||||
public class NovaDrawer : MonoBehaviourLinkerRuntime<FigmaConverterUnity>
|
||||
{
|
||||
public async Task DrawToScene(List<FObject> fobjects)
|
||||
{
|
||||
monoBeh.AssetTools.SelectFcu();
|
||||
|
||||
monoBeh.CanvasDrawer.TextDrawer.Init();
|
||||
await monoBeh.CanvasDrawer.DrawComponents(fobjects, DrawByTag);
|
||||
}
|
||||
|
||||
private async Task DrawByTag(FObject fobject, FcuTag tag, Action onDraw)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (fobject.Data.GameObject == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case FcuTag.Blur:
|
||||
this.NovaBlurDrawer.Draw(fobject);
|
||||
break;
|
||||
|
||||
case FcuTag.Shadow:
|
||||
this.NovaShadowDrawer.Draw(fobject);
|
||||
break;
|
||||
|
||||
case FcuTag.AutoLayoutGroup:
|
||||
this.NovaAutoLayoutDrawer.Draw(fobject);
|
||||
break;
|
||||
|
||||
case FcuTag.ContentSizeFitter:
|
||||
|
||||
break;
|
||||
|
||||
case FcuTag.AspectRatioFitter:
|
||||
|
||||
break;
|
||||
|
||||
case FcuTag.InputField:
|
||||
|
||||
break;
|
||||
|
||||
case FcuTag.Button:
|
||||
this.NovaButtonDrawer.Draw(fobject);
|
||||
break;
|
||||
|
||||
case FcuTag.Mask:
|
||||
monoBeh.CanvasDrawer.MaskDrawer.Draw(fobject);
|
||||
break;
|
||||
|
||||
case FcuTag.CanvasGroup:
|
||||
|
||||
break;
|
||||
|
||||
case FcuTag.Placeholder:
|
||||
case FcuTag.Text:
|
||||
monoBeh.CanvasDrawer.TextDrawer.Draw(fobject);
|
||||
monoBeh.CanvasDrawer.LocalizationDrawer.Draw(fobject);
|
||||
break;
|
||||
|
||||
case FcuTag.Image:
|
||||
monoBeh.CanvasDrawer.ImageDrawer.Draw(fobject);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogException(ex);
|
||||
}
|
||||
|
||||
onDraw.Invoke();
|
||||
await Task.Yield();
|
||||
}
|
||||
|
||||
internal void SetupSpace()
|
||||
{
|
||||
#if false
|
||||
if (monoBeh.TryGetComponentSafe(out Canvas canvas))
|
||||
{
|
||||
canvas.RemoveComponentsDependingOn();
|
||||
canvas.Destroy();
|
||||
}
|
||||
|
||||
if (monoBeh.TagSetter.TagsCounter.TryGetValue(FcuTag.Blur, out int blurCount))
|
||||
{
|
||||
if (blurCount > 0)
|
||||
{
|
||||
Camera mc = CameraTools.GetOrCreateMainCamera();
|
||||
Camera bgbc = CameraTools.GetOrCreateBackgroundBlurCamera();
|
||||
|
||||
monoBeh.gameObject.TryAddComponent(out BackgroundBlurGroup blurGroup);
|
||||
blurGroup.PropertyMatchCamera = mc;
|
||||
blurGroup.BackgroundCamera = bgbc;
|
||||
|
||||
blurGroup.BlurEffects = blurGroup.BlurEffects.Where(x => x != null).ToList();
|
||||
|
||||
monoBeh.gameObject.TryAddComponent(out ScreenSpace screenSpace);
|
||||
screenSpace.TargetCamera = mc;
|
||||
screenSpace.enabled = false;
|
||||
screenSpace.AddAdditionalCamera(bgbc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
internal void EnableScreenSpaceComponent()
|
||||
{
|
||||
if (monoBeh.gameObject.TryGetComponentSafe(out ScreenSpace screenSpace))
|
||||
{
|
||||
screenSpace.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] NovaButtonDrawer novaButtonDrawer;
|
||||
[SerializeProperty(nameof(novaButtonDrawer))]
|
||||
public NovaButtonDrawer NovaButtonDrawer => monoBeh.Link(ref novaButtonDrawer);
|
||||
|
||||
[SerializeField] NovaShadowDrawer novaShadowDrawer;
|
||||
[SerializeProperty(nameof(novaShadowDrawer))]
|
||||
public NovaShadowDrawer NovaShadowDrawer => monoBeh.Link(ref novaShadowDrawer);
|
||||
|
||||
[SerializeField] NovaBlurDrawer novaBlurDrawer;
|
||||
[SerializeProperty(nameof(novaBlurDrawer))]
|
||||
public NovaBlurDrawer NovaBlurDrawer => monoBeh.Link(ref novaBlurDrawer);
|
||||
|
||||
[SerializeField] NovaAutoLayoutDrawer novaAutoLayoutDrawer;
|
||||
[SerializeProperty(nameof(novaAutoLayoutDrawer))]
|
||||
public NovaAutoLayoutDrawer NovaAutoLayoutDrawer => monoBeh.Link(ref novaAutoLayoutDrawer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10cc1bea77caee14796c3749aab14a81
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user