fairygui / fairygui-unity Goto Github PK
View Code? Open in Web Editor NEWA flexible UI framework for Unity
Home Page: https://fairygui.com
License: MIT License
A flexible UI framework for Unity
Home Page: https://fairygui.com
License: MIT License
Code rely on callback count has trouble.
Can you plz introduce Percentage Height and Width in future versions ..?
Is there any way to increase List Scrolling Speed ..?
_list.scrollPane.scrollSpeed = 1000;
but it dones not have effect ..
Hi!
how to stop Text from Receiving Touch events ..?
I think it is better to management.
.gitignore
https://github.com/github/gitignore/blob/master/Unity.gitignore
.gitattribute
*.bytes eol=lf
*.asset eol=lf
*.shader eol=text
*.unity eol=text
*.cs eol=text
*.meta eol=lf
*.prefab eol=lf
.gitattributes text
.gitignore text
Creation of Bitmap fonts takes took much time.
1- use littera to create sprite.
2- use showbox to unpack this sprite.
3-then import , include and assign characters to every sprite.
if some thing wrong, u have to do all these steps again.
Seriously this is too much manual work.
may be i have done some overhead but character assigning is too much work.
I have used Textmesh pro untiy , where u just have to assign font ,simple settings
and ur font is ready.
it would be much more convenient if Add font automation in editor.
Thanx
how to get Label AutoSize in script ..?
github has release feature.
so, Would you mind to release this to fairygui-{version}.unitypackage?
It will be easy to manage package.
after this layout code , during Scrolling list inertia some time get disabled
` private void RenderListItem(int index, GObject item)
{
var button = item.asButton;
var icon = button.GetChild("icon");
var backGround = button.GetChild("backGround");
var label = button.GetChild("text");
var randomNo = UnityEngine.Random.Range(2, 10);
var str = Path.GetRandomFileName();
for (int i = 0; i < randomNo; i++)
{
str += Path.GetRandomFileName();
}
label.text = str;
// layout
var margin = 10;
icon.xy = new Vector2(margin, margin);
label.width = button.width - 40 - icon.x - icon.width;
backGround.height = label.height + margin;
backGround.width = label.width + margin;
backGround.x = icon.x + icon.width + margin * 2;
backGround.y = 5;
label.x = backGround.x + 5;
label.y = backGround.y + 5;
button.height = backGround.y + backGround.height + 5;
}`
Kindly Can you Define your Road Map ..?
what are your future planes for this , what things you are going to introduce in next versions.
just roughly , to get idea ..
not scrolling Down properly.
_list.scrollPane.ScrollDown(0.5f, true);
Can you please make SlideBlock as Proper Side Menu with atleast following features
If possible also add
Here are working examples of Side Menus
Right now i m developing Application Using Fairy UI , But most Major Problem here is absence of Screens and Screen Navigation ,
every time i have to reinvent the wheel ,
if you add Screen and Screen Navigation System Like Feathers it would be Great..
Hi!
could not run even a simple color component.
steps
1- Create new project in Fairy GUI editor.
2- New Component.
3- Color it , and check bgColor
4- Export.
Edit "Basics" Scene ,
Select Package and component ,
Run
Create test@test failed!
UnityEngine.Debug:LogError(Object)
FairyGUI.UIPanel:CreateUI_PlayMode() (at D:/FairyGUI-unity/Scripts/UI/UIPanel.cs:336)
FairyGUI.UIPanel:Start() (at D:/FairyGUI-unity/Scripts/UI/UIPanel.cs:128)
Please Help to resolve it.
Fairy Gui Editor, Unity Plugin both are Updated.
using unity 5.6
1-List View With Pagination
2-colums count = 3 , row Count = 2,
main.ListView.itemRenderer = ItemGoingToRender;
main.ListView.numItems = 5;
Error
ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
System.Collections.Generic.List`1[FairyGUI.GList+ItemInfo].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
FairyGUI.GList.HandleScroll3 (Boolean forceUpdate) (at Assets/Fairy Gui/Scripts/UI/GList.cs:1990)
FairyGUI.GList.HandleScroll (Boolean forceUpdate) (at Assets/Fairy Gui/Scripts/UI/GList.cs:1615)
FairyGUI.GList.RefreshVirtualList (System.Object param) (at Assets/Fairy Gui/Scripts/UI/GList.cs:1434)
FairyGUI.GList.set_numItems (Int32 value) (at Assets/Fairy Gui/Scripts/UI/GList.cs:1281)
Test.Start () (at Assets/Test.cs:78)
Thanx For This Great Asset 👍
There is no other UI asset on assetStore even closer to it.
i just started learning it.
i have some queries.
1- Constant Physical size is same on mobile , these are my settings
2- Image height and width both are associated with Controller height and Width , image resize well in fairy Editor Iphone 5 Ipad but in unity editor, it remains designer size and do not resize to game view ,it should fill game view. if i m doing wrong plz correct me..
3- i have tried to increase scrolling speed by "_list.scrollPane.scrollSpeed = 300" but no effect.
4-i could not understand majority of tutorials because all are in chines expect "FairyGUI Tutorials 1"
Hi!
i m working on Chat UI thing right now , and stuck itemRenderer width ,
i have seen your Emoji Example , but it is not responsive,
now case is.
1- item renderer's min width should depends upon inner text ,
2- but max width depends upon list available width..
how i can solve.
Hi!
i was wondering why you are using poll and adding child directly..?
instead of increasing list.numItems ..?
"i have not seen any example of using list.data"
list is also not set to virtualized , instead you are explicitly checking its childCount and adding them in pool.
yes there are two item renderers , therefore you are using this thing.
but is there any better way we can adopt while using more then one itemRenderers , with virtualization as and not adding child directly to list..?
Hi!
i m working on an application where i have used both FairyGUI and UGUI.
Problem is when ever i shift from Fairy GUI Scene to UGUI scene. Stage Camera also popup there and leads some unexpected results.
Please take a look on it.
Can you plz introduce min and max limits in future versions ..?
min width ,max width
min height and max height ..?
GRoot.inst.SetContentScaleFactor (600, 800);
UIPackage.AddPackage ("Package1", loadFunc: LoadResource);
GComponent comp = UIPackage.CreateObject("Package1", "Component1").asCom;
GRoot.inst.ShowPopup (comp);
that code doesn't work what i intend.
GRoot.inst.ShowPopup (comp);
comp.Center (); // adding this line, it will work correctly.
i'm confused why comp.Center()
is needed
i want chat like this list items but
label configuration 1 this
layout code
` var margin = 10;
icon.xy = new Vector2(margin, 5);
var iconAsociatedHeight = icon.y + icon.height + margin;
label.x = icon.x + icon.width + margin * 2;
label.y = icon.y;
var labelWidth = button.width - label.x - 10;
if (label.width > labelWidth)
{
label.width = labelWidth;
}
backGround.x = label.x - 5;
backGround.y = label.y - 5;
backGround.height = label.height + 10;
backGround.width = label.width + 10;
var textAssoicatedHeight = backGround.y + backGround.height + 5;
button.height = Math.Max(textAssoicatedHeight, iconAsociatedHeight);`
lable configuration 2 this
code Same
Hi!
I was googling "How i can Reduce Battery Drain Problem in Unity for App".
i found this post , post
i think it would be better to share with you. and if it is possible include in fairy ui.
Unity re-Render every thing in Every Frame , wither it is needed or not , including fairy-ui components.
there is a solution just for fairy ui.
assume we are working on just app development ,means no 3d model.
Render only when its need to render by using upper mentioned post.
RenderOnce()
and now how to detect it needs to render or not ?
it could be done , by detecting input (by mouse movment , touchCount ), SizeChanged , PositionChanged for fairy-UI Component.
there All things Would be Customized, if any one wants to make renderer on every frame , he can do.
if you have better approach Plz apply it.
like render only needed components.
like Starling
actualHeight;
initHeight
sourceHeight
On Graph mode Rectangle
It was worked what i wanted.
but When i changed to Circle
line didn't in Unity. but In Fairyeditor it was worked.
Hi there,
Is there any possibility of porting Feathers' Waterfall layout to FairyUnity?
https://feathersui.com/help/waterfall-layout.html
Thanks
Hi!
i have created itemRenderer it has delete button.
when delete button clicked , itemRenderer also dispatches its selection event.
how to prevent parent from taking event ?
Horizontal Pagination List in this example
When width change it draw only items which can fit in , means no extra cutting item , but here things are not as same , Fairy ui
Feathers UI uses concept of pages so when you say 10 items in a page then UI always show 10 items even if UI is able to show 20, so if you can implement something like that in future (After fixing all current list related issues) that’d be great feathers Example
1- create List
2-apply FlowLayout
3-Created Items With Different Size(height and Width)
1 - overFlow on each other Problem
2 -items Disappearing during scrolling as stated before.
Facing About Same Issues in with Text
only GetChild function, It is hard to managemet code. so I suggested using attribute
before
GButton item = list1.AddItemFromPool().asButton;
item.GetChild("t0").text = "" + (i+1);
item.GetChild("t1").text = testNames[i];
item.GetChild("t2").asTextField.color = testColor[UnityEngine.Random.Range(0, 4)];
item.GetChild("star").asProgress.value = (int)((float)UnityEngine.Random.Range(1, 4) / 3f * 100);
after
public class AListItem : BaseGComponentHelper
{
[GChild]
FairyGUI.GTextField t0 = null;
[GChild]
FairyGUI.GTextField t1 = null;
[GChild]
FairyGUI.GTextField t2 = null;
[GChild("star")]
GProgressBar bar = null;
public AListItem(GComponent comp) : base(comp)
{
}
public void Init(string txt, string name, Color color, float progress)
{
t0.text = txt;
t1.text = name;
t2.color = color;
bar.value = progress;
}
}
var txt = "" + (i + 1); ;
var name = testNames[i];
var color = testColor[UnityEngine.Random.Range(0, 4)];
var progress = (int)((float)UnityEngine.Random.Range(1, 4) / 3f * 100);
var item = list1.AddItemFromPool().As<AListItem>();
item.Init(txt, name, color, progress);
implementation example
i know it invoke reflection function effect on performance. but sometimes it will be deserved.
using UnityEngine;
using FairyGUI;
using System;
using System.Reflection;
using System.Linq;
public static class GComponentExtension
{
public static T As<T>(this GObject obj) where T : BaseGComponentHelper
{
return (T)Activator.CreateInstance(typeof(T), obj.asCom);
}
}
public class BaseGComponentHelper
{
public BaseGComponentHelper(GComponent comp)
{
LoadComponents(comp);
}
public void LoadComponents(GComponent comp)
{
var behaviour_type = this.GetType();
var path_type = typeof(GChildAttribute);
var fields = behaviour_type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where(m => m.GetCustomAttributes(path_type, true).Length == 1);
foreach(var field in fields)
{
var attribute = field.GetCustomAttributes(path_type, true)[0] as GChildAttribute;
var path = (attribute.IsSelf) ? field.Name : attribute.path;
var gobject = comp.GetChild(path);
if(gobject == null)
{
Debug.LogError(string.Format("can't find gobject in {0}", path));
continue;
}
field.SetValue(this, gobject);
}
}
}
public class GChildAttribute : Attribute
{
public readonly string path = null;
public bool IsSelf
{
get { return this.path == null; }
}
public GChildAttribute(string path)
{
this.path = path;
}
public GChildAttribute()
{
this.path = null;
}
}
Hi!
i m facing problem in making ItemRenderer.
1-created itemrender as usual
2-make a child label.
3-label Width connect with container width.
container height connected with label hight.
(i have simplified this problem here but even applying there steps you will find problem)
Kindly provide page indicator after solving other things.
when i create fariygui/uipanel from 5.4/dll
i got error messege
TypeLoadException: Could not load type 'FairyGUI.GearBase' from assembly 'FairyGUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
FairyGUI.GComponent..ctor () (at D:/FairyGUI-unity/Scripts/UI/GComponent.cs:56)
FairyGUI.GRoot..ctor () (at D:/FairyGUI-unity/Scripts/UI/GRoot.cs:38)
FairyGUI.Stage.Instantiate () (at D:/FairyGUI-unity/Scripts/Core/Stage.cs:99)
FairyGUI.Stage.get_inst () (at D:/FairyGUI-unity/Scripts/Core/Stage.cs:85)
FairyGUI.UIPanel.SetSortingOrder (Int32 value, Boolean apply) (at D:/FairyGUI-unity/Scripts/UI/UIPanel.cs:242)
FairyGUI.UIPanel.CreateContainer () (at D:/FairyGUI-unity/Scripts/UI/UIPanel.cs:180)
FairyGUI.UIPanel.OnEnable () (at D:/FairyGUI-unity/Scripts/UI/UIPanel.cs:90)
how i can assign layouts in components in fairy ui editor ..?
When using Constant Physical size UI does not look Crisp. on mobile
example
Hi!
How Could Listitem will be select by double Click.
Is it possible to add support for xLua from Tencent which is pretty popular besides uLua & ToLua. Thanks.
TextMeshPro has so many advantages, crisp + rich text etc, Can you please add its support so we can use it with your list item renderers?
1 -Horizontal Pagination is Working Fine but vertically pagination is not working.
2-Plz provide horizontal and vertically alignment in list.
see space on right and bottom.
Image
after seeing IconManager.cs i was thinking about how i can load remote images ,
IconManager is a complete package for loading and caching images , but its fields are not protected , means i could not extends this...
so i have made some alternations in Run() , plz accept these changes or if you have better idea ,do implement.
`IEnumerator Run()
{
_started = true;
LoadItem item = null;
while (true)
{
if (_items.Count > 0)
{
item = _items[0];
_items.RemoveAt(0);
}
else
break;
if (_pool.ContainsKey(item.url))
{
//Debug.Log("hit " + item.url);
NTexture texture = (NTexture)_pool[item.url];
texture.refCount++;
if (item.onSuccess != null)
item.onSuccess(texture);
continue;
}
string url ;
bool indernal;
if (item.url.IndexOf("ui://") == 0)
{
url = _basePath + item.url + ".ab";
indernal = true;
}
else
{
url = item.url;
indernal = false;
}
WWW www = new WWW(url);
yield return www;
if (string.IsNullOrEmpty(www.error))
{
NTexture texture;
if (indernal)
{
AssetBundle bundle = www.assetBundle;
if (bundle == null)
{
Debug.LogWarning("Run Window->Build FairyGUI example Bundles first.");
if (item.onFail != null)
item.onFail(www.error);
continue;
}
#if UNITY_5
texture = new NTexture(bundle.LoadAllAssets()[0]);
#else
NTexture texture = new NTexture((Texture2D)bundle.mainAsset);
#endif
bundle.Unload(false);
}
else
{
texture = new NTexture( www.texture);
}
texture.refCount++;
_pool[item.url] = texture;
if (item.onSuccess != null)
item.onSuccess(texture);
}
else
{
if (item.onFail != null)
item.onFail(www.error);
}
}
_started = false;
}
`
Does "Association" work with child to parent property?
means i have item ItemRenderer it has two labels , title and description ,
description.autosize = height;
and title has constant height ,
now problem is how can i assign..?
ItemRenderer.height = title.height + description.height;
can i achieve it using association?
FairyGui ScrollView has just two events , onPullDownRelease , onPullUpRelease ,it seems no way to create Animations Like this
but if you have any idea it is more better...
I have tried listView in NGUI where i made detailed scroll Events , Please take a look on it so it could be implemented in fairyGui ..
`public class ScrollEvents : MonoBehaviour
{
public UnityEvent OnPullDownStarted;
public UnityEvent OnPullDowned;
public UnityEvent OnPullDownStartEnding;
public UnityEvent OnPullDownEnded;
public UnityEvent OnPullUpStarted;
public UnityEvent OnPullUped;
public UnityEvent OnPullUpStartEnding;
public UnityEvent OnPullUpEnd;
public class scrollEvent : UnityEvent<float> { };
public scrollEvent OnPullDownScroll;
public scrollEvent OnPullUpScroll;
[Range(0, 100)] public int pullDownStartThreshold = 50;
[Range(0 ,250)] public int pullDownThreshold = 100;
[Range(0, 100)] public int pullDownEndThreshold = 50;
[Range(0, 100)] public int pullUpStartThreshold = 50;
[Range(0, 250)] public int pullUpThreshold = 100;
[Range(0, 100)] public int pullUpEndThreshold = 50;
private UIScrollView scrollView;
private UIPanel panel;
private bool moving;
private bool dragging;
private bool pullDownStarted;
private bool pullDowned;
private bool pullDownStartEnding;
private bool pullUpStarted;
private bool pullUped;
private bool pullUpStartEnding;
void Awake()
{
panel = GetComponent<UIPanel>();
scrollView = GetComponent<UIScrollView>();
scrollView.onDragStarted += OnDragStarted;
scrollView.onDragFinished += OnDragFinished;
scrollView.onStoppedMoving += OnStopMoving;
OnPullDownStarted = new UnityEvent();
OnPullDowned = new UnityEvent();
OnPullDownStartEnding = new UnityEvent();
OnPullDownEnded = new UnityEvent();
OnPullUpStarted = new UnityEvent();
OnPullUped = new UnityEvent();
OnPullUpStartEnding = new UnityEvent();
OnPullUpEnd = new UnityEvent();
OnPullDownScroll = new scrollEvent();
OnPullUpScroll = new scrollEvent();
}
private void OnDragStarted()
{
dragging = moving = true;
}
private void OnDragFinished()
{
dragging = false;
}
private void OnStopMoving()
{
moving = false;
resetAllStates();
}
private Vector3 GetScrollViewConstraint()
{
Bounds b = scrollView.bounds;
return panel.CalculateConstrainOffset(b.min, b.max);
}
void Update()
{
if (moving)
{
Vector3 constraint = GetScrollViewConstraint();
if (constraint.y == 0)
{
CheckAnyPendingEvents();
return;
}
if (constraint.y > 0)
{
if (constraint.y > pullDownStartThreshold && pullDownStarted || pullDowned)
{
float scrollValue = (constraint.y - pullDownStartThreshold) / (pullDownThreshold - pullDownStartThreshold);
scrollValue = Mathf.Clamp01(scrollValue);
if (OnPullDownScroll != null) OnPullDownScroll.Invoke(scrollValue);
}
if (constraint.y > pullDownThreshold && pullDownStarted && pullDowned == false)
{
if (OnPullDowned != null) OnPullDowned.Invoke();
pullDowned = true;
}
else if (constraint.y < pullDownThreshold && pullDowned && pullDownStartEnding == false)
{
if (OnPullDownStartEnding != null) OnPullDownStartEnding.Invoke();
pullDownStartEnding = true;
}
else if (constraint.y > pullDownStartThreshold && pullDowned == false && pullDownStarted == false && dragging)
{
if (OnPullDownStarted != null) OnPullDownStarted.Invoke();
pullDownStarted = true;
}
else if (constraint.y < pullDownEndThreshold && (pullDownStarted || pullDowned))
{
if (OnPullDownEnded != null) OnPullDownEnded.Invoke();
resetAllStates();
}
}
else if (constraint.y < 0)
{
if (constraint.y < -pullUpStartThreshold && pullUpStarted || pullUped)
{
float scrollValue = (constraint.y - pullUpStartThreshold) / (pullUpThreshold - pullUpStartThreshold);
scrollValue = Mathf.Clamp01(Mathf.Abs(scrollValue));
if (OnPullUpScroll != null) OnPullUpScroll.Invoke(scrollValue);
}
if (constraint.y < -pullUpThreshold && pullUpStarted && pullUped == false)
{
if (OnPullUped != null) OnPullUped.Invoke();
pullUped = true;
}
else if (constraint.y < -pullUpStartThreshold && dragging && pullUpStarted == false && pullUped == false)
{
if (OnPullUpStarted != null) OnPullUpStarted.Invoke();
pullUpStarted = true;
}
else if (constraint.y > -pullUpThreshold && pullUped && pullUpStartEnding == false)
{
if (OnPullUpStartEnding != null) OnPullUpStartEnding.Invoke();
pullUpStartEnding = true;
}
else if (constraint.y > -pullUpEndThreshold && (pullUpStarted || pullUped))
{
if (OnPullUpEnd != null) OnPullUpEnd.Invoke();
resetAllStates();
}
}
}
}
private void CheckAnyPendingEvents()
{
if (pullDowned || pullDownStartEnding || pullDownStarted)
{
if (OnPullDownEnded != null) OnPullDownEnded.Invoke();
resetAllStates();
}
if (pullUpStarted || pullUpStartEnding || pullUped)
{
if (OnPullUpEnd != null) OnPullUpEnd.Invoke();
resetAllStates();
}
}
private void resetAllStates()
{
pullUpStartEnding = pullDownStartEnding = pullDownStarted = pullDowned = pullUpStarted = pullUped = false;
}
void OnDestroy()
{
scrollView.onDragStarted -= OnDragStarted;
scrollView.onDragFinished -= OnDragFinished;
scrollView.onStoppedMoving -= OnStopMoving;
OnPullDownStarted.RemoveAllListeners();
OnPullDowned.RemoveAllListeners();
OnPullDownStartEnding.RemoveAllListeners();
OnPullDownEnded.RemoveAllListeners();
OnPullUpStarted.RemoveAllListeners();
OnPullUped.RemoveAllListeners();
OnPullUpStartEnding.RemoveAllListeners();
OnPullUpEnd.RemoveAllListeners();
OnPullDownScroll.RemoveAllListeners();
OnPullUpScroll.RemoveAllListeners();
}
}
`
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.