delight-dev / delight Goto Github PK
View Code? Open in Web Editor NEWDelight is an open source component-oriented framework for Unity.
Home Page: https://delight-dev.github.io/
License: MIT License
Delight is an open source component-oriented framework for Unity.
Home Page: https://delight-dev.github.io/
License: MIT License
In the XML, I tried "#ffffffde" but it seems to ignore the first two characters and sets the "de" to the B component.
On a close note, are there any way to declare colours to then reuse them by name? That would be very helpful.
Thanks in advance! Love your framework!
Implement tooltips in the Delight Designer. Hovering over names of views and properties in the XML editor should show the docs/comment associated with the element.
Should RectTransform.offsetMax actually read like this instead?
RectTransform.offsetMax = new Vector2( offsetMaxX + margin.Left.Pixels - margin.Right.Pixels + offset.Left.Pixels - offset.Right.Pixels + offsetFromParent.Left.Pixels - offsetFromParent.Right.Pixels, offsetMaxY + margin.Bottom.Pixels - margin.Top.Pixels - offset.Top.Pixels + offset.Bottom.Pixels - offsetFromParent.Top.Pixels + offsetFromParent.Bottom.Pixels);
As in, adding margin.Left.Pixels and margin.Bottom.Pixels, otherwise setting a left margin on a rect with a fixed size within a group shrinks it instead of moving to the right.
Example:
<Group Id="MainMenu" Alignment="Left" Orientation="Horizontal" Width="300" Height="100%"> <Region Id="Meme" BackgroundColor="Red" Width="10" Height="100%" Alignment="Left" Margin="105,0,0,0"/> </Group>
The below modified version of ModelBindingText:
<ModelBindingTest xmlns="Delight" BasedOn="LayoutRoot" SomeParentProperty="t:string">
<Group Orientation="Horizontal">
<Group Spacing="10" Width="500">
<Button Text="Test 1" Click="Test1" />
<Button Text="Test 2" Click="Test2" />
</Group>
<List Id="PlayerList" Items="{player in @Players}" Width="650" BackgroundColor="Green"
Spacing="5">
<Group BackgroundColor="Blue">
<Label Text="{player.Name}" />
<List Id="AchievementsList" Items="{achievement in player.Achievements}"
Orientation="Vertical" Offset="50,0,0,0" Width="300">
<Label Text="{achievement.Title}" />
</List>
</Group>
<!-- No error but does not generate elements -->
<Group BackgroundColor="Red" Offset="350,0,0,0" Width="300">
<List Id="HighscoreList" Items="{highscore in player.Highscores}"
Orientation="Vertical" Offset="50,0,0,0">
<Label Text="{highscore.ScoreText}" />
</List>
</Group>
</List>
</Group>
</ModelBindingTest>
Implement keyboard shortcut F12 to jump to view under caret in Delight designer, and F10 to toggle back and forth between the previously open views.
When I use the Rotation property, the input is supposed to take a Quaternion as an argument, but it takes 3 arguments. Also, when I type in a Vector3, it is converted into Quaternion before it is transferred into Euler angles again.
Here is an example:
<Button Rotation="90,0,0" />
turns into:
Delight.Button.RotationProperty.SetDefault(_mainMenuViewScrollUpButton, Quaternion.Euler(0.7071068f, 0f, 0f));
So the input is getting converted along the way somewhere. Quaternion.Euler(90,0,0,0)
returns Quaternion(0.7071068f, 0 , 0 , 0.7071068f).
, which is already the input here but also takes into account the first three variables.
Hi,
I'm currently trying to understand whether we can use Delight together with Unity Addressables. I guess we can't add completely new views (as it requires the code generation in Unity Editor to run), but could it work for styles? Is there a way to dynamically load a style definition (from remote) and apply it to (all) views?
Thx for any hints! BR
Bug with data templates for derived views. E.g. NavigationButton sets NavigationButtonLabel template, but it's based on LabelTemplates.Label template, rather than ButtonTemplates.ButtonLabel (see NavigationButton_g.cs (108). See CodeGenerator.cs (788):
// initialize and instantiate template instance
The consequence of this bug is that all views that inherit from other views that has XML content - the content won't get their default values set.
If I want to use a Unity UI prefab in XML, how should I use it?
I have this code in xml, which is a list item within a list:
<ListItem Style="NoAnimListItemStyle">
<Label Style="CardListHeaderStyle" Text="{@Loc[h_other]}" />
</ListItem>
Code generation does not parse it correctly and throws an error in UnityEditor:
Assets\Content\Views\SettingsView_g.cs(284,267): error CS0103: The name 'h_other' does not exist in the current context
What is generated is this line:
// binding <Label Text="{@Loc[h_other]}">
listItem9.Bindings.Add(new Binding(new List<BindingPath> { new BindingPath(new List<string> { }, new List<Func<object>> { }) }, new BindingPath(new List<string> { "Text" }, new List<Func<object>> { () => label11 }), () => label11.Text = Models.Loc[h_other], () => { }, false));
What it should look like is this:
// binding <Label Text="{@Loc[h_other]}">
listItem9.Bindings.Add(new Binding(new List<BindingPath> { new BindingPath(new List<string> { "[h_other]", "Label" }, new List<Func<object>> { () => Models.Loc, () => Models.Loc["[h_other]"] }) }, new BindingPath(new List<string> { "Text" }, new List<Func<object>> { () => label11 }), () => label11.Text = Models.Loc["[h_other]"], () => { }, false));
Seen on Unity 2020.3.15f2, Windows 11. This is especially frustrating because even if I manually fix them, when there is a change in the parent UI the generation also resets and throws these errors again.
This Issue took some time to understand and to find cause each try the process stopped working ๐
System: Win10 - 20H2
Unity: 2020.3.17f1
Delight: current store version
When using this example view
<NewView AdjustToParent="Stretch" MyBool="t:Boolean"
BasedOn="LayoutRoot">
<Grid AdjustToParent="Stretch">
<Group Spacing="10" Alignment="BottomLeft"
BackgroundColor="Green" Orientation="Horizontal">
<Group Spacing="10" Alignment="TopLeft"
IsVisible="$ {MyBool} != false " >
<Group Orientation="Horizontal">
<Label Text="Test: {MyBool}" />
</Group>
</Group>
</Group>
</Grid>
</NewView>
This or other embedded C# Codes seems to break the process of creating the script files:
IsVisible="$ {MyBool} != false "
Reproduce:
Be in the designer, change anything in the view file
Save and stop the running "game"
You'll see something like this in the Console Log:
Copying assembly from 'Temp/Assembly-CSharp.dll' to 'Library/ScriptAssemblies/Assembly-CSharp.dll' failed. Detailed error: Sharing violation on path
Unfocus Unity, and refocus it
Nothing happens when you don't have the embedded C# code then it all "just works"
Implement state animations.
Implement AutoComplete functionality to the Delight Designer. Support autocompleting:
Could it be possible to add Layout Groups and Layout Elements as components to some custom views, and setting their properties using XML? And extend some default views to have Layout Elements properties (like Buttons)? I'm think in an API something like
<VerticalGroup forceExpandWidth="false">
<Button flexibleHeight="1" />
<Button flexibleHeight="2" />
</VerticalGroup>
If it is feasible, where I could start? I don't mind doing extra work if it is necessary, but I would appreciate a lot some direction, examples or ideas.
Thanks a lot!
When using the below ModelBindingText XML that adds a second List on the same nesting level the AchievementsList, the code generator creates invalid code as it attempts to reuse the local variable label2 (the Label used in the AchievementsList and declared locally in that loop) for the second list.
<ModelBindingTest xmlns="Delight" BasedOn="LayoutRoot" SomeParentProperty="t:string">
<Group Orientation="Horizontal">
<Group Spacing="10" Width="500">
<Button Text="Test 1" Click="Test1" />
<Button Text="Test 2" Click="Test2" />
</Group>
<List Id="PlayerList" Items="{player in @Players}" Width="650" BackgroundColor="Green"
Spacing="5">
<Group BackgroundColor="Blue">
<Label Text="{player.Name}" />
<List Id="AchievementsList" Items="{achievement in player.Achievements}"
Orientation="Vertical" Offset="50,0,0,0" Width="300">
<Label Text="{achievement.Title}" />
</List>
<!-- Causes compile error regarding label2 as the local label generated in the above List
block is attempted to be reused for the HighscoreList -->
<List Id="HighscoreList" Items="{highscore in player.Highscores}"
Orientation="Vertical" Offset="50,0,0,0">
<Label Text="{highscore.ScoreText}" />
</List>
</Group>
</List>
</Group>
</ModelBindingTest>
I have an enum under Delight.Models :
public enum UpdateType{ ... }
When I want to reference it on my xml I am using this code:
<UpdateCard TypeOfUpdate="t:UpdateType"> </UpdateCard>
Then the code is generated with a "+" instead of a "."
public readonly static DependencyProperty<Delight.Models+UpdateType> TypeOfUpdateProperty = new DependencyProperty<Delight.Models+UpdateType>("TypeOfUpdate");
public Delight.Models+UpdateType TypeOfUpdate
{
get { return TypeOfUpdateProperty.GetValue(this); }
set { TypeOfUpdateProperty.SetValue(this, value); }
}
If anything else is needed, please let me know :)
I downloaded and looked around package, but only realizing 'Getting started' is full of fixed-pathy autogenerations.
Delight editor plugin finds default paths from config file in specific path (asset root), and the path in config is fixed to specific structure (assets/Config/[subdirectories]), and its fallback paths is hardcoded in constant, and autogeneration tries to access template files from hardcoded fixed paths (assets/Delight/Content/Assets/[cs files], etc etc....
I thought I could modify a little to rearrange asset structure into comparted subdirectory, but it turned out like extremely hard.
It is disappointing If this structure is inevitable.
Hi there,
Maybe a misunderstanding on my part, but just want to clarify. I'm trying to make a Frame (or a Group) that resizes automatically to its content. According to the docs, it seems like the Frame component is meant for this.
<Frame Margin="0"
BackgroundSprite="BlueBackground"
>
<Label AutoSize="Width" Text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasdfasaadddddsdssdgdsfgsdfgsdfg" FontColor="White" Alignment="Top"/>
</Frame>
So I want the Frame to resize according to the content inside of it. This seems to be working, however, the background sprite is not being resized.
If I use a Group:
<Group Margin="0"
BackgroundSprite="BlueBackground"
BackgroundType="Sliced"
>
<Label AutoSize="Width" Text="daaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasdfasaadddddsdssdgdsfgsdfgsdfg" FontColor="White" Alignment="Top"/>
</Group>
It seems to be resizing the Group as well, but in this case the background image is stretched and not sliced.
Am I missing something? The only way I can get the frame to resize correctly with its background sprite is to explicitly set the width and height.
Hi! First of all, I want to thank you for making this tool, I'm still learning how to use it but it seems really helpful so far.
Now to my problem. I'm trying to create a button dinamically, but I couldn't find the way to activate the label's button. The label is always disabled, and it doesn't have any text. Other things I tried:
button.Label.IsActive
GameObject
, e.g.: button.Label.GameObject.SetIsActive(true)
I'm not even sure if I'm doing it in the right method (should it be BeforeInitialize
? BeforeLoad
?). I'm using TextMesh Pro, btw.
This is my current code. Thanks a lot!
namespace Delight
{
public partial class MyPanel
{
public override void AfterInitialize()
{
var buttonGroup = this.Find<Group>("Buttons");
new Button(buttonGroup, buttonGroup, "CloseButton")
{
Text = "Close",
DisplayLabel = true,
LabelIsActive = true,
Width = ElementSize.FromPercents(1),
Height = ElementSize.FromPixels(100),
Alignment = ElementAlignment.Bottom
};
base.AfterInitialize();
}
}
}
Hi, first off, thank you for your effort, I'm having a lot of fun adding some menus to my learning game. It's proven to be super convenient and easy, but I did hit a snag.
I wanted to use a Models
binding to be able to update the UX of my game, that I present through a ViewPresenter
.
View
<GameInterfaceView>
<Group Spacing="10">
<Label Id="TurnLabel" Text="Turn {@TurnValue}" />
</Group>
</GameInterfaceView>
Models
namespace Delight
{
public partial class Models
{
public static int TurnValue = 0;
}
}
I call it from a MonoBehaviour
class attached to a game object.
Delight.Models.TurnValue = 1;
I validate that the Models value is updated, but it does not seem to update the text in GameInterfaceView
. Are these bindings expected to be two way? I started reading the code a bit, but I can't quite figure out how it works and why I am having this issue.
Alternatively, there might be a way to do what I want differently. Am I using the correct approach here? I am simply trying to update the turn counter whenever the game turn changes.
Thanks!
Hi,
I'm currently trying to understand whether we can use Delight together with Unity Addressables. I guess we can't add completely new views (as it requires the code generation in Unity Editor to run), but could it work for styles? Is there a way to dynamically load a style definition (from remote) and apply it to (all) views?
Thx for any hints! BR
Hi,
Any reason to why this is not in the asset store?
Implement AutoComplete functionality for bindings in the Delight Designer. Support autocompleting:
<Label Text="{Player.Name}" />
<List Items="{player in \@Players}">
<Label Text="{player.FirstName}">
Implement list paging
Hi,
When you press 'Create view' whilst in the /content/views folder it keeps reloading, which means you cannot give the file a proper name.
Doing create view in any other location works correctly.
This however led me to create a view called 'Ma' - how do i properly remove this view? i tried deleting the files .cs/.xml/.g.cs but that keeps giving me errors, since then it cannot vind the class in viewactivators:
ViewActivators.Add("Ma", (x, y, z) => new Ma(x, y, null, z));
Refreshing unity keeps adding above line...
I am using the Delight asset available on Asset Store and could not make the "Open Designer" button to show on the Delight window (I have enabled TextMeshPro, rebuilt all and even restarted Unity).
So I took a look at the source code and found that the "Open Designer" button is commented out. I uncommented the code and had to change "DelightDesigner.unity" location to the "Content" folder inside the asset.
Hi! Great job - looks like neat tool.
I tested and there was some functionality in the project on global namespace that clashed with UniRX and Websockets-sharp
https://github.com/neuecc/UniRx
https://github.com/sta/websocket-sharp
Maybe add some of those into your own namespace?
Thanks,
I accidentally included some demo scenes from a plugin in the Content/Assets folder. This lead to the generation of this code in Assets_g.cs
which breaks at build time due to missing UnityEditor namespace, though it runs fine in the editor. Not blocking for me as I didnt' need these scene assets but was a little confusing to track down.
#region SceneAssets
/// <summary>
/// Manages a UnityEditor.SceneAsset object. Loads/unloads the asset on-demand as it's requested by views.
/// </summary>
public partial class SceneAsset : AssetObject<UnityEditor.SceneAsset>
{
public static implicit operator SceneAsset(UnityEditor.SceneAsset unityObject)
{
return new SceneAsset { UnityObject = unityObject, IsUnmanaged = true };
}
public static implicit operator SceneAsset(string assetId)
{
if (String.IsNullOrEmpty(assetId))
return null;
if (assetId.StartsWith("?"))
assetId = assetId.Substring(1);
return Assets.SceneAssets[assetId];
}
}
From the data-binding documentation:
https://delight-dev.github.io/Tutorials/DataBinding.html
namespace Delight
{
public partial class Models
{
public static string MyModelValue = "Hello";
}
}
Is it possible to have multiple of these partial classes? We have around 4 UIs, and having all 4 UIs in one single state file gets a little messy. We are thinking of appending HUD_
and INVENTORY_
to each value, but is there a better way? Ideally separate model files or something.
Thanks
Hello!
First and foremost: thanks for the wonderful tool - I was about to implement something very similar by myself, until I stumbled to your solution :-)
For the bug:
Delight-latest.unitypackage
and open it in Unity 2020.1.10f1 (did not try other versions)Delight
folder -> 3rdParty\Delight\Delight
Content
folder -> 3rdParty\Delight\Content
Game/Delight
folder for custom contentconfig.txt
:ServerUri: http://example.com
UseSimulatedUriInEditor: true
BuildTargets: Dev
AssetBundleVersion: 1
DelightPath: 3rdParty/Delight/
ContentFolders:
Game/Delight/
3rdParty/Delight/Content/
DefaultContentFolder: Game/Delight/
Modules:
TextMeshPro
The config should be read properly
On each asset change:
DirectoryNotFoundException: Could not find a part of the path "D:\MyProject\Assets\Delight\Content\Config_g.cs".
FileNotFoundException: Could not find file "D:\MyProject\DelightConfig.bin"
The problem persist even after restarting Unity (I saw a few static fields for config)
while importing Delight for the first time it causes complilation errors.
Assets\Delight\Content\Views\UI\TextMeshPro\Label_g.cs(242,16): error CS0246: The type or namespace name 'TMP_ColorGradientAsset' could not be found (are you missing a using directive or an assembly reference?)
Assets\Delight\Content\Views\UI\TextMeshPro\Label_g.cs(250,16): error CS0246: The type or namespace name 'TMP_SpriteAsset' could not be found (are you missing a using directive or an assembly reference?)
Assets\Delight\Content\Views\UI\TextMeshPro\Label_g.cs(240,62): error CS0246: The type or namespace name 'TMP_ColorGradientAsset' could not be found (are you missing a using directive or an assembly reference?)
Assets\Delight\Content\Views\UI\TextMeshPro\Label_g.cs(248,62): error CS0246: The type or namespace name 'TMP_SpriteAsset' could not be found (are you missing a using directive or an assembly reference?)
Assets\Delight\Content\Views\UI\TextMeshPro\InputField_g.cs(488,16): error CS0246: The type or namespace name 'TMP_InputValidatorAsset' could not be found (are you missing a using directive or an assembly reference?)
Assets\Delight\Content\Views\UI\TextMeshPro\InputField_g.cs(736,16): error CS0246: The type or namespace name 'TMP_ColorGradientAsset' could not be found (are you missing a using directive or an assembly reference?)
Assets\Delight\Content\Views\UI\TextMeshPro\InputField_g.cs(743,16): error CS0246: The type or namespace name 'TMP_SpriteAsset' could not be found (are you missing a using directive or an assembly reference?)
Assets\Delight\Content\Views\UI\TextMeshPro\InputField_g.cs(486,62): error CS0246: The type or namespace name 'TMP_InputValidatorAsset' could not be found (are you missing a using directive or an assembly reference?)
the config.txt in /content
## Configuration file. Available options:
## ServerUri - URI that points to where remote asset bundles are stored
## BuildTargets - controls which model data is included in build
## ContentFolders - specifies where Delight content (views, models, etc) resides (besides the default folders)
## DefaultContentFolder - specifies default content folder where new content is placed when created by the Delight Designer
## StreamedBundles - specifies which bundles (by name) should be streamed locally rather than from remote URI
## ServerUriLocator - name of class that locates server URI based on bundle name
## UseSimulatedUriInEditor - set to true/false indicating if a simulated server URI should be used in the editor
## Namespaces - Namespaces to be included in the generated code and prioritized when infering types
## DelightPath - Delight framework root path
## DefaultBasedOn - Default view all views are based on if the BasedOn attribute isn't specified (UIView if not specified)
## BaseView - Custom view all views will inherit from.
## AssetBundleVersion - Set to non-zero integer to enable caching of asset bundles. Increment to invalidate bundle caches and force new updates
## Modules - List of modules to activate. E.g. To enable TextMesh Pro, download the latest package with the package manager and add TextMeshPro to config file.
## Example configuration, remove "#" to uncomment configuration options:
ServerUri: http://example.com
UseSimulatedUriInEditor: true
BuildTargets: Dev
AssetBundleVersion: 1
ContentFolders:
Modules: TextMeshPro
Because of this compilations error it is impossible to click on Window>Delight>Rebuild All : it does not even show in the window
Hello, I want make the game which ui is moddable, the mod is put in StreamingAssets dir.
Does Delight support runtime load xml files from StreamingAssets ?
Best Regards!
The designer text editor appears to be incorrectly calculating the Text Cursor position when using Tabs rather than Spaces for indentation.
To Reproduce:
This can make the designer very difficult to use for files using Tabs rather than Spaces, though it's easily worked around by changing your text editor config.
CTRL+Z and CTRL+Y to undo or redo XML edits/actions in designer. Implement by storing state each time the XML is edited.
Currently run-time parsing is only possible within the editor. Implement run-time parsing of views outside the editor to allow things like applying new styles and creating new views outside the editor.
Are nested Lists possible? I have a list of items which contains several properties and some of this properties are Lists too, and I want to render them using bindings if that's possible.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.