ServiceProvider

사용되지 않는 항목 표시

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.

만들 수 없음
찾아볼 수 없음

서비스 공급자는 상속된 클래스에 따라 멤버로 사용하는 특정 단일 클래스를 저장하고 제공하는 추상 클래스입니다. A ServiceProvider is an abstract class, which stores, and provides certain singleton classes, depending on what inherited class you are using its members with.

요약

메서드

  • 병렬 쓰기

    지정된 className에 의해 이미 생성된 경우 지정된 서비스를 반환하고 유효하지 않은 이름에 대한 오류를 발생시킵니다.

  • 요청한 클래스 이름으로 서비스를 반환하고, 존재하지 않으면 생성합니다.

이벤트

속성

메서드

FindService

병렬 쓰기

지정된 className에 의해 이미 생성된 경우 지정된 서비스를 반환하고 유효하지 않은 이름에 대한 오류를 발생시킵니다.

매개 변수

className: string
기본값: ""

반환

코드 샘플

ServiceProvider:FindService

print(game:FindService("Part"))
--> nil
print(game:FindService("Workspace"))
--> Workspace

GetService

요청된 클래스 이름을 가진 서비스를 반환합니다.서비스의 이름으로 호출되면(예: Debris) 해당 서비스의 인스턴스가 반환됩니다.서비스가 아직 존재하지 않으면 생성되고 새 서비스가 반환됩니다.이것은 일부 서비스를 만드는 유일한 방법이며, 특이한 이름을 가진 서비스에도 사용할 수 있습니다(예:RunService의 이름은 "Run Service"입니다.

참고:

  • 이 함수는 className 매개 변수가 기존 클래스인 경우 nil 를 반환하지만 클래스가 서비스가 아닙니다.
  • 다른 개체에 있는 서비스를 가져오려고 시도하면 "독점 서비스Name이 이미 존재합니다"라는 오류가 발생합니다.

매개 변수

className: string

요청된 서비스의 클래스 이름.

기본값: ""

반환

요청된 서비스의 인스턴스.

코드 샘플

ServiceProvider:GetService

local BadgeService = game:GetService("BadgeService")
local GameSettings = UserSettings():GetService("UserGameSettings")
print(BadgeService)
print(GameSettings)

이벤트

Close

현재 장소가 종료될 때 발화합니다.


코드 샘플

This example prints "The place is closing" when the game.Close event fires.

ServiceProvider.Close

local function onClose()
print("The place is closing")
end
game.Close:Connect(onClose)

ServiceAdded

서비스가 생성될 때 해고됩니다.

매개 변수

service: Instance

ServiceRemoving

서비스가 제거될 때 발사됩니다.

매개 변수

service: Instance