111
This commit is contained in:
8
Assets/ThirdParty/Tools/SetGroup/Editor.meta
vendored
Normal file
8
Assets/ThirdParty/Tools/SetGroup/Editor.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8c0e170123a0cd44abfa7b731bd7668
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
47
Assets/ThirdParty/Tools/SetGroup/Editor/SetGroupEditor.cs
vendored
Normal file
47
Assets/ThirdParty/Tools/SetGroup/Editor/SetGroupEditor.cs
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(SetGroup))]
|
||||
public class SetGroupEditor : Editor
|
||||
{
|
||||
SetGroup inst;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
inst = (SetGroup)target;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
//
|
||||
if(GUILayout.Button("SetGroup", GUILayout.Height(50)))
|
||||
{
|
||||
AAA();
|
||||
}
|
||||
}
|
||||
|
||||
void AAA()
|
||||
{
|
||||
GameObject[] curObjects = Selection.gameObjects;
|
||||
Vector3 centerPos = Vector3.zero;
|
||||
foreach (GameObject obj in curObjects)
|
||||
{
|
||||
centerPos += obj.GetComponent<MeshRenderer>().bounds.center;
|
||||
}
|
||||
centerPos /= curObjects.Length;
|
||||
|
||||
//
|
||||
GameObject parent = new GameObject(inst.namee);
|
||||
parent.transform.position = centerPos;
|
||||
parent.transform.SetParent(inst.root);
|
||||
|
||||
foreach (GameObject obj in curObjects)
|
||||
{
|
||||
obj.transform.SetParent(parent.transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/Tools/SetGroup/Editor/SetGroupEditor.cs.meta
vendored
Normal file
11
Assets/ThirdParty/Tools/SetGroup/Editor/SetGroupEditor.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2282a076a67c6bd4ca3650e9c5449fd3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Assets/ThirdParty/Tools/SetGroup/SetGroup.cs
vendored
Normal file
21
Assets/ThirdParty/Tools/SetGroup/SetGroup.cs
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SetGroup : MonoBehaviour
|
||||
{
|
||||
public Transform root;
|
||||
public string namee;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/Tools/SetGroup/SetGroup.cs.meta
vendored
Normal file
11
Assets/ThirdParty/Tools/SetGroup/SetGroup.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fc6d85366980714a9a3e5d1289e4ae6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user