AddLayer和AddTag
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine; public class LayerTagSpawn : AssetPostprocessor
{
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
foreach (string s in importedAssets)
{
if (s.Contains("HandleController"))
{
AddLayer("dragLayer");
AddLayer("terrain");
return;
}
}
} static void AddTag(string tag)
{
if (!isHasTag(tag))
{
SerializedObject tagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[]);
SerializedProperty it = tagManager.GetIterator();
int index = ;
bool bFindTag = false;
while (it.NextVisible(true))
{
if (it.name == "tags")
{
for (int i = ; i < it.arraySize; i++)
{
index++;
SerializedProperty dataPoint = it.GetArrayElementAtIndex(i);
if (string.IsNullOrEmpty(dataPoint.stringValue))
{
dataPoint.stringValue = tag;
tagManager.ApplyModifiedProperties();
bFindTag = true;
return;
}
}
if (!bFindTag)
{
it.InsertArrayElementAtIndex(index);
SerializedProperty property = it.GetArrayElementAtIndex(index);
property.stringValue = tag;
tagManager.ApplyModifiedProperties();
return;
}
}
}
}
} static void AddLayer(string layer)
{
if (!isHasLayer(layer))
{
SerializedObject tagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[]);
SerializedProperty it = tagManager.GetIterator();
while (it.NextVisible(true))
{
if (it.name == "layers")
{
for (int i = ; i <= ; i++)
{
SerializedProperty dataPoint = it.GetArrayElementAtIndex(i);
if (string.IsNullOrEmpty(dataPoint.stringValue))
{
dataPoint.stringValue = layer;
tagManager.ApplyModifiedProperties();
return;
}
}
}
}
}
} static bool isHasTag(string tag)
{
for (int i = ; i < UnityEditorInternal.InternalEditorUtility.tags.Length; i++)
{
if (UnityEditorInternal.InternalEditorUtility.tags[i].Contains(tag))
return true;
}
return false;
} static bool isHasLayer(string layer)
{
for (int i = ; i < UnityEditorInternal.InternalEditorUtility.layers.Length; i++)
{
if (UnityEditorInternal.InternalEditorUtility.layers[i].Contains(layer))
return true;
}
return false;
}
}
AddLayer和AddTag的更多相关文章
- MapControl控件AddLayer出现错误-引发类型为“System.Windows.Forms.AxHost+InvalidActiveXStateException”的异常
出错代码: AxMapControl pMptrl = new AxMapControl(); //add data string mdbPath = string.Format("{0}\ ...
- Arcgis for javascript map操作addLayer具体解释
本节的内容非常easy.说说Arcgis for Javascript里面map对象的addLayer方法.在for JS的API中,addLayer方法有两种.例如以下图: watermark/2/ ...
- Arcgis for javascript map操作addLayer详解
本节的内容很简单,说说Arcgis for Javascript里面map对象的addLayer方法.在for JS的API中,addLayer方法有两种,如下图: addLayer方法 在addLa ...
- 使用AddLayer方法加载shp文件中使用的Map、Dataset等对象详解
内容源自:ArcGIS Engine+C#入门经典 方法二:使用axMapControl1对象的AddLayer方法加载ShapeFile文件 添加ShapeFile文件需要用到Map.Dataset ...
- addlayer添加神经网络层
def addlayer(inputs,insize,outsize,activity_function = None): weights = tf.Variable(tf.random_nor ...
- SuperMap iClient for JavaScript 新手入门
地理信息系统(英语:Geographic Information System,缩写:GIS)是一门综合性学科,结合地理学与地图学,已经广泛的应用在不同的领域,是用于输入.存储.查询.分析和显示地理数 ...
- Java中用得比较顺手的事件监听
第一次听说监听是三年前,做一个webGIS的项目,当时对Listener的印象就是个"监视器",监视着界面的一举一动,一有动静就触发对应的响应. 一.概述 通过对界面的某一或某些操 ...
- ArcGIS Engine开发之鹰眼视图
鹰眼是GIS软件的必备功能之一.它是一个MapControl控件,主要用来表示数据视图中的地理范围在全图中的位置. 鹰眼一般具有的功能: 1)鹰眼视图与数据视图的地理范围保持同步. 2)数据视图的当前 ...
- ArcGIS Engine开发之地图基本操作(4)
ArcGIS Engine开发中数据库的加载 1.加载个人地理数据库数据 个人地理数据库(Personal Geodatabase)使用Miscrosoft Access文件(*.mdb)进行空间数据 ...
随机推荐
- liunx shell 脚本的基础知识
Shell脚本编程30分钟入门====================## 什么是Shell脚本### 示例看个例子吧: #!/bin/sh cd ~ mkdir shell_tut cd shell ...
- leetcode-8.atoi · string *
题面 原题挺长的,还是英文,就不抄了,
- SpringCloud之RabbitMQ消息队列原理及配置
本篇章讲解RabbitMQ的用途.原理以及配置,RabbitMQ的安装请查看SpringCloud之RabbitMQ安装 一.MQ用途 1.同步变异步消息 场景:用户下单完成后,发送邮件和短信通知. ...
- 解决spring-boot-maven-plugin插件打包,springboot启动时报找不到主main问题
一:遇到的问题及解决方法 最近在搭建一个新项目时,使用spring-boot-maven-plugin插件打包,springboot项目在发布后启动时遇到找不到主main问题. 遇到这个问题当时感觉本 ...
- .NET Core中使用水印
.NET Core中使用水印 在项目中,我需要给上传的图片添加水印,通过网上查找针对.NET Core 的找到两个方案: 使用 CoreCompat.System.Drawing 及用于非Window ...
- idou老师教你学Istio 29:Envoy启动流程
1. 功能概述 Envoy启动时,会启动一个进程,并在这个进程中启动很多线程,这样,可以启动很多worker线程,一般worker线程数与核心数相同,每个worker线程处理所有已配置的listene ...
- 本地开发的jar包放到本地maven仓库
mvn install:install-file -Dfile=C:\Users\Administrator\Desktop\taobao-sdk-java-1455552377940-2016060 ...
- mxnet在windows使用gpu 出错
1. cuda windows安装 官网下载 代码: import mxnet as mxfrom mxnet import ndfrom mxnet.gluon import nn a = nd.a ...
- 极光推送出现 超时问题:Connect timeout. Please retry later. Error:7
检查之后均没有什么太大的问题, 最后发现出现77这种错误码,有一种可能就是系统的ca包没有更新 包名为 ca-certificates 使用命令 yum install ca-certificates ...
- Java常用数学类和BigDecimal
笔记: Math类 * java.lang.Math提供了一系列静态方法用于科学计算:其方法的参数和返回值类型一般为double型. * abs 绝对值 * acos,asin,atan,cos,si ...