ModelInspector 프리팹은 동명의 클래스 스크립트를 컴포넌트로 갖는 게임 오브젝트입니다.
ModelInspector 프리팹은 실 사용 예시를 위해 첨부한 것으로, ModelInspector 클래스는 동명의 프리팹이 아닌 다른 게임 오브젝트에 추가할 수 있습니다.
이름 | 설명 |
---|---|
string name |
ModelInspector가 직렬화할 수 있는 InspectorLogDump의 이름입니다. 직렬화 후 저장할 파일 이름에도 활용됩니다. 만약 null 이라면 InspectorLogDump의 이름은 none 으로 지정됩니다. |
GameObject targetObject |
ModelInspector가 감시할 게임 오브젝트입니다. |
Vector3 minPosition |
ModelInspector가 감지할 직육면체 좌표 범위의 한 꼭짓점입니다. maxPosition 과 겹치지 않는 것이 좋습니다. |
Vector3 maxPosition |
ModelInspector가 감지할 직육면체 좌표 범위의 한 꼭짓점입니다. minPosition 과 겹치지 않는 것이 좋습니다. |
float elapsedTime |
logElapsedTime 이 true 인 동안의 시간 경과를 기록합니다. |
List<InspectorKeyFrame> inspectorKeyFrames |
runInspectPositionHandler 가 true 인 동안 targetObject 의 minPosition 와 maxPosition 사이 범위의 출입을 기록합니다. |
string dumpOutPut |
데이터 직렬화 후 저장할 폴더의 경로입니다. 기본값은 "Dumps" 입니다. 이 경우, /Assets/Dumps/ 하위에 직렬화된 데이터가 저장됩니다. |
bool logCheckRange |
true 인 동안 유니티 에디터 콘솔에 지정된 범위 사이에 targetObject 가 위치해있는지 출력합니다. |
bool logElapsedTime |
true 인 동안 시간 경과를 기록합니다. |
bool runInspectPositionHandler |
true 인 동안 지정된 범위의 targetObject 출입 상황을 기록합니다. |
이름 | 설명 |
---|---|
Init(string Name) Init(string Name, Vector3 MinPosition, Vector3 MaxPosition) |
ModelInspector 를 초기화합니다. |
bool CheckRange() |
targetObject , minPosition , maxPosition 이 지정되어 있을 때, targetObject 가 해당 범위 내에 있는지 확인합니다. |
StartLogElapsedTime() | logElapsedTime 을 true 로 변경해 시간 경과를 elapsedTime 에 기록하도록 합니다. |
StopLogElapsedTime() | logElapsedTime 을 false 로 변경해 시간 경과 기록을 멈춥니다. |
InspectPositionTrigger() | runInspectPositionHandler 를 true 로 변경해 targetObject 의 지정 범위 출입을 기록하기 시작합니다. |
StopInspectPosition() | runInspectPositionHandler 를 false 로 변경해 targetObject 의 지정 범위 출입 기록을 멈춥니다. |
InitializeDumpPath() | 데이터 파일을 출력할 폴더를 생성합니다. |
SetDumpPath(string Path) | dumpOutPut 을 변경합니다. |
InspectorLogDump GetInspectorLog() |
inspectorKeyFrames 가 존재한다면 반환합니다. |
DumpInspectorLog() | inspectorKeyFrames 를 InspectorLogDump 객체로 변환하여 덤프합니다. |
이름 | 설명 |
---|---|
bool CheckRange(GameObject TargetObject, Vector3 MinPosition, Vector3 MaxPosition)bool CheckRange(GameObject TargetObject, Vector2 MinPosition, Vector2 MaxPosition) |
TargetObject 가 MinPosition 과 MaxPosition 사이에 위치하고 있는지 확인합니다. |
이 클래스 컴포넌트가 첨부된 게임 오브젝트의 다른 컴포넌트에서 이 클래스를 참조할 때
ModelInspector modelInspector;
void Start()
{
modelInspector = gameObject.GetComponent<ModelInspector>();
modelInspector.Init("First Animation");
modelInspector.StartLogElapsedTime();
modelInspector.InspectPositionTrigger();
}
다른 게임 오브젝트에서 ModelInspector
게임 오브젝트에 첨부된 이 클래스 컴포넌트를 참조할 때
ModelInspector modelInspector;
void Start()
{
modelInspector = GameObject.Find("ModelInspector").GetComponent{ModelInspector}();
modelInspector.Init("First Animation");
modelInspector.StartLogElapsedTime();
modelInspector.InspectPositionTrigger();
}
키프레임을 덤프할 때
public ModelInspector modelInspector;
void Start()
{
modelInspector.Init("First Animation");
}
[ContextMenu("Dump Data")]
void Dump()
{
modelInspector.DumpInspectorLog();
}
[System.Serializable] public class InspectorLogDump
{
public InspectorLogDump(string Name, InspectorKeyFrame InitialKeyFrame, InspectorKeyFrame FinalKeyFrame, List<InspectorKeyFrame> InspectorKeyFrames)
}
이름 | 설명 |
---|---|
string name |
이름 |
InspectorKeyFrame initialKeyFrame |
inspectorKeyFrames 리스트의 첫번째 요소입니다. |
InspectorKeyFrame finalKeyFrame |
inspectorKeyFrames 리스트의 마지막 요소입니다. |
List<InspectorKeyFrame> inspectorKeyFrames |
게임 오브젝트의 출입 기록을 담은 리스트입니다. |
[System.Serializable]
public class InspectorKeyFrame
{
public InspectorKeyFrame(bool BeforeInRange, bool AfterInRange, Vector3 PositionTriggered, float DeltaTime, float ElapsedTime)
}
이름 | 설명 |
---|---|
bool beforeInRange |
기록 시점 직전에 범위 내에 있었는지 여부입니다. |
bool afterInRange |
기록 시점 이후에 범위 내에 있었는지 여부입니다. |
Vector3 positionTriggered |
기록 시점의 오브젝트의 위치입니다. |
float deltaTime |
기록 시점 직전부터 기록 시점까지 시간 경과입니다. |
float elapsedTime |
감시 시작 시점부터 기록 시점까지 시간 경과입니다. |
beforeInRange
와afterInRange
는 같은 값을 가질 수 없습니다.beforeInRange
가true
일 때는 오브젝트가 범위 바깥으로 나간 것이고,afterInRange
가true
일 때는 오브젝트가 범위 안으로 들어온 것입니다.