-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathAddOptionObject.cs
78 lines (66 loc) · 2.42 KB
/
AddOptionObject.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* 小物を追加するスクリプト
*
* (C)2019 slip
* This software is released under the MIT License.
* http://opensource.org/licenses/mit-license.php
* [Twitter]: https://twitter.com/kjmch2s/
*
* 利用規約:
* 作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等)
* についても制限はありません。
* このスクリプトはもうあなたのものです。
*
*/
using System.Text;
using UnityEditor;
using UnityEngine;
using System.Collections;
using System.IO;
namespace VRM
{
public class AddOptionObject : ScriptableWizard
{
static public Object[] objects;
static public GameObject parentObject;
public string[] AddObjectName = null;
public static void CreateWizard()
{
objects = Resources.LoadAll("AttachObjectSetting");
var wiz = ScriptableWizard.DisplayWizard<AddOptionObject>(
"AddOptionObject", "Add");
var go = Selection.activeObject as GameObject;
}
void OnWizardCreate()
{
for(int i = 0; i<objects.Length; i++){
AddObjectSetting setting = (AddObjectSetting)objects[i];
GameObject childObject = Instantiate(setting.Object) as GameObject;
parentObject = GameObject.Find(setting.parentPartName);
childObject.transform.parent = parentObject.transform;
childObject.transform.localEulerAngles = setting.rotation;
childObject.transform.localScale = setting.scale;
childObject.transform.localPosition = setting.position;
}
}
void OnWizardUpdate()
{
if(AddObjectName == null){
AddObjectName = new string[objects.Length];
for(int i = 0; i<objects.Length; i++){
AddObjectSetting setting = (AddObjectSetting)objects[i];
AddObjectName[i] = setting.parentPartName;
}
}
}
}
public static class VRMExporterMenu
{
const string ADD_OPTIONOBJECT_KEY = VRMVersion.VRM_VERSION + "/AddOptionObject";
[MenuItem(ADD_OPTIONOBJECT_KEY)]
private static void ExportFromMenu()
{
AddOptionObject.CreateWizard();
}
}
}