Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Better UI 2.0 Beta

Discussion in 'Assets and Asset Store' started by Hosnkobf, Dec 21, 2018.

  1. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    652
    Hello UI Designers,

    Finally I created Better UI 2.0 Beta.

    What is Better UI?
    It is an asset which helps creating UIs for any resolution. It also has some further functionality to change sprite appearance or having more transitions for an selectable (and more).
    Here is an Asset Store Link
    Here is the Forum Thread
    Here is the documentation of the previous version (v1.2)

    What is new in Version 2.0?
    The biggest feature is "Real Responsive Design". This means you can create one UI which changes settings / positions / sizes for different screens or orientations (like small landscape screen or big portrait screen or touch screen or ...).
    There are also a lot of small improvements and a complete set of Better Components for Layout.
    Here is a link to the changes in v2.0

    Why a Beta?
    The changes in Better UI 2.0 are huge! I tried to be backwards compatible anyways. So I would like to find out if there are problems when upgrading from a project with an older version.
    Also, I recently had no time to finish everything, but the customers are waiting long enough now. So this version is about 95% complete. When I release I would like to have the last 5% completed. Also I would like to be as bug-free as possible ;)

    Who can get the Beta Version?
    Everybody who purchased Better UI - or who convince me that he is a good Beta tester.
    Please write me a private message with your invoice number or your reason why you think you should get the beta. I will send you a download link then.

    What is this thread for?
    I would like to get your feedback here. I am looking especially for the following feedback:
    • If upgraded existing project with previous version of Better UI (after backup): Did everything still work? If not: what did not work?
    • If added Better UI to a new project: Did you encounter any issues other than "Known Issues" described in the documentation of the Beta?
    • Did you find a bug? How to reproduce it?
    • Do you have a suggestion how to improve something?
    • If you have trouble understanding the features, you can also use this thread.
    General feedback is also welcome :)
     
    vonbetelgeuse and Grumpy-Dot like this.
  2. vonbetelgeuse

    vonbetelgeuse

    Joined:
    Aug 28, 2014
    Posts:
    124
  3. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    652
    vonbetelgeuse likes this.
  4. vonbetelgeuse

    vonbetelgeuse

    Joined:
    Aug 28, 2014
    Posts:
    124
    Hello again!

    I'm currently using 2018.3.0f2 and I understand that for the moment Beta doesn't like TextMeshPro.

    I̶'̶v̶e̶ ̶t̶r̶i̶e̶d̶ ̶f̶o̶l̶l̶o̶w̶i̶n̶g̶ ̶t̶h̶e̶ ̶s̶a̶m̶e̶ ̶i̶n̶s̶t̶r̶u̶c̶t̶i̶o̶n̶s̶ ̶u̶s̶i̶n̶g̶ ̶a̶ ̶U̶n̶i̶t̶y̶ ̶U̶I̶ ̶I̶n̶p̶u̶t̶F̶i̶e̶l̶d̶ ̶b̶u̶t̶ ̶I̶'̶m̶ ̶n̶o̶t̶ ̶g̶e̶t̶t̶i̶n̶g̶ ̶i̶t̶ ̶t̶o̶ ̶w̶o̶r̶k̶ ̶f̶o̶r̶ ̶m̶e̶,̶ ̶s̶h̶o̶u̶l̶d̶ ̶I̶ ̶b̶e̶ ̶d̶o̶i̶n̶g̶ ̶i̶t̶ ̶a̶n̶o̶t̶h̶e̶r̶ ̶w̶a̶y̶?̶

    The solution works beautifully in 2017.4.15f1 and the Vertical Layout Group also works substantially better.

    EDIT: I didn't change out the InputField Script to the Better InputField Script, it works perfectly in 2018.3.0f2, thank you!
     
    Last edited: Feb 7, 2019
    Hosnkobf likes this.
  5. MooseMouse

    MooseMouse

    Joined:
    Sep 14, 2011
    Posts:
    515
    Hi Hosnkobf,

    FYI, I am trying to build to an new iPad Pro via Unity 2018.2.20f1, and I am getting this error in Xcode:

    UnauthorizedAccessException: Access to the path "/var/containers/Bundle/Application/56F014C7-61B9-497F-BA04-64D3F6D526D0/happypaint.app/Data/TheraBytes" is denied.

    at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00000] in <00000000000000000000000000000000>:0

    at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00000] in <00000000000000000000000000000000>:0

    at TheraBytes.BetterUi.SingletonScriptableObject`1[T].EnsureInstance () [0x00000] in <00000000000000000000000000000000>:0

    at TheraBytes.BetterUi.SingletonScriptableObject`1[T].get_Instance () [0x00000] in <00000000000000000000000000000000>:0

    at TheraBytes.BetterUi.ResolutionMonitor.get_CurrentScreenConfiguration () [0x00000] in <00000000000000000000000000000000>:0

    at TheraBytes.BetterUi.SizeConfigCollection`1[T].GetCurrentItem (T fallback) [0x00000] in <00000000000000000000000000000000>:0

    at TheraBytes.BetterUi.BetterGridLayoutGroup.CalculateCellSize () [0x00000] in <00000000000000000000000000000000>:0



    (Filename: currently not available on il2cpp Line: -1)



    UnauthorizedAccessException: Access to the path "/var/containers/Bundle/Application/56F014C7-61B9-497F-BA04-64D3F6D526D0/happypaint.app/Data/TheraBytes" is denied.

    at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00000] in <00000000000000000000000000000000>:0

    at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00000] in <00000000000000000000000000000000>:0

    at TheraBytes.BetterUi.SingletonScriptableObject`1[T].EnsureInstance () [0x00000] in <00000000000000000000000000000000>:0

    at TheraBytes.BetterUi.SingletonScriptableObject`1[T].get_Instance () [0x00000] in <00000000000000000000000000000000>:0

    at TheraBytes.BetterUi.ResolutionMonitor.get_CurrentScreenConfiguration () [0x00000] in <00000000000000000000000000000000>:0

    at TheraBytes.BetterUi.SizeConfigCollection`1[T].GetCurrentItem (T fallback) [0x00000] in <00000000000000000000000000000000>:0

    at TheraBytes.BetterUi.BetterGridLayoutGroup.CalculateCellSize () [0x00000] in <00000000000000000000000000000000>:0

    UnityEngine.UnhandledExceptionHandler:printException(String, Exception)

    UnityEngine.UnhandledExceptionHandler:HandleUnhandledException(Object, UnhandledExceptionEventArgs)
     
  6. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    652
    Hi @MooseMouse,
    Thanks for the report. I recently removed the third party singleton scriptable object class and added an own implementation. Seems like I didn't test it enough.

    From the stack trace it looks like the resolution monitor has not been created in the editor, so it tries to create it at runtime. If this happens, I should write some error to the logs and should not create a file for it on runtime. Will be changed soon.

    Please let me know if you have a folder
    Assets/TheraBytes/Resources
    and what is inside.
    It would also be good to know when exactly the exception is thrown.
     
  7. MooseMouse

    MooseMouse

    Joined:
    Sep 14, 2011
    Posts:
    515
    On line 52 of SingletonScriptableObject.cs I made the following change to fix the problem:

    //string completeFilePath = Path.Combine(Application.dataPath, filePath);
    string completeFilePath = Path.Combine(Application.persistentDataPath, filePath);

    Apparently iOS needs "persistentDataPath"
     
  8. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    652
    This is not the intended use for the scriptable object singletons.
    The ScriptableObjectSingleton is a base class for two objects needed by Better UI: Materials and ResolutionMonitor.
    Those are ScriptableObjects so that you as a user can configure them to fit your needs.
    They are not in the package of Better UI. Instead they are created automatically the first time Better UI needs them (or when you select Window->TheraBytes->ScriptableObjects->Force ScriptableObjectSingleton Initialization). After they are created in your project you should check them out with the inspector (especially the Resolution Monitor) and adjust it for your needs.
    They are generated automatically (if not found) at the path
    Assets/TheraBytes/Resources
    and are not included in the package, so that you cannot accidentally overwrite them when you update to the latest version of Better UI.

    This is really important for me to know. Does the problem occur although you can find the ResolutionMonitor in your unity project? Is it maybe in your .gitignore or could there be another reason why it is not in the build?

    However, I changed the code, so that it shouldn't break your app anymore and instead logs an error message.

    In SingletonScriptableObject.cs please remove everything between
    filePath += ".asset";
    and
    creatingInstance = false;
    . Then paste the following code there:

    Code (CSharp):
    1.                 string resourceFilePath = Path.GetFileNameWithoutExtension(
    2.                         filePath.Split(new string[] { "Resources" }, StringSplitOptions.None).Last());
    3.  
    4.                 var obj = Resources.Load(resourceFilePath);
    5.                 instance = obj as T; // note: in the debugger it might be desplayed as null (which is not the case)
    6.  
    7.                 if(obj == null)
    8.                 {
    9.                     instance = CreateInstance<T>(); // note: in the debugger it might be desplayed as null (which is not the case)
    10. #if UNITY_EDITOR
    11.                     string completeFilePath = Path.Combine(Application.dataPath, filePath);
    12.                     string directory = Path.GetDirectoryName(completeFilePath);
    13.                     if (!Directory.Exists(directory))
    14.                     {
    15.                         Directory.CreateDirectory(directory);
    16.                     }
    17.  
    18.                     AssetDatabase.CreateAsset(instance, "Assets/" + filePath);
    19.                     AssetDatabase.Refresh();
    20.  
    21. #else
    22.                     Debug.LogErrorFormat(
    23.                         "Could not find scriptable object of type '{0}'. Make sure it is instantiated inside Unity before building.",
    24.                         typeof(T));
    25. #endif
    26.                 }
    27.                
    Please let me know if that works for you.
     
  9. MooseMouse

    MooseMouse

    Joined:
    Sep 14, 2011
    Posts:
    515
    Hi Hosnkobf,

    I had to pull out a bunch of your stuff to get it to build to iOS initially in Unity, and I removed the resources stuff. I don't remember what all I did (in a big hurry), so I just made a fresh project and tried to build your example scene without any changes on my part. Here are the errors I got in Unity:

    These errors showed up after importing your package. I restarted Unity and they went away:

    NullReferenceException: Object reference not set to an instance of an object

    TheraBytes.BetterUi.Materials.AddIfNotPresent (System.String name, System.Func`2 CreateMaterial, TheraBytes.BetterUi.MaterialEffect[] preservedLayerEffects) (at Assets/TheraBytes/BetterUI/Scripts/Utils/Materials.cs:144)

    TheraBytes.BetterUi.Materials.OnEnable () (at Assets/TheraBytes/BetterUI/Scripts/Utils/Materials.cs:51)

    UnityEngine.ScriptableObject:CreateInstance()

    TheraBytes.BetterUi.SingletonScriptableObject`1:EnsureInstance() (at Assets/TheraBytes/BetterUI/Scripts/Utils/ScriptableObjectManagement/SingletonScriptableObject.cs:64)

    TheraBytes.BetterUi.ScriptableObjectInstantiator:Initialize() (at Assets/TheraBytes/BetterUI/Scripts/Utils/ScriptableObjectManagement/ScriptableObjectInstantiator.cs:24)

    TheraBytes.BetterUi.ScriptableObjectInstantiator:.cctor() (at Assets/TheraBytes/BetterUI/Scripts/Utils/ScriptableObjectManagement/ScriptableObjectInstantiator.cs:16)

    UnityEditor.EditorAssemblies:processInitializeOnLoadAttributes()

    NullReferenceException: Object reference not set to an instance of an object

    TheraBytes.BetterUi.Materials.AddIfNotPresent (System.String name, System.Func`2 CreateMaterial, TheraBytes.BetterUi.MaterialEffect[] preservedLayerEffects) (at Assets/TheraBytes/BetterUI/Scripts/Utils/Materials.cs:144)

    TheraBytes.BetterUi.Materials.OnEnable () (at Assets/TheraBytes/BetterUI/Scripts/Utils/Materials.cs:51)






    ********************************************************************************************************
    These are the errors I get in Unity when I try to build to iOS:


    Assets/TheraBytes/BetterUI/Scripts/Utils/ScriptableObjectManagement/ScriptableObjectInstantiator.cs(11,6): error CS0246: The type or namespace name `InitializeOnLoad' could not be found. Are you missing an assembly reference?

    Assets/TheraBytes/BetterUI/Scripts/Utils/ScriptableObjectManagement/ScriptableObjectInstantiator.cs(19,10): error CS0246: The type or namespace name `MenuItem' could not be found. Are you missing an assembly reference?

    Assets/TheraBytes/BetterUI/Scripts/Utils/ScriptableObjectManagement/SingletonScriptableObject.cs(72,21): error CS0103: The name `AssetDatabase' does not exist in the current context

    Assets/TheraBytes/BetterUI/Scripts/Utils/ScriptableObjectManagement/SingletonScriptableObject.cs(73,21): error CS0103: The name `AssetDatabase' does not exist in the current context

    Error building Player because scripts had compiler errors

    Build completed with a result of 'Failed'

    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    UnityEditor.BuildPlayerWindow+BuildMethodException: 5 errors at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x0021f] in /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:187 at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x0007f] in /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:94

    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)



    I have to work on some other stuff for a bit, but will try to get back to it when I can. Hopefully this info will send you in the right direction in the meantime.
     
  10. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    652
    Thank you for your reports.

    Regarding the first error: I think this is the first known issue as described in the documentation of the changes. Couldn't find out yet what causes it, but it seems like everything works anyways. If you wanna be sure that nothing broke, make a BetterImage, assign a sprite to it and change the Material to Standard / Gayscale / Hue Saturation Brightness as well as the Material Effect and see if it renders as expected.

    Regarding the second error: This is also because of the scriptable singleton object changes which I didn't test yet in builds. Thanks for pointing out again.
    To fix it, put the content of ScriptableObjectInstantiator.cs inside a
    #if UNITY_EDITOR
    ...
    #endif
    statement and apply the changes from the previous post to SingletonScriptableObject.cs (or wait for the next beta, if you are busy).
     
  11. vonbetelgeuse

    vonbetelgeuse

    Joined:
    Aug 28, 2014
    Posts:
    124
    Could I put in a request for consideration?

    When using a BetterInputField that expands vertically it would be really neat if you could set a BetterContentSizeFitter - Has Min Height. At the moment if there's no text in the BetterInputField it contracts completely hiding the Placeholder text.

    I've been trying to change the BetterContentSizeFitter - Padding: Optimized Size via BetterInputField - On Value Changed but it seems to be reliant on a lot of other things.
     
    Last edited: Feb 19, 2019
  12. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    652
    Hi @vonbetelgeuse,
    I already implemented this feature for the next Beta.
    However, you can download the files you need here.
    Note that you need to drag the InputField-gameObject or its text object into the "Source" field and add a SizeChangeTracker to the Text object which has a reference to the object with the Better Content Size Fitter in order to make it work.
     
    Last edited: Feb 20, 2019
    vonbetelgeuse likes this.
  13. vonbetelgeuse

    vonbetelgeuse

    Joined:
    Aug 28, 2014
    Posts:
    124
    Awesome, thanks you! :)
     
  14. vonbetelgeuse

    vonbetelgeuse

    Joined:
    Aug 28, 2014
    Posts:
    124
    Hello!

    I'm getting the same couple of errors MooseMouse is getting when attempting to build to Android in Unity 2018.3.0f2, Better UI - v2.0 (Beta 1)

    Scripting Runtime Version: .Net 4.x Equivalent
    Scripting Backend: IL2CPP
    Api Compatibility: .Net Standard 2.0

    Assets\TheraBytes\BetterUI\Scripts\Utils\ScriptableObjectManagement\ScriptableObjectInstantiator.cs(11,6): error CS0246: The type or namespace name 'InitializeOnLoadAttribute' could not be found (are you missing a using directive or an assembly reference?)

    Assets\TheraBytes\BetterUI\Scripts\Utils\ScriptableObjectManagement\ScriptableObjectInstantiator.cs(11,6): error CS0246: The type or namespace name 'InitializeOnLoad' could not be found (are you missing a using directive or an assembly reference?)

    Assets\TheraBytes\BetterUI\Scripts\Utils\ScriptableObjectManagement\ScriptableObjectInstantiator.cs(19,10): error CS0246: The type or namespace name 'MenuItemAttribute' could not be found (are you missing a using directive or an assembly reference?)

    Assets\TheraBytes\BetterUI\Scripts\Utils\ScriptableObjectManagement\ScriptableObjectInstantiator.cs(19,10): error CS0246: The type or namespace name 'MenuItem' could not be found (are you missing a using directive or an assembly reference?)

    Error building Player because scripts had compiler errors

    Build completed with a result of 'Failed'
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    UnityEditor.BuildPlayerWindow+BuildMethodException: 5 errors
    at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x00234] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:190
    at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x0007f] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:96
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    IndexOutOfRangeException: Index was outside the bounds of the array.
    UnityEditor.Android.AndroidBuildWindowExtension.GetBuildPlayerWindow () (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEditor.Android.AndroidBuildWindowExtension.RepaintTargetList () (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:200)

    I'm actively working on this project, happy to help debugging.
     
  15. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    652
    Did you apply the suggested changes above? Especially:
    I hope I find time next week to refractor and test it myself and to release a second beta...
     
  16. vonbetelgeuse

    vonbetelgeuse

    Joined:
    Aug 28, 2014
    Posts:
    124
    I tried this but it's throwing up another two errors causing the build to fail:

    Assets\TheraBytes\BetterUI\Scripts\Utils\ScriptableObjectManagement\SingletonScriptableObject.cs(72,21): error CS0103: The name 'AssetDatabase' does not exist in the current context

    Assets\TheraBytes\BetterUI\Scripts\Utils\ScriptableObjectManagement\SingletonScriptableObject.cs(73,21): error CS0103: The name 'AssetDatabase' does not exist in the current context
     
  17. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    652
    Did you also apply this?
     
  18. vonbetelgeuse

    vonbetelgeuse

    Joined:
    Aug 28, 2014
    Posts:
    124
    I missed that, applied it and it's resolved the problem. Cheers!
     
    Hosnkobf likes this.
  19. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    652
    Better UI 2.0 Beta 2 is now ready.
    PM me if you want it.

    Several Changes / Improvements / Features and Fixes has been made. Here the highlights:
    • Scriptable Object initialization shouldn’t block builds anymore. (as mentioned in this thread)
    • Text Mesh Pro is available again! And it works Better now than before.
    • "Make Better" cares about references within prefabs now. So, you can make use of it inside Unity's new prefab editor.
    • In addition to the Max Size there is also a Min Size now for Better Content Size Fitters.
     
    Grumpy-Dot likes this.