Logo my studio is game, portfólio is developer game

3 Data Converters in Unity

Here I show 3 ways to convert data to game programming in Unity:

using System;
using UnityEngine;

public class Converters : MonoBehaviour
{
    private int life = 2;
    private string textLife = "3";
    private bool isDeath = true;

    private void Start()
    {
        // Converts a variable string to int
        life += int.Parse(textLife);
        Debug.Log("Life: " + life);

        // Converts a variable bool to int
        Debug.Log("My bool: " + Convert.ToInt32(isDeath));

        // Converts any value to string
        Debug.Log("My life: " + life.ToString() + " is death: " + isDeath.ToString() + "!");
    }
}

Make contact!

Did you like this content? Let's talk...

I'm a game developer, I use unity. If you want to develop something, tell me!