Click here to Skip to main content
15,669,693 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to:
If the text is 10 then gameobject deletes?

<pre lang="C++">

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

public class UnityCollectItems : MonoBehaviour
    public int sceneNum;
    public GameObject scoreText;
    public int thescore;
    public AudioSource collectSound;

    void OnTriggerEnter(Collider other)
        theScore += 1;
        scoretext.GetComponent<Text>().text = "SCORE: " + theScore;
    public void IfScoreText()
    if (scoretext) 10 then:


What I have tried:

Please help!
How to:
If the text is 10 then gameobject deletes

Please help!
Updated 16-Dec-22 6:34am
Richard MacCutchan 16-Dec-22 12:15pm    
Well that is what the code is telling it to do.
OriginalGriff 16-Dec-22 12:34pm    
Apparently he's a spammer - check S&A
If so, this could be an attempt to "legitimize" hos account?
PIEBALDconsult 16-Dec-22 12:40pm    
Rick York 16-Dec-22 13:10pm    
That does not look like C++.

1 solution

Unity has a dedicated forum at Unity Forum[^]. You will likely get help faster from there.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900