中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

做網(wǎng)站賣廣告掙幾百萬建站模板平臺

做網(wǎng)站賣廣告掙幾百萬,建站模板平臺,流程網(wǎng)站設(shè)計,網(wǎng)站宣傳單頁制作目錄 1.功能概述 2.完整代碼 3. 實現(xiàn)原理 4. 使用預(yù)覽 5.新增優(yōu)化版本 在Unity項目開發(fā)過程中,管理和維護資源之間的引用關(guān)系是至關(guān)重要的。當(dāng)然我們項目也是需要這個功能 畢竟項目大了之后查找資源引用還是交給 資源引用查找器 比較好。 1.功能概述 資源引用…

目錄

1.功能概述

2.完整代碼

3. 實現(xiàn)原理

4. 使用預(yù)覽

5.新增優(yōu)化版本


在Unity項目開發(fā)過程中,管理和維護資源之間的引用關(guān)系是至關(guān)重要的。當(dāng)然我們項目也是需要這個功能 畢竟項目大了之后查找資源引用還是交給?資源引用查找器 比較好。

1.功能概述

資源引用查找器允許開發(fā)者選擇一個目標(biāo)資源,并在整個項目中查找引用了該資源的其他資源。其主要功能包括:

  • 在Unity編輯器菜單欄下添加一個名為"Resource Reference Finder"的菜單項。
  • 提供一個可調(diào)整大小的窗口,用于選擇目標(biāo)資源和顯示引用結(jié)果。
  • 通過點擊"Search"按鈕來觸發(fā)搜索過程,查找所有引用了目標(biāo)資源的Prefab文件,并將結(jié)果展示在窗口中。

2.完整代碼

using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
using System.IO;public class ResourceReferenceFinder : EditorWindow
{[MenuItem("Assets/Resource Reference Finder")]static void SearchReference(){GetWindow<ResourceReferenceFinder>("Resource Reference Finder");}private static Object targetResource;private List<Object> referencingAssets = new List<Object>();private Vector2 scrollPosition;private void OnGUI(){// 顯示資源選擇字段和搜索按鈕EditorGUILayout.BeginHorizontal();GUILayout.Label("Select Target Resource:", GUILayout.Width(150));targetResource = EditorGUILayout.ObjectField(targetResource, typeof(Object), true, GUILayout.Width(200));if (GUILayout.Button("Search", GUILayout.Width(100))){ReferenceFinder();}EditorGUILayout.EndHorizontal();// 滾動視圖開始scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);EditorGUILayout.BeginVertical();// 顯示搜索結(jié)果for (int i = 0; i < referencingAssets.Count; i++){EditorGUILayout.ObjectField(referencingAssets[i], typeof(Object), true, GUILayout.Width(300));}EditorGUILayout.EndVertical();EditorGUILayout.EndScrollView();// 滾動視圖結(jié)束}// 查找引用private void ReferenceFinder(){referencingAssets.Clear();// 檢查是否選擇了資源if (targetResource == null){Debug.LogWarning("Please select a resource to search for references.");return;}// 獲取選擇資源的 GUIDstring assetPath = AssetDatabase.GetAssetPath(targetResource);string assetGuid = AssetDatabase.AssetPathToGUID(assetPath);// 遍歷項目中所有 Prefab 文件string[] guids = AssetDatabase.FindAssets("t:Prefab", new[] { "Assets" });int length = guids.Length;for (int i = 0; i < length; i++){string filePath = AssetDatabase.GUIDToAssetPath(guids[i]);EditorUtility.DisplayCancelableProgressBar("Checking", filePath, (float)i / length);// 讀取 Prefab 文件內(nèi)容,檢查是否包含選擇資源的 GUIDstring content = File.ReadAllText(filePath);if (content.Contains(assetGuid)){// 如果包含,將該 Prefab 添加到結(jié)果列表中Object referencingAsset = AssetDatabase.LoadAssetAtPath(filePath, typeof(Object));referencingAssets.Add(referencingAsset);}}// 清除進度條EditorUtility.ClearProgressBar();}
}

3. 實現(xiàn)原理

  • 使用Unity編輯器提供的MenuItem特性,在菜單欄下添加了一個自定義的菜單項,用于觸發(fā)資源引用查找器窗口的顯示。
  • 創(chuàng)建了一個繼承自EditorWindow的窗口類,實現(xiàn)了GUI繪制和資源引用搜索的邏輯。
  • 在GUI中,通過ObjectFieldButton控件實現(xiàn)了目標(biāo)資源的選擇和搜索按鈕的功能。
  • 使用AssetDatabase類來訪問項目中的資源,并通過FindAssets方法查找所有Prefab文件。
  • 讀取Prefab文件的內(nèi)容,檢查是否包含目標(biāo)資源的GUID,如果是,則將該Prefab添加到引用結(jié)果列表中。

4. 使用預(yù)覽

查找Prefab引用

查找圖片引用

5.新增優(yōu)化版本

新增優(yōu)化版本右鍵直接選中需要查找的資源? 直接省略繁瑣步驟 完整代碼如下

using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
using System.IO;public class ResourceReferenceFinder : EditorWindow
{private List<Object> referencingAssets = new List<Object>();private Vector2 scrollPosition;[MenuItem("Assets/ZYT ASSETS/Find References", true)]private static bool ValidateSearchReference(){// 只在選中了對象且不是文件夾時才顯示菜單項return Selection.activeObject != null && !AssetDatabase.IsValidFolder(AssetDatabase.GetAssetPath(Selection.activeObject));}[MenuItem("Assets/ZYT ASSETS/Find References")]private static void SearchReference(){// 創(chuàng)建并打開資源引用查找窗口if (Selection.activeObject != null && !AssetDatabase.IsValidFolder(AssetDatabase.GetAssetPath(Selection.activeObject))){GetWindow<ResourceReferenceFinder>("Resource Reference Finder").ReferenceFinder(Selection.activeObject);}}private void OnGUI(){// 顯示搜索結(jié)果EditorGUILayout.LabelField("Search Results:");// 滾動視圖開始scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);EditorGUILayout.BeginVertical();// 顯示搜索結(jié)果for (int i = 0; i < referencingAssets.Count; i++){EditorGUILayout.ObjectField(referencingAssets[i], typeof(Object), true, GUILayout.Width(300));}EditorGUILayout.EndVertical();EditorGUILayout.EndScrollView();// 滾動視圖結(jié)束}// 查找引用private void ReferenceFinder(Object targetResource){referencingAssets.Clear();// 獲取選擇資源的 GUIDstring assetPath = AssetDatabase.GetAssetPath(targetResource);string assetGuid = AssetDatabase.AssetPathToGUID(assetPath);// 遍歷項目中所有 Prefab 文件string[] guids = AssetDatabase.FindAssets("t:Prefab", new[] { "Assets" });int length = guids.Length;for (int i = 0; i < length; i++){string filePath = AssetDatabase.GUIDToAssetPath(guids[i]);EditorUtility.DisplayCancelableProgressBar("Checking", filePath, (float)i / length);// 讀取 Prefab 文件內(nèi)容,檢查是否包含選擇資源的 GUIDstring content = File.ReadAllText(filePath);if (content.Contains(assetGuid)){// 如果包含,將該 Prefab 添加到結(jié)果列表中Object referencingAsset = AssetDatabase.LoadAssetAtPath(filePath, typeof(Object));referencingAssets.Add(referencingAsset);}}// 清除進度條EditorUtility.ClearProgressBar();}
}

?使用方法??

如果未選中資源則是如下狀況 工具是沒法使用的

下圖是現(xiàn)在修改后的界面

http://www.risenshineclean.com/news/51486.html

相關(guān)文章:

  • 南昌新建網(wǎng)站建設(shè)南京網(wǎng)絡(luò)推廣公司排名
  • 網(wǎng)站建設(shè)小組搜索引擎優(yōu)化方式
  • 網(wǎng)站開發(fā)包含哪些網(wǎng)站下載
  • 免費建站網(wǎng)站一級大陸在線看網(wǎng)站優(yōu)化推廣培訓(xùn)
  • 鞍山市住房和城鄉(xiāng)建設(shè)網(wǎng)站中國有幾個搜索引擎
  • 最優(yōu)的錦州網(wǎng)站建設(shè)專門搜索知乎內(nèi)容的搜索引擎
  • 網(wǎng)站建設(shè)個人網(wǎng)站網(wǎng)站頁面優(yōu)化包括
  • 網(wǎng)站建設(shè)的項目計劃書網(wǎng)店運營實訓(xùn)報告
  • 外國人的做視頻網(wǎng)站嗎搜搜
  • 網(wǎng)站全景看圖怎么做網(wǎng)銷是做什么的
  • 個人網(wǎng)站有什么寧波seo推薦優(yōu)化
  • 免費設(shè)計室內(nèi)裝修app廈門seo結(jié)算
  • 廣州市建設(shè)和水務(wù)局網(wǎng)站全網(wǎng)搜索引擎優(yōu)化
  • 大連三豐建設(shè)集團公司網(wǎng)站四種營銷策略
  • 網(wǎng)站支持asp網(wǎng)絡(luò)營銷論文畢業(yè)論文
  • wordpress整站源碼網(wǎng)絡(luò)營銷的目的是什么
  • 南通高端網(wǎng)站建設(shè)開發(fā)百度站長資源平臺
  • access做網(wǎng)站數(shù)據(jù)庫能有多大容量百度競價什么意思
  • 如何訪問云南建設(shè)廳網(wǎng)站網(wǎng)站服務(wù)器是什么意思
  • 濟南網(wǎng)站建設(shè)企業(yè)談?wù)勀銓W(wǎng)絡(luò)營銷的看法
  • 兩個網(wǎng)站共用一個空間搜索引擎排名中國
  • 太原網(wǎng)站建設(shè)與維護做網(wǎng)站的平臺
  • 廣州的十七做網(wǎng)站百度首頁優(yōu)化排名
  • 藍(lán)色政府網(wǎng)站模版網(wǎng)站運營推廣方式
  • wordpress 多個站點深圳網(wǎng)站設(shè)計實力樂云seo
  • 什么網(wǎng)站做旅行計劃seo運營人士揭秘
  • 微信公眾號怎樣做淘客網(wǎng)站重慶網(wǎng)站搭建
  • 上海企業(yè)名錄地址電話seo網(wǎng)絡(luò)推廣
  • 桂林億星網(wǎng)絡(luò)科技公司百度seo排名優(yōu)化是什么
  • 訪問網(wǎng)站提示輸入用戶名密碼網(wǎng)絡(luò)推廣營銷培訓(xùn)機構(gòu)