gui – What is the Unity 2019.3.5 version of `UnityEngine.UI.Text`?

I was following a tutorial on how to create a dialogue Box in Unity, and in one part of the tutorial the tutor imports UnityEngine.UI and creates an object of type Text, but my version of Unity is 2019.3.5f1 and I learned through searching a bit online that this UnityEngine.UI doesn’t exist anymore in this version, and that it was replaced with
UnityEngine.UIElements, and this Text type doesn’t exist anymore as well.

I couldn’t find a replacement for Text or what is the new nomenclature, nothing from trying stuff that popped in the auto complete or searching for answers in the Internet gave me answers. Maybe I just searched poorly, but if anyone happens to know, could you kindly answer?

Unity vs Unreal for Android [closed]

Does anyone out there have experience using the Unity or Unreal game engines for mobile development? Which one do you think is easier to port to Android or iOS?

unity – Workflow for authoring Pokémon-like game database content

I would generally not use a SQL database (not even SQLite) for handling static data in a singleplayer game. The only exception would be if I had so much data that it won’t all fit into RAM. But when the data is less than a couple hundred MB, I would look for a solution which loads all the data when the game starts and then allow the game to access it directly.

Solution within Unity: Scriptable Objects

A solution completely within Unity would be to work with scriptable objects. A scriptable object is a game-specific asset type. So you could create a class CreatureType : ScriptableObject. This enables you to create “CreatureType” assets in the Unity editor which you can then manage in the Unity project outline like any other Unity asset.

You can then assign these assets to inspector properties of MonoBehaviour‘s and thus assign them to prefabs or objects within your scene. You can also have ScriptableObjects referencing other ScriptableObjects. So you can, for example, have another ScriptableObject type for the various attacks your creatures can perform and then assign attacks to creature types via drag&drop.

When the standard controls for public fields are insufficient for your purpose, you can use Editor Scripting to enhance the inspector of these assets to better fulfill your game designers needs.

Working with files

However, scriptable objects have their limitations when it comes to editor support. While the Unity editor is very extensible, it can take a lot of development resources to to essentially reinvent what you can already do in a spreadsheet application.

So another solution is to keep the data in a file format editable with a spreadsheet application, import that file into a Unity project as a Text Asset and then load and parse that file at game start.

Perhaps the most developer-friendly format for that is CSV, because:

  • It can be handled by most spreadsheet applications, but can also be edited with a simple text editor when in a pinch.
  • It is very easy to write a parser for it.
  • The raw files are pretty human-readable and use one text-line per data entry, which means it can be handled well by text-based version control systems like Git.

But depending on the needs of your designers you might need to compromise and use a more advanced spreadsheet file format.

Unity: Is there any alternative to facebook SDK for facebook ads attribution?

We have a Unity mobile game.
We will be showing ads for it on facebook audience network.
Now in the past when we tried this, the CPI started out good and then got terrible.. Facebook have told us that to avoid this we need to have the facebook sdk installed in our game.

But the facebook Unity SDK is the bane of my existence. In every project Ive added it to over the years, I have spent so many days bashing my face against the brick wall of getting it to build and run, and when it does the weird workaround solution is incredibly fragile.

My question is.. Do we really need the SDK? What do devs using game engines without an SDK provided by facebook do? Is there an API we can call? Surely the SDK itself is calling some api to do the attribution which allows facebook to optimise the CPI for the ads. Can we just call that?

At this point I would try any alternative.

Blender animation’s curled fingers are splayed-out when played in Unity

I have exported my character into Unity and all the animations came with it. At first, I thought I was good to go but then I made a jogging animation. In blender the hands are gripped like this:

Image of the character animations working in Blender.

When this animation is exported to Unity the hands are no longer gripped and look like this:

Image of the character animations not working in Unity

Here are some more pictures showing the settings I have on my animation first in Blender:

enter image description here

Next in Unity:

enter image description here

So far I have tried:
Checking if the animations were updated in Unity (They were),
Reimporting the Unity model,
Looking through the animation properties in Blender,
Looking through the animation properties in Unity

I’ve been stuck on this for a few days now and I would appreciate some help as this is getting quite frustrating.

c# – Inventory Bug in unity

Hello so I made an inventory in unity that when I collide with the item medkit it puts the medkit into my inventory. And there is a problem, the medkit appears in the inventory slot but also appears over the player. Below is my inventory code. The MedicalInventory script is on the player and the MedicalPickup script is on the pickup item.

    public class MedicalInventory : MonoBehaviour
{
    public bool() isFull;
    public GameObject() slots;
}

Now here is my item pick up code.

public class MedicalPickup : MonoBehaviour
{
    private MedicalInventory medInventory;
    public GameObject itemButton;

    private void Start()
    {
        medInventory = GameObject.FindGameObjectWithTag("Player").GetComponent<MedicalInventory>();
    }

    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Player"))
        {
            for (int i = 0; i < medInventory.slots.Length; i++)
            {
                if (medInventory.isFull(i) == false)
                {
                    medInventory.isFull(i) = true;
                    Instantiate(itemButton, medInventory.slots(i).transform, false);
                    Destroy(gameObject);
                    break;
                }
            }
        }
    }
}

Please help. Thanks!

unity – How do I properly initialize UDP SDK?

When uploading my game to Unity Distribution Portal (UDP), I kept on receiving this message about sandbox testing:

It seems your game was never tested in the UDP Sandbox environment, as no UDP Initialization call was found on the UDP back-end.
Launch your APK in the UDP Sandbox environment to ensure it initializes properly. You must complete this step to release your game.

Now, I initially thought that Unity sandbox testing was enabled as soon as you installed the UDP plugins, but I have read that you need to make a script like this for the testing procedures to pass:

public class InitListener : IInitListener
{  
     public void Initialize()
     {
          StoreService.Initialize(IInitListener listener);
     }
     public void OnInitialized(UserInfo userInfo)
     {
          Debug.Log("Initialization succeeded"); 
     }
     public void OnInitializeFailed(string message)
     {
          Debug.Log("Initialization failed: " + message);
     }
}

However, I kept on encountering a syntax error that said

InitListener.cs(9,49): error CS1003: Syntax error, ‘,’ expected

…Even though there’s no need for a “,”. Even then, what am I supposed to do with this initialization script? Where do I assign it?

Thank you for reading.

unity – What’s the best way to make a game launcher?

I am a new game dev, and would like to make a launcher for my games. All my games would be in ONE launcher, and it’d be similar to the Minecraft Launcher. I wanna do it for free too.

The main reason I wanna do it is to update my games. I don’t have a file server, so the files would be on Google Drive.

Thanks!

unity – How to move one Game unit with every key press?

This solution is for grid based games. The idea is to have “turns”. A turn will happen regardless of whatever or not there is input or not. At the end of the turn the avatar will be aligned to the grid, and a turn always takes the same time.

Pseudo-code:

var current_time = get_current_time();
var elapsed_time = current_time - start_time;
var got_input = get_input();
input = got_input ?? input;
if (elapsed_time > turn_duration)
{
    elapsed_time -= turn_duration;
    start_time += turn_duration;
    start_position = end_position;
    end_position = compute_next_position(start_position, input);
}

current_position = interpolate(start_position, end_position, elapsed_time);

The duration of the turn can be computed from the velocity and the size of the grid. We know that speed = distance / time, solve for time:

speed = distance / time

=>

time * speed = distance

=>

time = distance / speed

Thus:

turn_duration = grid_side_length / speed;

We are storing where it was at the start of the “turn”, and where it will be at the end of the turn. Those positions should be aligned to the grid. We use the elapsed time since the start of the turn to compute the current position via interpolation.

When, the turn ends, we use the input and the last position to compute the next position. That would be the position plus the size of the grid in the direction dictated by input, if any.

You can buffer input if you like. You can treat no input as going in the same direction if you like.


We can make the end_position nullable (declare it Vector2? instead of Vector2), and take that as signal that no movement is happening at the moment. We can also work with end_time instead of elapsed_time. Similarly make end_time nullable.

var current_time = get_current_time();
var got_input = get_input();
input = got_input ?? input;

if (input != null && end_position == null)
{
    start_time = current_time;
    end_time = start_time + turn_duration;
    start_position = current_position;
    end_position = compute_next_position(start_position, input);
}

if (end_time == null || end_position == null)
{
    return;
}

if (current_time > end_time.Value)
{
    current_position = end_position.Value;
    end_position = null;
    end_time = null;
}
else
{
    current_position = interpolate(start_position, end_position.Value, elapsed_time);
}

The above code differs in that it will move when it gets some input, and stays there until new input arrive. Note, however, that it will not interrupt the current motion. I do not know what you may want to happen when a key is pressed while the object is moving, it varies from game to game. However, the key to interrupt the motion is to drop the check for end_position == null, and be careful to set the new end_position still on the grid.


In my implementation for Unity and Godot, I made a Motion struct to encapsulate some of this. It holds start and end position, and also duration, and will do the interpolation given the elapsed time since the start of the motion. I also ended up accumulating delta time (Time.deltaTime) instead of using current time.

My code looks something like this (this is Unity code):

if (!_motion.HasValue)
{
    var nextMotion = NextMotion(transform.position, GetNewTarget(), speed);
    if (nextMotion != null)
    {
        _motion = nextMotion;
        _time = 0.0f;
    }
}

if (!_motion.HasValue)
{
    return;
}

_time += Time.deltaTime;
var motion = _motion.Value;
if (_time > motion.Duration)
{
    _motion = null;
    transform.position = motion.End;
}
else
{
    transform.position = motion.GetCurrent(_time);
}

GetNewTarget() computes a target position based on input. In your case, it should check the input, and if there is any, add to the current position the length of the side of the grid in the appropriate direction.

NextMotion creates a new motion, given the current position, the target position, and the speed.

As you can imagine GetCurrent is a linear interpolation. Its code is simply:

return Start + ((End - Start) * time / Duration);

Where Duration is pre-computed as:

var diff = end - start;
var length = diff.magnitude;
Duration = length / speed;

If you want to allow interrupting motion, the code should look something like this:

var target = GetNewTarget();

if (!_motion.HasValue || _motion.Value.End != target)
{
    var nextMotion = NextMotion(transform.position, target, speed);
// ...

And GetNewTarget would work from the start position of the current motion if any, if there is no current motion the use the current position.

shaders – Unity: Efficient way to get the average pixel color for a portion of the camera viewport

At it’s core, the problem I’m trying to solve is this:
I have a camera (not main) that I would like to project to a 2 pixel RenderTexture. I would like the first pixel to be the average color of all pixels in the left portion of the camera viewport (or a close approximation). And the second pixel to be the average color of all pixels in the right portion of the camera viewport.

So far I’ve looked into doing this via OnRenderImage(src, dest) but I’m open to any suggestions. Same goes with camera resolutions, 256×256 seems like a good starting point but open to suggestions here too. It’s worth mentioning that I just threw together a brute-force non threaded approach that works but totally tanks FPS (nothing surprising)

Any help would be greatly appreciated. This doesn’t seem like an incredibly weird downscaling approach but I can’t seem to find anything regarding it. There might be a clever way of dealing with this via a shader but I have yet to find it. Bilinear downscaling (which I think is what unity uses by default) sadly does not give the appropriate result.

System compatibility is not an issue, Win 10, DX 12.