dkozar
August 24, 2012, 8:33pm
21
Let me continue with the previous post.
Since the Alert class closes itself (cancels) on KEY_UP, other components shouldn’t react on this event since they are not in focus.
In GUI programming, a number of actions has to be “done later”.
There are convenience methods for delaying actions in eDriven. One of them is the Defer method. This is the instance method of the component. If you have a piece of code that has to be done a few frames later, this is the way you use it:
Defer(delegate { Foo(); }, 1); // Foo() will run one frame later
Normally, delays so short aren’t noticeable.
dkozar
August 24, 2012, 10:11pm
22
Ah, you are not inside the component. If deferring from scripts, use:
DeferManager.Instance.Defer(delegate { Foo(); }, 3); // defer for 3 frames
dkozar
August 24, 2012, 10:17pm
23
Or, if Foo has the DeferManager.DelayedAction signature (which it has here):
DeferManager.Instance.Defer(Foo, 3); // defer for 3 frames
And inside the Foo is everything you need to run after N frames:
private void Foo() {
Alert.Show(...)
}
Or directly via delegate:
DeferManager.Instance.Defer(delegate {
Alert.Show(...)
}, 3); // defer for 3 frames
dkozar
August 24, 2012, 10:31pm
24
Of course To me this happens automatically. Sorry for assuming everybody’s using Visual Studio (Express) or ReSharper.
I prefer to be concise. Very nice of you for filling in the gaps → fell free to do that
dkozar
August 26, 2012, 8:15pm
25
Nope, as I remember this is where the underlying immediate TextField takes control.
I just implemented the following static properties on Alert:
public static bool CircularTabs;
public static bool CircularArrows;
public static bool ArrowsEnabled = true;
(will go into the next build)
Implement GetTabChildren() as in one of the examples. With it, you can also define the order.
dkozar
August 26, 2012, 8:21pm
26
I get:
Error CS0019: Operator +=' cannot be applied to operands of type
eDriven.Core.Events.MulticastDelegate’ and `anonymous method’ (CS0019) (Assembly-CSharp)
How exactly are you debugging this framework with Unity?
The latter is written OK - it’s all eDriven events (eDriven.Core.Events.Event )
Actually I saw this warning once - in script - and cannot remember the reason. Try using the method reference instead of the delegate.
I’m using Debug.Log() for debugging purposes (got a special debug build with #if DEBUG statements and writing interesting things to log only when in debug build).
dkozar
August 26, 2012, 8:34pm
27
Hi,
Reference: NGUI/ex2D/Play2d
Each object has the ability to have a different LayoutDescriptor from it’s parent (scene).
So, you could have different anchor positions:
A parent container object can have Center, the child can have different as it wishes.
In eDriven, suppose you set the form or main geometry to:
LayoutDescriptor = LayoutDescriptor.Absolute;
But instead of hard-wired positions, like below, you want to set the LayoutDescriptor to LayoutDescriptor.VerticalTopRight or something else instead -
(your demo - AbsoluteLayoutDemo.cs)
Button btn4 = new Button
{
Left = 500,
Right = 100,
Top = 500,
Bottom = 100,
MinWidth = 300,
MinHeight = 300, // want them to be LayoutDescriptor.VerticalTopRight instead of hard-wiring numbers.
FocusEnabled = false,
Text = @"Left = 500,
Right = 100,
Top = 500,
Bottom = 100,
MinWidth = 300,
MinHeight = 300",
ToggleMode = true,
Styles = buttonStyles
};
AddChild(btn4);
so is there way to have/get different geometry positions for different objects and not conform to the parent container’s LayoutDescriptor?
You have to chose a single layout for the container, and all of its children play by its rules.
Or: you can turn the layout OFF for some children with: child.IncludeInLayout = false;
Or: you could layer two containers on top of each other, each with a different layout.
Btw. LayoutDescriptors are defaults made for quick prototyping, normally you should use the Layout property instead. Plug in any of the layouts (BoxLayout - this is both HBox and VBox), Absolute layout etc. and configure it in details.
then, is there a way to have edge-based alignment?
Example: Align the object to the edge of the screen (e.g., ((edge) - 100px)) and it auto-moves when screen size changes).
Place the control into a Container (or Stage) that has an AbsoluteLayout . Make it:
myControl.Width = 100;
myControl.Right = 0;
dkozar
August 26, 2012, 8:45pm
28
Actually I can, because this is not the framework code, but a specific (script) implementation for my demos (attach).
This is also the MVC example (or as I call it: “semi data-binding”).
1019734–37780–$OptionsToolbar.zip (5.83 KB)
dkozar
August 26, 2012, 8:58pm
29
Nah, like it as it is.
Will look at it.
If I could split in 2, one of us would be fixing the Level bug, and the other one would answer your questions
Didn’t try it, but should work with Change event:
txt.Change += delegate (Event e) {
txt.Text = txt.Text.ToUpper();
}
dkozar
August 26, 2012, 9:01pm
30
No (for individual controls), that would break the layout rules, wouldn’t it? Layout is how the parent places its children, not vice-versa.
dkozar
August 26, 2012, 9:05pm
31
There is error for resizing of fonts in iOS platform:
Font size and style overrides are only supported for dynamic fonts.
UnityEngine.GUIStyle:CalcSize(GUIContent)
eDriven.Gui.Util.MeasureUtil:MeasureContent(Component, Single, Single)
eDriven.Gui.Components.Component:Measure()
eDriven.Gui.Components.Label:Measure()
eDriven.Gui.Components.InvalidationManagerClient:cfdda025f85c6e53043176fb58df93bf4()
eDriven.Gui.Components.InvalidationManagerClient:ValidateSize(Boolean)
A.c85d15b834db2406fda444e03009f3caf:c5860f0ec3032fa5e72f72b873f3ad135(IInvalidationManagerClient)
The solution for this error is found here . Basically you have to tweak the font importer.
dkozar
August 26, 2012, 9:36pm
32
dkozar
August 26, 2012, 10:13pm
33
Then I need edges and geometry information.
For example:
var x= GUI.Width; // not work
var y= GUI.Height; // not work
but
Button.Width = XX;
Height.Widht = XX;
works.
Reason why I need is to adjust it so that layout to different screen sizes. Preferably, to the edges of the screen.
e.g.,
if the GUI.LayoutDescriptor is AbsolutePosition where should the panel be placed which is equivalent to HorizontalLeftCenter?
if you don’t want a control to have that information, then provide a class to get that layout info out…
There’s a ScreenSize property in SystemManager which gives you the currrent screen dimensions.
When placing the control inside a container, it won’t be measured as long as the container doesn’t run the measure pass. So, you cannot know the final size except if you give it the fixed size.
However, there’s a method to force validation passes on control which is not yet officially measured: you have to call myControl.ValidateNow () and after that you can read it’s dimensions for further calculations.
dkozar
August 28, 2012, 9:43pm
35
You can try it. You need to add:
Uses UnityEngine; // add to uses clause. After that, you get errors error below →
Error CS0104: Event' is an ambiguous reference between
eDriven.Core.Events.Event’ and `UnityEngine.Event’ (CS0104) (Assembly-CSharp)
later when you add “eDriven.Core.Events.Events”, you end up with:
Error CS0019: Operator +=' cannot be applied to operands of type
eDriven.Core.Events.MulticastDelegate’ and `anonymous method’ (CS0019) (Assembly-CSharp)
which makes no sense.
This is a sporadic error (I saw it once, for me it works). When it happens, proceed as follows:
Instead of this:
txt.Change += delegate (Event e) {
txt.Text = txt.Text.ToUpper();
}
write this:
txt.Change += new EventHandler(delegate (Event e) {
txt.Text = txt.Text.ToUpper();
});
or this:
txt.Change += ChangeHandler;
private void ChangeHandler(Event e) {
txt.Text = txt.Text.ToUpper();
}
dkozar
August 29, 2012, 9:14pm
36
Bugs fixed. Uploading a new version to the AssetStore tonight. Will post a message when visible online (probably tomorrow).
Hey dkozar, are you going to do any examples/tutorial videos for the edriven framework like you have for the GUI? I’m very interested in learning about software development practices outside of unity, and this seems like a great way.
dkozar
August 29, 2012, 9:40pm
38
holyjewsus:
Hey dkozar, are you going to do any examples/tutorial videos for the edriven framework like you have for the GUI? I’m very interested in learning about software development practices outside of unity, and this seems like a great way.
I’d really like to, but never having enough time for eDriven.Core, since promoting GUI
However, there are great resources for figuring out how it works:
GitHub repository: https://github.com/dkozar/eDriven
Sources of eDriven.Gui demos, which also contain Core classes. For example, the Twitter demo shows how to connect asynchronously to a server as well as the usage of other core classes. Source here: http://edrivenunity.com/backend/source/load-images-source/
dkozar
August 30, 2012, 9:47am
39
A small demo I made yesterday (loading different scenes…): http://edrivenunity.com/unity/load_level/
dkozar
August 31, 2012, 6:44am
40
Set this up before any of eDriven managers gets called, for instance:
void Awake()
{
eDriven.Core.Framework.EnableInfoMessages = false;
}
Try using only 1 default font per project, and let the other be named fonts.
Furthermore you could style each component instance using the same style names a mapper property names, starting with small uppercase letter:
Label lbl = new Label { Text = "Styled label" };
lbl.SetStyle("labelStyle", myGUIStyle);
Would it be possible to provide some kind of global CSS equivalent to the style mappers?
That is, when it starts, you override a protected event and all the styles are defined in code. It would be fabulous if you could initialize all the style mapper defaults in code…
Will look into it.