首页 > 其他 > 详细

AddParent

时间:2014-06-07 00:35:19      阅读:414      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
using UnityEngine;
using UnityEditor;
using System.Collections;
 
public class AddParent : ScriptableObject
{
    [MenuItem ("GameObject/+Add Parent")]
    static void MenuInsertParent()
    {
        Transform[] transforms = Selection.GetTransforms(SelectionMode.TopLevel |
            SelectionMode.OnlyUserModifiable);
 
        GameObject newParent = new GameObject("_Parent");
        Transform newParentTransform = newParent.transform;
 
        if(transforms.Length == 1)
        {
            Transform originalParent = transforms[0].parent;
            transforms[0].parent = newParentTransform;
            if(originalParent)
                newParentTransform.parent = originalParent;
        }
        else
        {
            foreach(Transform transform in transforms)
                transform.parent = newParentTransform;
        }
    }
}
bubuko.com,布布扣

 

AddParent,布布扣,bubuko.com

AddParent

原文:http://www.cnblogs.com/softimagewht/p/3765397.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!