zoukankan      html  css  js  c++  java
  • 获取预制和获取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);
                }
            }
        }
    }
  • 相关阅读:
    转盘抽奖活动代码
    信息滚动条
    gulp应用学习
    js实现语音播报功能
    如何安装使用sass
    纯CSS写三角形-border法
    css兼容性写法
    字体中英文对照
    浏览器内核判断
    个人课程总结
  • 原文地址:https://www.cnblogs.com/softimagewht/p/3928831.html
Copyright © 2011-2022 走看看