首页 > 代码库 > 获取预制和获取gameObject
获取预制和获取gameObject
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); } } }}
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。