2024. 8. 22. 19:14
게임/VRChat
공식문서 : https://creators.vrchat.com/sdk/build-pipeline-callbacks-and-interfaces/
https://gist.github.com/ahzkwid/38df2817c709ace268d843ecba7a7f95
using System.Reflection;
using UnityEngine;
using VRC.SDK3A.Editor;
using VRC.SDKBase;
using VRC.SDKBase.Editor.BuildPipeline;
public class VRCBuildProcessor : IVRCSDKBuildRequestedCallback, IVRCSDKPreprocessAvatarCallback
{
public bool OnPreprocessAvatar(GameObject avatarGameObject)
{
Debug.Log($"PreprocessAvatar.{System.DateTime.Now}");
return true;
}
public int callbackOrder => 0;
public bool OnBuildRequested(VRCSDKRequestedBuildType requestedBuildType)
{
Debug.Log($"BuildRequested.{System.DateTime.Now}");
//선택된 아바타
VRC_AvatarDescriptor selectedAvatar = null;
{
var fieldInfo = typeof(VRCSdkControlPanelAvatarBuilder).GetField("_selectedAvatar", BindingFlags.Static | BindingFlags.NonPublic);
selectedAvatar = (VRC_AvatarDescriptor)fieldInfo.GetValue(null);
}
VRCSdkControlPanelAvatarBuilder builder = null;
{
var fieldInfo = typeof(VRCSdkControlPanelAvatarBuilder).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic);
builder = (VRCSdkControlPanelAvatarBuilder)fieldInfo.GetValue(null);
}
builder.OnSdkBuildStart -= BuildStart;
builder.OnSdkBuildProgress -= BuildProgress;
builder.OnSdkBuildFinish -= BuildFinish;
builder.OnSdkBuildSuccess -= BuildSuccess;
builder.OnSdkBuildStart += BuildStart;
builder.OnSdkBuildProgress += BuildProgress;
builder.OnSdkBuildFinish += BuildFinish;
builder.OnSdkBuildSuccess += BuildSuccess;
void BuildStart(object sender, object target)
{
Debug.Log($"BuildStart.{System.DateTime.Now}");
}
void BuildProgress(object sender, string status)
{
Debug.Log($"BuildProgress.{System.DateTime.Now}");
builder.OnSdkBuildProgress -= BuildProgress;
}
void BuildFinish(object sender, string status)
{
Debug.Log($"BuildFinish.{System.DateTime.Now}");
builder.OnSdkBuildFinish -= BuildFinish;
}
void BuildSuccess(object sender, string path)
{
Debug.Log($"BuildSuccess.{System.DateTime.Now}");
builder.OnSdkBuildSuccess -= BuildSuccess;
}
// 빌드를 계속 진행하려면 true, 중단하려면 false를 반환합니다.
return true;
}
}
using System;
using System.Threading.Tasks;
namespace VRC.SDKBase.Editor
{
/// <summary>
/// This is the public interface you, as a user of the SDK, can use to interact with the SDK Builder
/// </summary>
public interface IVRCSdkBuilderApi: IVRCSdkControlPanelBuilder
{
// Build Events
event EventHandler<object> OnSdkBuildStart;
event EventHandler<string> OnSdkBuildProgress;
event EventHandler<string> OnSdkBuildFinish;
event EventHandler<string> OnSdkBuildSuccess;
event EventHandler<string> OnSdkBuildError;
event EventHandler<SdkBuildState> OnSdkBuildStateChange;
SdkBuildState BuildState { get; }
// Upload Events
event EventHandler OnSdkUploadStart;
event EventHandler<(string status, float percentage)> OnSdkUploadProgress;
event EventHandler<string> OnSdkUploadFinish;
event EventHandler<string> OnSdkUploadSuccess;
event EventHandler<string> OnSdkUploadError;
event EventHandler<SdkUploadState> OnSdkUploadStateChange;
SdkUploadState UploadState { get; }
// Shorthand methods
// for shorthand build and upload methods check the Avatars and Worlds SDKs respectively
void CancelUpload();
}
public enum SdkBuildState
{
Idle,
Building,
Success,
Failure
}
public enum SdkUploadState
{
Idle,
Uploading,
Success,
Failure
}
}
모든 이벤트는 이렇게 된다
namespace VRC.SDK3A.Editor
{
public class VRCSdkControlPanelAvatarBuilder : IVRCSdkAvatarBuilderApi
{
private const int MAX_ACTION_TEXTURE_SIZE = 256;
protected VRCSdkControlPanel _builder;
protected VRC_AvatarDescriptor[] _avatars;
protected static VRC_AvatarDescriptor _selectedAvatar;
private static VRCSdkControlPanelAvatarBuilder _instance;
중요관련 변수들
'게임 > VRChat' 카테고리의 다른 글
VRChat 제스처 매니저 단점 (0) | 2024.08.29 |
---|---|
VRChat 업로드 불가문제 모음 (0) | 2024.07.23 |
캐릭터별 의상 대응방법 (0) | 2024.05.17 |