Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

All Counts

Discussion in 'Scripting' started by gagac42, Aug 18, 2020.

  1. gagac42

    gagac42

    Joined:
    Apr 24, 2018
    Posts:
    119
    Helllo who help me i create sript but not all work i need check up all matchdates if at least 1 conformity in day script setactive true else secattive false ....here is script

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class DateEnable : MonoBehaviour
    4. {
    5.     public string date;
    6.     public string[] matchdates;
    7.  
    8.     private void Awake()
    9.     {
    10.  
    11.         date = System.DateTime.Now.ToString("dd/MM/yyyy");
    12.     }
    13.  
    14.     void Start()
    15.     {
    16.      
    17.  
    18.      
    19.     }
    20.  
    21.     // Update is called once per frame
    22.     void Update()
    23.     {
    24.         for (int i = 0; i < matchdates.Length; i++)
    25.         {
    26.  
    27.             if (date == matchdates[i] )
    28.             {
    29.                 this.gameObject.SetActive(true);
    30.             }else
    31.                 this.gameObject.SetActive(false);
    32.         }
    33.     }
    34. }
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    Try this:
    Code (CSharp):
    1.     void Update()
    2.     {
    3.         for (int i = 0; i < matchdates.Length; i++)
    4.         {
    5.             if (date == matchdates[i] )
    6.             {
    7.                 this.gameObject.SetActive(true);
    8.                 return;
    9.             }
    10.         }
    11.  
    12.         this.gameObject.SetActive(false);
    13.     }
     
  3. gagac42

    gagac42

    Joined:
    Apr 24, 2018
    Posts:
    119
    thanks verry much