Doubt over C # int [-1,1]

0

Good person, I made a script where it exchanges objects with setactive in int connected to onclick buttons 1,2,3,4 and so on

I need help from you to make the exchange of the int to -1,1 in the onclick buttons the idea would be like this

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

public class trocarobjetos : MonoBehaviour 
{
   private List<GameObject> modelos;
   private int selecaoIndex = 0;

   private void Start()
   {
      modelos= new List<GameObject>();
      foreach(Transform t in transform)
      {
         modelos.Add(t.gameObject);
         t.gameObject.SetActive(false);
      }
      modelos[selecaoIndex].SetActive(true);
   }
   public void SelecionarObjeto(int index)
   {
      if(index ==selecaoIndex)
         return;

      if(index < 0 || index >= modelos.Count)
         return;

      modelos[selecaoIndex].SetActive(false);
      selecaoIndex = index;
      modelos[selecaoIndex].SetActive(true);
   }
}
    
asked by anonymous 09.10.2017 / 03:10

0 answers