커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
물방울이 보이지 않아요
undefined주차
북마크
함*주
댓글
3
추천
0
조회수
8
조회수
8
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


어제 강의 완강 후 재생을 했을 땐 빨간 물방울까지 다 보였는데 오늘 다시 프로젝트를 여니까 물방울이 보이지 않습니다. 재생하면 분명히 점수 변동이 있는데 원인을 모르겠어요 ㅜㅜ 무슨 문제인지 모르겠어서 코드와 설정 첨부해요

그리고 혹시 프로젝트를 하나의 파일로 저장하는 법이 있나요 지금은 그냥 유니티 허브 첫화면에서 이전 사용한 프로젝트를 열고 있는데 프로젝트 저장 경로에 어떤 파일을 열어야 프로젝트 파일이 열리는 지 모르겠습니다.



스파르타 즉문즉답



스파르타 즉문즉답



rain.cs

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


public class rain : MonoBehaviour
{
    int type;
    float size;
    int score;


    // Start is called before the first frame update
    void Start()
    {
        float x = Random.Range(-2.7f, 2.7f);
        float y = Random.Range(3.0f, 5.0f);
        transform.position = new Vector3(x, y, 0);


        type = Random.Range(1, 5);


        if (type == 1)
        {
            size = 1.2f;
            score = 3;
            GetComponent<SpriteRenderer>().color = new Color(100 / 255f, 100 / 255f, 255 / 255f, 255 / 255f);
        }
        else if (type == 2)
        {
            size = 1.0f;
            score = 2;
            GetComponent<SpriteRenderer>().color = new Color(130 / 255f, 130 / 255f, 255 / 255f, 255 / 255f);
        }
        else if (type == 3)
        {
            size = 0.8f;
            score = 1;
            GetComponent<SpriteRenderer>().color = new Color(150 / 255f, 150 / 255f, 255 / 255f, 255 / 255f);
        }
        else
        {
            size = 0.8f;
            score = -5;
            GetComponent<SpriteRenderer>().color = new Color(255 / 255f, 100 / 255f, 100 / 255f, 255 / 255f);
        }


        transform.localScale = new Vector3(size, size, 0);
    }


    // Update is called once per frame
    void Update()
    {
        
    }
    void OnCollisionEnter2D(Collision2D coll)
    {
        if (coll.gameObject.tag == "ground")
        {
            Destroy(gameObject);
        }
        if(coll.gameObject.tag == "rtan")
        {
            Destroy(gameObject);
            GameManager.I.addScore(score);
      
        }
    }


}


Gamemanager.cs

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




public class GameManager : MonoBehaviour
{
    public GameObject rain;
    public static GameManager I;
    public Text ScoreText;
    public Text timeText;
    public GameObject Panel;


    int TotalScore;
    float limit = 5f;




    void Awake()
    {
        I = this;
    }


    // Start is called before the first frame update
    void Start()
    {
        initGame();
        InvokeRepeating("makeRain", 0, 1f);
    }


    // Update is called once per frame
    void Update()
    {
            limit -= Time.deltaTime;
        if (limit < 0)
        {
            Time.timeScale = 0.0f;
            Panel.SetActive(true);
            limit = 0.0f;
        }
        timeText.text = limit.ToString("N2");


    }


    void makeRain()
    {
        Instantiate(rain);
    }


    public void addScore(int score)
    {
        TotalScore += score;
        ScoreText.text = TotalScore.ToString();
    }


    public void retry()
    {
        SceneManager.LoadScene("MainScene");
    }


    void initGame()
    {
        Time.timeScale = 1.0f;
        TotalScore = 0;
        limit = 30f;
    }
}


첨부파일 (1)

물방울.mp4
(8.637M)
취소
 공유
취소
댓글 0
댓글 알림
나의얼굴