Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEditor;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System;
- public class CreateTransforms : EditorWindow
- {
- //clothes = 0
- //swimsuit = 1
- //gloves = 2
- //shoes = 3
- public int objType = 0;
- // Use this for initialization
- [MenuItem("HoneySelect/Create Transforms")]
- static void Init()
- {
- CreateTransforms window = (CreateTransforms)EditorWindow.GetWindow(typeof(CreateTransforms));
- window.Show();
- }
- // Update is called once per frame
- void OnGUI()
- {
- GUILayout.Label("Create Transforms", EditorStyles.boldLabel);
- if (GUILayout.Button("Clothes"))
- {
- objType = 0;
- aCreateTransforms(objType);
- }
- else if (GUILayout.Button("Swimsuit"))
- {
- objType = 1;
- aCreateTransforms(objType);
- }
- else if (GUILayout.Button("Gloves"))
- {
- objType = 2;
- aCreateTransforms(objType);
- }
- else if (GUILayout.Button("Shoes"))
- {
- objType = 3;
- aCreateTransforms(objType);
- }
- else if (GUILayout.Button("Socks"))
- {
- objType = 4;
- aCreateTransforms(objType);
- }
- else if (GUILayout.Button("Accessory"))
- {
- objType = 5;
- aCreateTransforms(objType);
- }
- else if (GUILayout.Button("Bra"))
- {
- objType = 6;
- aCreateTransforms(objType);
- }
- }
- static void aCreateTransforms(int objType)
- {
- switch (objType)
- {
- case 0:
- Transform rootTransform = Selection.activeGameObject.transform;
- String sPath = "cf_N_O_root/N_cos_00/N_top_00/N_bot_d";
- CreateTree(rootTransform, sPath);
- sPath = "cf_N_O_root/N_cos_00/N_top_00/N_top_a";
- CreateTree(rootTransform, sPath);
- sPath = "cf_N_O_root/N_cos_00/N_top_00/N_bot_n";
- CreateTree(rootTransform, sPath);
- sPath = "cf_N_O_root/N_cos_00/N_top_00/N_top_b";
- CreateTree(rootTransform, sPath);
- Selection.activeGameObject = GameObject.Find(sPath);
- break;
- case 2:
- rootTransform = Selection.activeGameObject.transform;
- sPath = "cf_N_O_root/N_under/N_glove";
- CreateTree(rootTransform, sPath);
- Selection.activeGameObject = GameObject.Find(sPath);
- break;
- case 3:
- rootTransform = Selection.activeGameObject.transform;
- sPath = "cf_N_O_root/N_under/N_shoes";
- CreateTree(rootTransform, sPath);
- Selection.activeGameObject = GameObject.Find(sPath);
- break;
- case 4:
- rootTransform = Selection.activeGameObject.transform;
- sPath = "cf_N_O_root/N_under/N_socks";
- CreateTree(rootTransform, sPath);
- Selection.activeGameObject = GameObject.Find(sPath);
- break;
- case 5:
- rootTransform = Selection.activeGameObject.transform;
- sPath = "N_move";
- CreateTree(rootTransform, sPath);
- Selection.activeGameObject = GameObject.Find(sPath);
- break;
- case 6:
- rootTransform = Selection.activeGameObject.transform;
- sPath = "cf_N_O_root/N_under/N_bra";
- CreateTree(rootTransform, sPath);
- Selection.activeGameObject = GameObject.Find(sPath);
- break;
- default:
- Console.WriteLine("This should not happen");
- break;
- }
- }
- static void CreateTree(Transform parent, string path)
- {
- string[] splitted = path.Split('/');
- foreach (string name in splitted)
- {
- if (string.IsNullOrEmpty(name))
- continue;
- Transform existingTransform = parent.Find(name);
- if (existingTransform == null)
- {
- GameObject go = new GameObject(name);
- go.transform.SetParent(parent);
- go.transform.localPosition = Vector3.zero;
- go.transform.localRotation = Quaternion.identity;
- go.transform.localScale = Vector3.one;
- parent = go.transform;
- }
- else
- parent = existingTransform;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement