Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
ajuste na exibição do texto
Fonte Link
rLinhares
  • 8,1mil
  • 32
  • 29
  • 47
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CarShop : MonoBehaviour {

    public string carroSelected;
    public Text velMaxima;
    public Text Acele;
    public Text cambio;
    public Text Motor;
    public GameObject capContorno;
    public GameObject copContorno;
    public GameObject viaContorno;
    public GameObject nviaContorno;
    
    // Use this for initialization
    void Start () {
        velMaxima.text = "0 km/H";
        Acele.text = "0s";
        cambio.text = "0 Marchas";
        Motor.text = "NULL";
    }
    
    // Update is called once per frame
    void Update () {
        
    }
    
    public void capitalSel () {
        carroSelected = "Capital";
        velMaxima.text = "110 km/h";
        Acele.text = "21.90s";
        cambio.text = "4 Marchas";
        Motor.text = "Boxxer";
        capContorno.SetActive(true);
        copContorno.SetActive(false);
        viaContorno.SetActive(false);
        nviaContorno.SetActive(false);
    }
    
    public void copaSel () {
        carroSelected = "Copa";
        velMaxima.text = "170 km/h";
        Acele.text = "10.3s";
        cambio.text = "5 Marchas";
        Motor.text = "AP (Alta Performance)";
        capContorno.SetActive(true);
        copContorno.SetActive(false);
        viaContorno.SetActive(false);
        nviaContorno.SetActive(false);
    }
    
    public void viagemSel () {
        carroSelected = "Viagem";
        velMaxima.text = "170 km/h";
        Acele.text = "11.5s";
        cambio.text = "5 Marchas";
        Motor.text = "AP (Alta Performance)";
        capContorno.SetActive(true);
        copContorno.SetActive(false);
        viaContorno.SetActive(false);
        nviaContorno.SetActive(false);
    }
    
    public void nViagemSel () {
        carroSelected = "Novo Viagem";
        velMaxima.text = "190 km/h";
        Acele.text = "10s";
        cambio.text = "5 Marchas";
        Motor.text = "Power EA";
        capContorno.SetActive(true);
        copContorno.SetActive(false);
        viaContorno.SetActive(false);
        nviaContorno.SetActive(false);
    }   
}

}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CarShop : MonoBehaviour {

public string carroSelected;
public Text velMaxima;
public Text Acele;
public Text cambio;
public Text Motor;
public GameObject capContorno;
public GameObject copContorno;
public GameObject viaContorno;
public GameObject nviaContorno;

// Use this for initialization
void Start () {
    velMaxima.text = "0 km/H";
    Acele.text = "0s";
    cambio.text = "0 Marchas";
    Motor.text = "NULL";
}

// Update is called once per frame
void Update () {
    
}

public void capitalSel () {
    carroSelected = "Capital";
    velMaxima.text = "110 km/h";
    Acele.text = "21.90s";
    cambio.text = "4 Marchas";
    Motor.text = "Boxxer";
    capContorno.SetActive(true);
    copContorno.SetActive(false);
    viaContorno.SetActive(false);
    nviaContorno.SetActive(false);
}

public void copaSel () {
    carroSelected = "Copa";
    velMaxima.text = "170 km/h";
    Acele.text = "10.3s";
    cambio.text = "5 Marchas";
    Motor.text = "AP (Alta Performance)";
    capContorno.SetActive(true);
    copContorno.SetActive(false);
    viaContorno.SetActive(false);
    nviaContorno.SetActive(false);
}

public void viagemSel () {
    carroSelected = "Viagem";
    velMaxima.text = "170 km/h";
    Acele.text = "11.5s";
    cambio.text = "5 Marchas";
    Motor.text = "AP (Alta Performance)";
    capContorno.SetActive(true);
    copContorno.SetActive(false);
    viaContorno.SetActive(false);
    nviaContorno.SetActive(false);
}

public void nViagemSel () {
    carroSelected = "Novo Viagem";
    velMaxima.text = "190 km/h";
    Acele.text = "10s";
    cambio.text = "5 Marchas";
    Motor.text = "Power EA";
    capContorno.SetActive(true);
    copContorno.SetActive(false);
    viaContorno.SetActive(false);
    nviaContorno.SetActive(false);
}

}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CarShop : MonoBehaviour {

    public string carroSelected;
    public Text velMaxima;
    public Text Acele;
    public Text cambio;
    public Text Motor;
    public GameObject capContorno;
    public GameObject copContorno;
    public GameObject viaContorno;
    public GameObject nviaContorno;
    
    // Use this for initialization
    void Start () {
        velMaxima.text = "0 km/H";
        Acele.text = "0s";
        cambio.text = "0 Marchas";
        Motor.text = "NULL";
    }
    
    // Update is called once per frame
    void Update () {
        
    }
    
    public void capitalSel () {
        carroSelected = "Capital";
        velMaxima.text = "110 km/h";
        Acele.text = "21.90s";
        cambio.text = "4 Marchas";
        Motor.text = "Boxxer";
        capContorno.SetActive(true);
        copContorno.SetActive(false);
        viaContorno.SetActive(false);
        nviaContorno.SetActive(false);
    }
    
    public void copaSel () {
        carroSelected = "Copa";
        velMaxima.text = "170 km/h";
        Acele.text = "10.3s";
        cambio.text = "5 Marchas";
        Motor.text = "AP (Alta Performance)";
        capContorno.SetActive(true);
        copContorno.SetActive(false);
        viaContorno.SetActive(false);
        nviaContorno.SetActive(false);
    }
    
    public void viagemSel () {
        carroSelected = "Viagem";
        velMaxima.text = "170 km/h";
        Acele.text = "11.5s";
        cambio.text = "5 Marchas";
        Motor.text = "AP (Alta Performance)";
        capContorno.SetActive(true);
        copContorno.SetActive(false);
        viaContorno.SetActive(false);
        nviaContorno.SetActive(false);
    }
    
    public void nViagemSel () {
        carroSelected = "Novo Viagem";
        velMaxima.text = "190 km/h";
        Acele.text = "10s";
        cambio.text = "5 Marchas";
        Motor.text = "Power EA";
        capContorno.SetActive(true);
        copContorno.SetActive(false);
        viaContorno.SetActive(false);
        nviaContorno.SetActive(false);
    }   
}
Fonte Link

Ativar um objeto e desabilitar os demais

Eu estou fazendo um sistema de loja de carros na engine Unity, e preciso de um método para ativar um tipo de contorno no carro selecionado.Porém, eu preciso que o contorno dos outros carros se desativem automaticamente. O script que eu já tenho é esse:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CarShop : MonoBehaviour {

public string carroSelected;
public Text velMaxima;
public Text Acele;
public Text cambio;
public Text Motor;
public GameObject capContorno;
public GameObject copContorno;
public GameObject viaContorno;
public GameObject nviaContorno;

// Use this for initialization
void Start () {
    velMaxima.text = "0 km/H";
    Acele.text = "0s";
    cambio.text = "0 Marchas";
    Motor.text = "NULL";
}

// Update is called once per frame
void Update () {
    
}

public void capitalSel () {
    carroSelected = "Capital";
    velMaxima.text = "110 km/h";
    Acele.text = "21.90s";
    cambio.text = "4 Marchas";
    Motor.text = "Boxxer";
    capContorno.SetActive(true);
    copContorno.SetActive(false);
    viaContorno.SetActive(false);
    nviaContorno.SetActive(false);
}

public void copaSel () {
    carroSelected = "Copa";
    velMaxima.text = "170 km/h";
    Acele.text = "10.3s";
    cambio.text = "5 Marchas";
    Motor.text = "AP (Alta Performance)";
    capContorno.SetActive(true);
    copContorno.SetActive(false);
    viaContorno.SetActive(false);
    nviaContorno.SetActive(false);
}

public void viagemSel () {
    carroSelected = "Viagem";
    velMaxima.text = "170 km/h";
    Acele.text = "11.5s";
    cambio.text = "5 Marchas";
    Motor.text = "AP (Alta Performance)";
    capContorno.SetActive(true);
    copContorno.SetActive(false);
    viaContorno.SetActive(false);
    nviaContorno.SetActive(false);
}

public void nViagemSel () {
    carroSelected = "Novo Viagem";
    velMaxima.text = "190 km/h";
    Acele.text = "10s";
    cambio.text = "5 Marchas";
    Motor.text = "Power EA";
    capContorno.SetActive(true);
    copContorno.SetActive(false);
    viaContorno.SetActive(false);
    nviaContorno.SetActive(false);
}

}