Search Unity

error CS0029: Cannot implicitly convert type 'string' to 'UnityEngine.UI.Text'

Discussion in 'UGUI & TextMesh Pro' started by Average_developer, Jan 1, 2019.

  1. Average_developer

    Average_developer

    Joined:
    Jun 27, 2018
    Posts:
    3
    I was using this code from the roll the ball tutorial and I am receiving this error and I am unsure how to fix this.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class CollectingEssentialObjects : MonoBehaviour
    7. {
    8.     public Text essentialcountText;
    9.     public Text essentialwinText;
    10.     private int EssentialCount;
    11.  
    12.  
    13.  
    14.     void Start()
    15.     {
    16.         EssentialCount = 0;
    17.         essentialwinText = "";
    18.         SetEssentialCountText();
    19.     }
    20.     void SetEssentialCountText()
    21.     {
    22.         essentialcountText.text = "Essentials " + EssentialCount.ToString() + "/2";
    23.         if (EssentialCount >= 2)
    24.         {
    25.             essentialcountText.text = "";
    26.  
    27.         }
    28.     }
    29.  
    30.    
    31.    
    32.     void OnTriggerEnter(Collider other)
    33.     {
    34.         if (other.gameObject.CompareTag("Pick Up"))
    35.         {
    36.             other.gameObject.SetActive(false);
    37.             EssentialCount = EssentialCount + 1;
    38.             SetEssentialCountText();
    39.         }
    40.     }
    41.    
    42. }
    Any help will be greatly appreciated thank you in advance.
     
  2. bentontr

    bentontr

    Joined:
    Jun 9, 2017
    Posts:
    39
    Line 17 should be:
    Code (CSharp):
    1.  essentialwinText.text = "";
     
    Average_developer likes this.