首页 > 其他 > 详细

获取预制和获取gameObject

时间:2014-08-22 12:22:06      阅读:319      评论:0      收藏:0      [点我收藏+]
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;

public class selectionFn : ScriptableObject {

    [MenuItem("Learn/selection")]
    static void _selection()
    {
        //获取预制的方法
        ArrayList getPrefabs = new ArrayList();
        Object[] objs = Selection.GetFiltered(typeof(Object),SelectionMode.DeepAssets);

        foreach(Object c in objs)
        {
            string _Path =  AssetDatabase.GetAssetPath(c);
            if(_Path.Contains(".prefab"))
            {
                getPrefabs.Add(c);
                //Debug.Log(_Path);
            }
        }
        //Debug.Log(getPrefabs.Count.ToString());

        //2写的获取project里资产的方法
        Object[] _objs = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.Assets | SelectionMode.DeepAssets);
        foreach(var obj in _objs)
        {
            if (obj is GameObject)
            {
                GameObject go = obj as GameObject;
                Debug.Log("Asset:" + go.name);
            }
        }
    }
}

 

获取预制和获取gameObject,布布扣,bubuko.com

获取预制和获取gameObject

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

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