Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Better UI

Discussion in 'Assets and Asset Store' started by Hosnkobf, Jan 30, 2017.

  1. Meganoodle

    Meganoodle

    Joined:
    Jun 2, 2020
    Posts:
    1
    Hi guys got Better UI as part of a bundle.
    Just to clarify, Im fairly new to unity , Ive made a few games before using scripted languages IE C++, VB, VC and so on , Im now only just coming to grips with how a more visual platform works, which is surprisingly quite a steep learning curve. Ive been using C++ and others since the mid 90's.

    Im at the stage now where I need to redesign the UI in my current game, so I though I would give this a try.
    Ive read the documentation, watched some videos, still cant seem to figure how to use this asset.
    Ive taken the steps through the wizard, set the resolution to HD (landscape).
    Ive created a canvas as always, I try to add 'BetterUI' elements but they are all grayed out (unselectable).
    I dont think there is anything wrong with your asset , It is more probable that I am doing something wrong.
    I have looked for a quick start guide, or get started guide, Ive looked through your videos but they all seem to focus on a canvas that is already established and setup.
    Again I might be missing something here.
    Going by all the other users of your asset ,who seem to be using it without issue, I would say its more of a me problem than anything else.

    Is there such a video that takes you through the process of setting up a canvas and getting started with Better UI.
    Or is this asset more directed at advanced developers, (Although I cant believe anything can be worse than the Unity UI system).

    Normally I wouldnt make a post like this, and just set the asset aside as a dead one , but I noticed the forum is fairly active so Im reaching out for advice on what Im doing wrong.
     
  2. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Hi @Meganoodle,
    thanks for reaching out instead of putting the asset aside :)

    Better UI is an extension for UGUI. So, what you usually do, is creating a UI with UGUI and turning specific components into their better version (see Make Better Workflow). To create a canvas and everything you need, the easiest way is to rightclick in the Hierarchy window and select UI -> Canvas (or any other thing inside UI). This will create a Canvas with Canvas Scaler and Graphic Raycaster as well as an Event System for you (note that resizing features of Better UI only work if you have your Canvas Scaler set to "Constant Pixel Size"). Having these allow you to create UI. When you add a component, everything inside "UI" as well as "Layout" are for UI stuff. If you directly want to add a Better UI component, you can find a "Better UI" section with several sub sections beneath the "Add Component" button.

    I would recommend learning the basics of UGUI first and then explore what Better UI adds to that. Here is a good tutorial covering a lot of aspects of UI development with UGUI.

    Note that many developers find the tools Snap Anchors and Smart Parent very useful when developing UI (with or without Better UI components).

    I hope this helps. To be honest, I am not 100% sure where you are stuck.
    If you have any more specific questions, feel free to ask :)
     
  3. Alex_2022

    Alex_2022

    Joined:
    May 4, 2022
    Posts:
    16
    Hi @Hosnkobf , i feel like i have a noob question, but i need to ask. I have just started with BetterUI and i am interested in the align&distribute function. When i try that in a new Panel, everything works as expected. However, when i need to change my existing Panel, something goes wrong and text disappears.

    This is how the Panel looks like before the align-function:
    upload_2022-9-12_22-6-57.png

    Now i select the 3 objects (Image with text "Player 1", Toggle "Not Ready", Button "Button) in hierarchy and use align (Align-to-the-middle, align-to: Parent, Anchors follow Object). I would expect that the Button will be aligned, that is to say it should go down some pixels.

    However the result is this:
    upload_2022-9-12_22-10-0.png

    What am i doing wrong?
     
  4. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Hi @AlexTriesUnity
    From what you describe, you did everything correctly. It is very weird that things disappear.
    Please provide some more information:
    • Are the three elements as big as they appear (or do they have parents which are bigger / smaller)?
    • Which Render mode does your canvas use?
    • Is the UI rotated or scaled?
     
  5. aloften

    aloften

    Joined:
    Aug 25, 2017
    Posts:
    18
    I also have been experiencing this issue, but only in certain instances. I will try to debug, but I thought I would give you what I have discovered so far.

    1. Does not occur on every canvas, for me.
    2. Is specifically happening on my 2 canvas that are in world render mode and rotated on the y axis by 90 degrees. One of my canvas work fine with these tools even being in world render mode.
    3. All of my canvas that I am using betterui on right now are also being scaled down a bit but not all of them are having this issue.
    4. Im currently noticing this with snap anchors. (I did see an issue with the align tool, but I fiddled with the parent anchors and positions and this fixed the alignment tool - does not fix the snap tool)
    5. Does NOT have issues with Vertical snapping, but DOES have issues with horizontal snapping and snapping all borders.
    6. Sets the left and right to nan while setting x min and x max to -infinity and infinity.
    7. Using ctrl+z does not fix everything.
    8. I THINK Ive narrowed the problem down to the "CalculateMinAnchor" function in the snapanchorswindow.cs file
    9. ALSO...it looks like in that same function, you are sometimes dividing by 0. This is coming from "outersize". I think this is because Unity does not know how big the object is sometimes.
    10. It appears to be the fallback is also sometimes returning -infinity/infinity.
    I THINK...this is all coming from ToScreenRect() in your RectTransformExtensions.cs - It doesnt look like it is always returning the proper size - causing you to sometimes divide by zero. Thats how far I could get.

    I found 2 work arounds that fixes this. If I rotate the ENTIRE world around by 90 degrees, I can use the tools properly. Also, if I rotate my canvas back to have 0, 0, 0 rotation, the tools seem to work properly.

    Sorry for the large amount of information. Just wanted to help where I can. Let me know if you need more info.

    I have an idea to fix it, Ill let you know if it works.
     
  6. aloften

    aloften

    Joined:
    Aug 25, 2017
    Posts:
    18
    I think I found a solution, atleast for snap anchors(im sure it will apply anywhere the code needs to get size).

    For snap anchors, on the internal static function "SnapBorder", before anything is done I added...


    Code (CSharp):
    1. Canvas daCanvas = obj.GetComponentInParent<Canvas>();
    2.  
    3. Vector3 oldRotation = daCanvas.transform.rotation.eulerAngles;
    4.  
    5. daCanvas.transform.rotation = Quaternion.Euler(0, 0, 0);
    And then I added the following to the bottom of the function...
    Code (CSharp):
    1. daCanvas.transform.rotation = Quaternion.Euler(oldRotation.x, oldRotation.y, oldRotation.z);
    All this is really doing is rotation the canvas, then rotating it back. lol. Im not sure if this is the best solution or one you would wnat to reuse, but Ill probably use it for now. haha. :)
     
    Last edited: Sep 15, 2022
    Hosnkobf likes this.
  7. Alex_2022

    Alex_2022

    Joined:
    May 4, 2022
    Posts:
    16
    Hi @Hosnkobf, thank you for your response. First to answer your questions:
    - The three elements are as big as they appear. They are nested in a tree of Panels, which means the parent-Panels are a bit bigger in size, and i don't know if this causes a problem.
    upload_2022-9-15_12-12-50.png

    - The canvas uses Screen Space - Overlay render mode.
    - The UI is not rotated nor scaled. But it uses Layout-Groups with "Child Force Expand Hight/Width" enabled. Is this a problem?

    When i find time maybe next week, i will create the whole Menu again from scratch step-by-step, using the align-function between every step. Maybe i can find out what causes the problem.
     
  8. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    Last edited: Sep 15, 2022
  9. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Wow, @aloften
    Thank you very much for the detailed report and the suggested fix! I already fixed rotated parents similarly previously, but obviously I have overseen rotated canvases.
     
    aloften likes this.
  10. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    The size of the parent doesn't really matter.
    If the parent of the objects you want to align is a Layout Group, it would be a problem. You either set the transforms of the elements by hand (or by one of Better UI's tools) or use a layout group. you cannot do both.
    But if the layout group is higher up in the hierarchy, it shouldn't be a problem... So, if that is the case, reproduction steps would be very helpful.
     
  11. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Better UI has similar features but probably achieved a bit differently.
    I quickly checked out the screenshot and I would say, you can achieve everything they show with Better UI except the "Nested Responsive Containers".
     
    justtime likes this.
  12. lemmons

    lemmons

    Joined:
    Jun 20, 2016
    Posts:
    68
    When using Better Transitions on a component like Better Toggle is it possible to assign custom callbacks for each mode (normal/pressed/selected/etc.) from code? I'm trying to instantiate some UI objects at runtime and need to be able to trigger a method in another object with a reference to the object that was instantiated. If there's a better way of going about this, let me know!

    Once I grab the Better Toggle component it looks like there are options for BetterToggleTransitions, transition, ToggleTransitions, etc. but I'm too noob to figure out how to use them and I didn't see anything about them in your documentation.

    Thanks in advance!
     
  13. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Hi @lemmons,
    When I implemented the transitions, I didn't had in mind that somebody would like to set it up via code, so, it is not easy to do this.
    If you want to add something to the normal transitions, you need the "BetterTransitions" variable. The other in the toggle is for transitions between on and off state.

    here is some code:
    Code (CSharp):
    1.             // Create a transition object with the desired state names
    2.             var myTransition = new BetterUi.Transitions(BetterUi.Transitions.SelectionStateNames);
    3.  
    4.             // Set the mode of the transition, so the desired transition type can be retrieved
    5.             myTransition.SetMode(BetterUi.Transitions.TransitionMode.CustomCallback);
    6.  
    7.             // Get the TransitionStates object of the set mode and convert it to the corresponding type
    8.             var myCustomStates = myTransition.TransitionStates as BetterUi.CustomTransitions;
    9.  
    10.             // Convert all individual states to the corresponding type
    11.             var individualStates = myCustomStates.GetStates().OfType<BetterUi.CustomTransitions.CustomTransitionState>();
    12.  
    13.             // Iterate the states and assign the actual transition logic for each states
    14.             foreach (var state in individualStates)
    15.             {
    16.                 switch (state.Name) // states can be differentiated by their names
    17.                 {
    18.                     case "Normal":
    19.                         state.StateObject.AddListener(MethodForNormalState);
    20.                         break;
    21.                     case "Highlighted":
    22.                         state.StateObject.AddListener(MethodForHoverState);
    23.                         break;
    24.                     case "Pressed":
    25.                         state.StateObject.AddListener(MethodForPressedState);
    26.                         break;
    27.                     case "Selected":
    28.                         state.StateObject.AddListener(MethodForSelectedState);
    29.                         break;
    30.                     case "Disabled":
    31.                         state.StateObject.AddListener(MethodForDisabledState);
    32.                         break;
    33.                     default:
    34.                         Debug.LogError($"Unexpected state name: {state.Name}");
    35.                         break;
    36.                 }
    37.             }
    38.  
    39.             // finally add the created transition to the toggle
    40.             myBetterToggle.BetterTransitions.Add(myTransition);
     
    lemmons likes this.
  14. Gaban_

    Gaban_

    Joined:
    Feb 26, 2019
    Posts:
    2
    Hi,

    I just followed your instruction and moved Therabytes folder to my "Plugins" but i get an exception after doing that:

    Exception: static property 'FilePath' must not contain a Plugin folder.


    So there is no way to put your asset in the plugins folder?
     
  15. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Hi @Gaban_

    If a folder in a unity project has a special name, it can have special purpose. For the "SingletonScriptableObject" I created for Better UI, I make use of folders named "Resources", to be able to easily load the manager objects when needed.

    "Plugins" is also a special folder which is meant for non-c# dll imports (e.g. some C++ or Java code that is wrapped).

    I don't remember exactly why I throw the exception in case of a "Plugins" folder, but I think that a Resources folder cannot be inside a Plugins folder.
    You can try if I'm right or not by commenting out line 96 of file SingletonScriptableObject.cs.

    However, I would recommend not to use a folder name with special purpose for third party assets. I would rather name it "ThirdParty" or "Extensions" or something like that.
     
  16. psql

    psql

    Joined:
    Nov 19, 2015
    Posts:
    10
    Just copped the add-on, and i'm getting a blank "Pick Resolution" pane after running the wizard. Any tips?
    upload_2022-10-6_14-58-48.png
     
  17. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Hi @psql
    Are you using unity 2022?
    If so, you need to apply this fix.
     
    andreiagmu likes this.
  18. jmgek

    jmgek

    Joined:
    Dec 9, 2012
    Posts:
    103
    I don't fully understand what this offers over unitys system? All the videos I watched could be achieved with the stretch anchor presets (even text). What is the gain to using this?
     
  19. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Hi @jmgek
    yes, I know that there is the anchor menu in unity now
    upload_2022-10-20_15-15-17.png

    But in Better UI, the Snap Anchors Tool has more (or other) options and is a bit easier to work with, as the buttons speak for themselves (I would claim).
    upload_2022-10-20_15-24-48.png
    However, Better UI is much more than this anchor tool. There is also a tool to easier control rect transforms with children (Smart Parent), a tool to align or distribute a selection of rect transforms (Align & Distribute) and a tool for changing resolutions and previewing responsive designs (Pick Resolution).

    Responsive design means that you can have different positions / sizes / variables of ui elements for different screen types (e.g. Small Screen / Big Screen or Landscape / Portrait). See this Tutorial.

    Pretty much every UGUI component can be converted to a "Better" version of it with just two clicks ("Make Better" Workflow), enabling proper resizing as well as some additional options (e.g. multiple transitions for buttons / toggles / ...).

    I didn't go too much into detail here, because the text on the store page sums up the features of Better UI pretty well. If you want to know even more details, you can read the documentation online.
     
    andreiagmu likes this.
  20. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    @jmgek
    You wrote in your review for Better UI, that you faced compile errors. I apologize for this.
    Thank you very much for reporting this. Reports like this help me to keep Better UI compatible with all versions of Unity. In the next version I will make sure that there are no compile errors in any supported unity version of Better UI (however, whenever a new version of Unity is released, there is a risk that something breaks).

    I think, the review section is not a good place for bug reports. So, I answer you here instead. Maybe this will help somebody else in the future as well.

    You pointed out two things.
    First Problem:
    When you imported the asset, you probably hit "No" at this prompt:
    upload_2022-10-21_10-31-5.png

    Fortunately, this is very easy to fix anyway:
    Just double click the compile error in the console or open
    ResolutionMonitor.cs
    and find line 496.
    change it from:
                var prefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();

    to
                var prefabStage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();

    (Unity removed the "Experimental" from the namespace)

    Second Problem:
    You are right that proper namespaces should be used. But in this case, not Better UI is the problem (it uses namespaces everywhere). I assume that your Environment class is not in a namespace (or it is in a namespace that is not related to your project, like "UnityEngine"). The Betterizer has a
    using System;
    statement at the top of the class, which allows using the
    Environment
    class without qualifying it by its full namespace.
    To fix this, you have three options:

    Option A:
    Put your Environment class in a proper namespace.

    Option B:
    Open the Betterizer class and edit line 46, so that the Environment class is fully qualified:
    System.Environment.NewLine

    Alternately, you could also replace it with
    "\n"
    (but I'm not sure if this is interpreted as new line on all operating systems).

    Option C:
    In the Project window, navigate to
    TheraBytes/Packages
    and import
    asmdef_excl_TextMeshPro
    . This will put Better UI in their own assemblies, so it doesn't see your code.


    Hope you manage to get it running now and Better UI is useful for you :)
     
    Last edited: Oct 21, 2022
    ledshok and andreiagmu like this.
  21. andreiagmu

    andreiagmu

    Joined:
    Feb 20, 2014
    Posts:
    175
    Hi! I just started using Better UI today (I got it from a past bundle), and I already see many time-saving possibilities for UI work. :D
    Thank you for developing this asset! It mitigates many of the issues and annoyances of working with UGUI.

    I want to ask: Does Better UI's Screen Configurations support split-screen multiplayer UI?

    My game has a widescreen single-player mode, so I'll use a Landscape screen configuration for that.
    But it also features a split-screen two-player mode, using two cameras split vertically (similar to the game "It Takes Two", or "A Hat in Time").
    Each player camera will have its own canvas, with the player's stats and etc. And I'd like to use an alternate Portrait screen configuration for each player's UI, on each side of the screen.

    Can this be achieved with Better UI?
     
  22. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Hi @andreiagmu
    This is an interesting question you have. Better UI doesn't have a "split screen feature" out of the box, but I think, it is possible to achieve what you want to do:
    The key here is to trigger screen configurations manually. To do this, you need to define screen configurations manually and instead of checking for the Orientation, you check for a tag (see Screen Configurations -> Settings -> Check Tag)
    So:
    • Create a screen configuration, maybe name it "Split Screen" and check the box for "Check Tag" and enter a tag here (like
      SplitScreen
      ). You may want the optimized resolution to be rotated or even just half the width.
    • Make the whole HUD a prefab. Use the Pick Resolution Window to switch between default and split screen view (to simulate the screen configuration). Add BetterLocators to all relevant objects of the hud and adjust the positions / sizes for the fallback and split screen configurations.
    • In code, enable the split screen configuration:
      TheraBytes.BetterUi.ResolutionMonitor.AddScreenTag("SplitScreen");

      and disable it again
      TheraBytes.BetterUi.ResolutionMonitor.RemoveScreenTag("SplitScreen");

      where it makes sense.
    • Spawn the Hud with an empty object as parent and make sure it acts like a panel (it should fill up the parent). In case of split screen you have two empty parents where you instantiate two of the hud prefabs.
    • In case of split screen, you may want to add an Override Screen Properties component to the empty parent objects, instead of defining different optimized resolutions in the configuration itself (this makes sense if you have split-screen adaptive UI which would still use the whole screen as reference).
    Hope this works for you :)
     
    andreiagmu likes this.
  23. esmundoz

    esmundoz

    Joined:
    Sep 18, 2013
    Posts:
    12
    Hi, just bought this asset. I Use 2021.3.9f1, got the following errors:

    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ScreenType\IsScreenOfCertainDeviceInfo.cs(35,64): error CS0117: 'DeviceType' does not contain a definition for 'Unknown'

    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ScreenType\IsScreenOfCertainDeviceInfo.cs(42,64): error CS0117: 'DeviceType' does not contain a definition for 'Handheld'

    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ScreenType\IsScreenOfCertainDeviceInfo.cs(45,64): error CS0117: 'DeviceType' does not contain a definition for 'Console'

    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ScreenType\IsScreenOfCertainDeviceInfo.cs(48,64): error CS0117: 'DeviceType' does not contain a definition for 'Desktop'

    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ResolutionMonitor.cs(496,31): error CS0234: The type or namespace name 'PrefabStageUtility' does not exist in the namespace 'UnityEditor.Experimental.SceneManagement' (are you missing an assembly reference?)

    I cannot start the wizard either, as "Better UI" doesn't appear in the tools menu.
     
  24. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Hi @esmundoz,
    thanks for reporting.

    These errors are strange. "DeviceType" is an enum inside UnityEngine that should be available in every version. The only reason why this error can occur is that you have a class / struct / enum or delegate called "DeviceType" in your project which is not inside any namespace (or is a namespace itself).
    You can put that data structure inside a namespace or you can edit the BetterUI sourcecode by fully qualify the calls, like this:

    In
    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ScreenType\IsScreenOfCertainDeviceInfo.cs
    replace the the "IsScreenType()" method (line 30 - 63) with:

    EDIT: the code below is wrong and just kept for reference. Here is the correct code.
    Code (CSharp):
    1.         public bool IsScreenType()
    2.         {
    3.             switch (expectedDeviceInfo)
    4.             {
    5.                 case UnityEngine.DeviceInfo.Other:
    6.                     return SystemInfo.deviceType == DeviceType.Unknown
    7. #if XR
    8.                         && !(UnityEngine.XR.XRDevice.isPresent)
    9. #endif
    10.                         && !(TouchScreenKeyboard.isSupported);
    11.  
    12.                 case UnityEngine.DeviceInfo.Handheld:
    13.                     return SystemInfo.deviceType == DeviceType.Handheld;
    14.  
    15.                 case UnityEngine.DeviceInfo.Console:
    16.                     return SystemInfo.deviceType == DeviceType.Console;
    17.  
    18.                 case UnityEngine.DeviceInfo.Desktop:
    19.                     return SystemInfo.deviceType == DeviceType.Desktop;
    20.  
    21.                 case UnityEngine.DeviceInfo.TouchScreen:
    22.                     return TouchScreenKeyboard.isSupported;
    23.  
    24.                 case UnityEngine.DeviceInfo.VirtualReality:
    25. #if XR
    26.                     return UnityEngine.XR.XRDevice.isPresent;
    27. #else
    28.                     return false;
    29. #endif
    30.  
    31.                 default:
    32.                     throw new NotImplementedException();
    33.             }
    34.         }
    35.  
    This is a known issue with Unity 2021.2+.
    I already provided a manual fix here (this post also covers the other problem you are facing).

    If you have any further problems or questions, feel free to ask :)
     
    Last edited: Nov 2, 2022
  25. esmundoz

    esmundoz

    Joined:
    Sep 18, 2013
    Posts:
    12
    Thank you for your quick reply. Now I get the following errors:


    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ScreenType\IsScreenOfCertainDeviceInfo.cs(34,22): error CS0234: The type or namespace name 'DeviceInfo' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ScreenType\IsScreenOfCertainDeviceInfo.cs(35,64): error CS0117: 'DeviceType' does not contain a definition for 'Unknown'

    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ScreenType\IsScreenOfCertainDeviceInfo.cs(41,22): error CS0234: The type or namespace name 'DeviceInfo' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ScreenType\IsScreenOfCertainDeviceInfo.cs(42,64): error CS0117: 'DeviceType' does not contain a definition for 'Handheld'

    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ScreenType\IsScreenOfCertainDeviceInfo.cs(44,22): error CS0234: The type or namespace name 'DeviceInfo' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ScreenType\IsScreenOfCertainDeviceInfo.cs(45,64): error CS0117: 'DeviceType' does not contain a definition for 'Console'

    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ScreenType\IsScreenOfCertainDeviceInfo.cs(47,22): error CS0234: The type or namespace name 'DeviceInfo' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ScreenType\IsScreenOfCertainDeviceInfo.cs(48,64): error CS0117: 'DeviceType' does not contain a definition for 'Desktop'

    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ScreenType\IsScreenOfCertainDeviceInfo.cs(50,22): error CS0234: The type or namespace name 'DeviceInfo' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

    Assets\TheraBytes\BetterUI\Runtime\Scripts\Utils\ScreenType\IsScreenOfCertainDeviceInfo.cs(53,22): error CS0234: The type or namespace name 'DeviceInfo' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)
     
  26. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    oh, I'm stupid, sorry... I put the "UnityEngine" at the wrong places...
    This here should be correct:
    Code (CSharp):
    1.         public bool IsScreenType()
    2.         {
    3.             switch (expectedDeviceInfo)
    4.             {
    5.                 case DeviceInfo.Other:
    6.                     return SystemInfo.deviceType == UnityEngine.DeviceType.Unknown
    7. #if XR
    8.                         && !(UnityEngine.XR.XRDevice.isPresent)
    9. #endif
    10.                         && !(TouchScreenKeyboard.isSupported);
    11.  
    12.                 case DeviceInfo.Handheld:
    13.                     return SystemInfo.deviceType == UnityEngine.DeviceType.Handheld;
    14.  
    15.                 case DeviceInfo.Console:
    16.                     return SystemInfo.deviceType == UnityEngine.DeviceType.Console;
    17.  
    18.                 case DeviceInfo.Desktop:
    19.                     return SystemInfo.deviceType == UnityEngine.DeviceType.Desktop;
    20.  
    21.                 case DeviceInfo.TouchScreen:
    22.                     return TouchScreenKeyboard.isSupported;
    23.  
    24.                 case DeviceInfo.VirtualReality:
    25. #if XR
    26.                     return UnityEngine.XR.XRDevice.isPresent;
    27. #else
    28.                     return false;
    29. #endif
    30.  
    31.                 default:
    32.                     throw new NotImplementedException();
    33.             }
    34.         }
     
  27. esmundoz

    esmundoz

    Joined:
    Sep 18, 2013
    Posts:
    12
    Thank you, working without errors now.
     
    Hosnkobf likes this.
  28. TheRealNovelist

    TheRealNovelist

    Joined:
    Nov 19, 2019
    Posts:
    2
    Hello, I am currently making a VR project. Does the assets have to be flat screen dependent, and is it ok to use this as world space component?

    Please respond soon!
     
  29. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Hi @TheRealNovelist

    I personally never worked with VR and therefore cannot really tell you for sure if it works or not.
    But what I can tell you: Many things will work. However, the resizing features will may not behave as you would expect.
    All the other features, like Better Locator, Locations Animations and all the Better Transitions will most probably work.

    However, you will need to try yourself if it will work in your project setup. If not, you still have the option to refund the asset.
     
  30. TheRealNovelist

    TheRealNovelist

    Joined:
    Nov 19, 2019
    Posts:
    2
    It is ok, I also use the asset on Flatscreen games, so it is still worth the money.

    Thanks for the heads up
     
    Hosnkobf likes this.
  31. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    107
    Hi, I've got an existing game that i want to start implementing Better UI, but I'd like to do it over time, not all at once. So for example, I've got a new screen/menu that I'm planning on adding, and I'd like to use Better UI.

    Just want to confirm that installing Better UI, and going through setup wizard, etc. it won't affect any of the existing UI?
     
  32. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    @jimmying
    Yes, Better UI prepares some stuff with the wizard, but as long as you don't use any Better-UI components, they are not used. So, your existing UI is unaffected.
    Note that you can easily upgrade certain components of your existing UI with two clicks where you need it (Make them Better)
     
  33. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    107
  34. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    313
    would be good to have more examples or tutorials on it.. like app layouts ..noticed some of the doc page images aren't even upto with the betterui and not alot of guide on it.

    It is a useful addon, just gets complicated and had a few times where clicking something can completely destroy child object positions/sizes... sometimes undo works othertimes well hope I had a backup that wasn't too far back..

    I guess its a real problem with UGUI its plain terrible.. but I'm going with it as the new UI stuff just isn't mature and it doesn't have alot of decent addons to fill all the gaps that things like new widget ui adds and other ugui addons..

    I kinda look at this one as an essential even though my usage of it is not as advanced as I'd like...

    gradient.. currently its just 2 colors ...is it not possible to use the gradient itself where more colors could be used?
     
  35. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Thanks for the feedback. It is always a hassle to keep the documentation up to date. But while the images might not display the latest version of Better UI, the text should.
    Regarding tutorials: It would be helpful to know where you struggle or where you are missing information. I have the "developer glasses" on, so it is super hard for me to imagine what people need.

    I'm sorry for the trouble. I know this can happen with the smart parent tool with detached childs if the size becomes 0 (as mentioned in the documentation). I tried to at least support undo here but it turned out, it is a very difficult task.
    I also stumbled once upon a setup where some values in RectTransform became NaN. It is a long time ago already and I'm unsure if I fixed it or not (at least it didn't happen to me for a very long time). However, if you stumble upon a similar bug, there are two things you can do:
    1. Report me what you did, so I can try to reproduce and fix it.
    2. Change your inspector to Debug view and replace all values that are NaN with 0 (If I recall correctly, the order matters. So, sometimes the change doesn't work before you change a different NaN value).
    I can only underline this. The new UI System is great in many ways, but it lacks essential features.

    Better UI just adds or fixes things of uGUI. If you know how to work with uGUI, Better UI is not so much more to learn.
    So, you should learn not only the uGUI controls but also all the stuff inside the Layout category. Then find out that the arrangement of Horizontal / Vertical Layout Groups are often not what you would expect and realize that you often shouldn't use them and anchor your objects properly instead. You will then understand why the Tools in Better UI are very valuable and great time savers. You should know the "Make Better" workflow in Better UI. This will allow you to quickly find out about the differences between the uGUI components and the Better UI extensions of them.

    It is just two colors because I simply assign the colors to the vertices of the quad where the sprite is rendered on. This allows to basically have the same performance as with only one color. Also, it works with all shaders. A gradient with more colors would require an own shader - or a tessellation of the quad mesh. As this would require a lot of rework and maybe would break backwards compatibility, I probably will not implement this. From my experience you ususally need only two color gradients, or three, which can be achieved by putting two images next to each other. The need for real gradients is super rare, I claim.
     
  36. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    107
    Hey @Hosnkobf, are there any issues with moving the installation directory somewhere else?

    e.g. instead of ./Assets/TheraBytes, I move it to ./Assets/Plugins/TheraBytes?
     
  37. Norimoo

    Norimoo

    Joined:
    Sep 22, 2018
    Posts:
    3
    Hi, I need urgent help regarding your asset.
    I'm working on a deadline and I'm encountering weird behaviour regarding the Animation functionality of the
    BetterContentSizeFitter. I have debug logs that I believe will interest you, and I need help giving it the expected behaviour. Namely, it is constantly animating with other layout groups as children.
     
  38. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Hi @Unkonoire

    The animation functionality of the Better Content Size Fitter is in a Foldout named "Experimental", because it doesn't work in every setup.
    However, you can show me your setup, so I can try to reproduce the issue. But it is likely that the problem you are facing cannot be fixed (unless I would include the sourcecode of UGUI and change it here and there directly, which I will not do).
     
  39. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Hi,
    you would need to adjust some hardcoded paths. See this post.
    However, AFAIK it is not possible to have the generated configuration files inside a folder named "Plugins". See this post.
     
  40. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    313
    how to set new sprite/with color gradient new gradient... is no setter for this..
    Code (CSharp):
    1. var tmp_sprite = tmp_plate.PlateTexture.CurrentSpriteSettings;
    2. tmp_plate.PlateTexture.CurrentSpriteSettings = new BetterImage.SpriteSettings(PlateGraphicsKg[0],
    3.     tmp_sprite.ColorMode, tmp_sprite.PrimaryColor, tmp_sprite.SecondaryColor);

    Will reply to the last message.. but yeah not lot of docs or code samples
     
  41. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    313
    another one... just trying to update the brightness value with the image material already set as hue saturation brightness

    Code (CSharp):
    1. var tmp = plateTexture.MaterialProperties;
    2. if (plateEnabled) {
    3.     tmp.FloatProperties[2].Value = plateCalculator.plateBrightness;
    4. } else {
    5.     tmp.FloatProperties[2].Value = plateCalculator.plateBrightnessDisabled;
    6. }
    7.  
    8. plateTexture.MaterialProperties.FloatProperties = tmp.FloatProperties;
    doesn't work no change? what am I missing/doing wrong..
     
  42. chumomo

    chumomo

    Joined:
    Jun 30, 2017
    Posts:
    17
    Hello, my UI with Better Locator doesn't work in built APP for iOS, but works in Unity Editor。
    For example, elements still show at the bottom in Landscape mode even though I've Better Locatered them to the right side.
    My iPhone is 14 pro and 16 iOS version.
    Thanks!
     
  43. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    In the current version, this is not perfectly prepared (in the next version, it will work better). But this should work:
    Code (CSharp):
    1. myBetterImage.ColorMode = ColorMode.VerticalGradient;
    2. myBetterImage.color = Color.white;
    3. myBetterImage.SecondaColor = Color.black;
    4. myBetterImage.SetVerticesDirty();
    Note that this will not change the config data, so, if the screen config changes, the colors are overwritten again. To also change the current config, you can write in addition:
    Code (CSharp):
    1. myBetterImage.CurrentSpriteSettings.ColorMode = ColorMode.VerticalGradient;
    2. myBetterImage.CurrentSpriteSettings.PrimaryColor= Color.white;
    3. myBetterImage.CurrentSpriteSettings.SecondaColor = Color.black;

    ---

    See here.
    You have to write:
    Code (CSharp):
    1. // const int HUE = 0;
    2. // const int SATURATION = 1;
    3. const int BRIGHTNESS = 2;
    4.  
    5. float brightness = (plateEnabled)
    6.     ? plateCalculator.plateBrightness
    7.     : plateCalculator.plateBrightnessDisabled;
    8.  
    9. plateTexture.SetMaterialProperty(BRIGHTNESS, brightness);
     
    Slashbot64 likes this.
  44. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Did you create an IngameResolutionMonitor?
     
  45. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    313
    Will you make any improvements to the better axis aligned group or the grid ... finding it very difficult to try make this UI work without Flex or a way of having certain grid cells being wider and fall below if the width isn't enough for them.. would solve alot of problems

    seems new widgets ui has https://ilih.name/unity-assets/EasyLayout/docs/easylayout.html ... finding using that would help but there isn't a betterui version of that.. would be great if you could collab with that other addon.
     
  46. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Hi @Slashbot64,
    I see your need and I also had it from time to time.
    For only single-lined UIs you can go for AxisAlignedLayoutGroups with LayoutElements attached to the children.

    However, having flexible layouts that span over multiple rows and columns is a lot trickier.
    Since Better UI is extending existing UGUI components, it wouldn't very clean to integrate such functionality in the existing "BetterAxisAlignedLayoutGroup" or "BetterGridLayoutGroup". It would be better to introduce a completely new component for this.

    To answer your actual question:
    I didn't plan to implement this yet, but put it now on my backlog for investigation.
     
  47. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    107
    Hey @Hosnkobf can you explain how the 1inch/1cm rulers work in the examples? Because usually I use the Constant Physical Size scaler, but I noticed that you're not using that. My goal is to just set up ui elements that have a consistent physical size.
     
  48. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    313
    I hope so... kinda need it badly..... even BetterGridLayoutGroup ..if there was some way to put a LayoutElement that could override the cell width/height (mainly width to override) that would help as it already moves things to row below.
     
  49. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    107
    Is there a reason there's a difference between the Unity Image component and Better UI Image component when displaying images that have transparent space around the border?

    Attached image shows two images, the left is Unity Image, and the right is the Better UI version.

    The image used is an image with portrait ratio, that has an orange circle in the top half.

    I can fix the issue by using Full Rect as the Mesh Type in the import settings, but curious as to why they show differently.
     

    Attached Files:

  50. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    Hi @jimmying
    The sizers of Better UI only work with "Constant Pixel Size" scalers. each sizer has a Size Modification Section where you can specify what is used to apply sizing. Usually, you want to scale based on the screen's pixel height difference compared to the optimized size as defined in the resolution explorer. Sometimes you want to use pixel width instead. If you want to keep the physical size of an element, you can use "dpi" instead.
    Note that you can even mix multiple values to scale based on a combination of parameters (but this is almost never needed).

    The reason is: UGUI changed since the first version of Better UI. The code in Better UI is almost the same as it was in an earlier version of UGUI. However, I already fixed it. So, in the next version there will be no difference.