에디터는 Asset/Editor/.. <- 에 생성&작성 해주어야 인식한다.
[일괄 이름 변경 에디터]
using UnityEngine;
using UnityEditor;
using System.Collections;
public class BatchRename : ScriptableWizard {
// 기본 이름
public string BaseName = "MyObject_";
// 시작 숫자
public int StartNumber = 0;
// 증가치
public int increment = 1;
[MenuItem("Edit/Batch Rename...")]
static void CreateWizard()
{
ScriptableWizard.DisplayWizard("Batch Rename", typeof(BatchRename), "Rename");
}
// 창이 처음 나타날 때 호출된다
void OnEnable()
{
UpdateSelectionHelper();
}
// 씬에서 선택 영역이 변경될 때 호출되는 함수
void OnSelectionChange()
{
UpdateSelectionHelper();
}
// 선택된 개수를 업데이트한다
void UpdateSelectionHelper()
{
helpString = "";
if (Selection.objects != null)
helpString = "Number of objects selected : " + Selection.objects.Length;
}
// 이름 변경
void OnWizardCreate()
{
// 선택된 것이 없으면 종료한다.
if (Selection.objects == null)
return;
// 현재 증가치
int PostFix = StartNumber;
// 순회하며 이름을 변경한다.
foreach(Object O in Selection.objects)
{
O.name = BaseName + PostFix;
PostFix += increment;
}
}
}
[버튼 클릭시 오브젝트 생성]
using UnityEngine;
using UnityEditor;
public class CreateWindow : EditorWindow
{
//
// Create Windows
//
[MenuItem("Test/Create Window")]
static public void ShowWindow()
{
// 윈도우 생성
CreateWindow window = (CreateWindow)EditorWindow.GetWindow(typeof(CreateWindow));
}
int nIntField;
void OnGUI()
{
nIntField = EditorGUI.IntField(new Rect(10, 10, 300, 17), "int", nIntField);
if (GUI.Button(new Rect(150, 100, 150, 150), "Button"))
{
for (int i = 0; i < nIntField; i++)
{
GameObject obj = new GameObject();
obj.name = "GameObject" + i;
}
Close();
}
}
}
(깨지는 꿀캠..ㅠㅠㅠ)
'NOTE > SaveSource' 카테고리의 다른 글
| [SaveSource] WeaponDrob (0) | 2017.01.04 |
|---|---|
| [SaveSource] ViveTouchPad (0) | 2017.01.04 |
| [SaveSource] 만보기소스(펌) (0) | 2016.11.09 |
| [Source Save] GyhroCameraMove.cs (0) | 2016.11.09 |
| [SaveSource] WebcamTexture (0) | 2016.11.02 |