GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - hackplayerz/Unity-Singleton: 유니티용 싱글턴 상속만 받으면 된다!

BranchesTags
Open more actions menu

Latest commit

 

History

7 Commits
7 Commits

Folders and files

NameName
Last commit message
Last commit date
.vs
.vs
 
 
UnitySingleton
UnitySingleton
 
 
README.md
README.md
 
 
UnitySingleton.sln
UnitySingleton.sln
 
 

Repository files navigation

Unity-Singleton

유니티용 싱글턴 상속만 받으면 된다!

2022-12-05 Ver.

싱글톤 클래스를 dll화하고 LazyInstance 적용

사용법

namespace : UnitySingleton
사용할 MonoBehavior 클래스에 상속받고 제네릭 사용

예시

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnitySingleton; // 싱글턴 사용을 위한 네임스페이스 임포트.

public class GameManager : DontDestroySingleton<GameManager> // DontDestry가 싫으면 Singleton<T>
{
    public bool IsPaused { get; private set; } = false;
    public bool IsGameOver { get; private set; } = false;

    public void SetIsPaused(bool isPaused)
    {
        IsPaused = isPaused;
    }

    public void SetIsGameOver(bool isGameOver)
    {
        IsGameOver = isGameOver;
    }

    public bool IsPlaying()
    {
        return !IsPaused || !IsGameOver;
    }
    
    /// <summary>
    /// 게임패드 플레이중인지 검사
    /// </summary>
    /// <returns>게임패드가 인식되었다면 true.</returns>
    public bool IsGamePadPlaying()
    {
        var joystick = Input.GetJoystickNames();
        foreach (var value in joystick)
        {
            // 연결된 게임패드 발견
            if (value != string.Empty)
            {
                return true;
            }
        }

        return false;
    }
}




참고:https://dev-nicitis.tistory.com/4

About

유니티용 싱글턴 상속만 받으면 된다!

Topics

singleton-patternunity3d

Resources

Readme
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.