Readd missing import files
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
public class RuntimeGizmosPreset : AssetPostprocessor
|
||||
{
|
||||
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
|
||||
{
|
||||
foreach (string s in importedAssets)
|
||||
{
|
||||
if (s.Contains("RuntimeGizmosPreset.cs"))
|
||||
{
|
||||
AddLayer("Gizmos");
|
||||
AddLayer("Nav");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void AddTag(string tag)
|
||||
{
|
||||
if (!HasTag(tag))
|
||||
{
|
||||
SerializedObject tagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
|
||||
SerializedProperty it = tagManager.GetIterator();
|
||||
while (it.NextVisible(true))
|
||||
{
|
||||
if (it.name == "tags")
|
||||
{
|
||||
for (int i = 0; i < it.arraySize; i++)
|
||||
{
|
||||
SerializedProperty dataPoint = it.GetArrayElementAtIndex(i);
|
||||
if (string.IsNullOrEmpty(dataPoint.stringValue))
|
||||
{
|
||||
dataPoint.stringValue = tag;
|
||||
tagManager.ApplyModifiedProperties();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void AddLayer(string layer)
|
||||
{
|
||||
if (!HasLayer(layer))
|
||||
{
|
||||
SerializedObject tagMagager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/Tagmanager.asset"));
|
||||
SerializedProperty it = tagMagager.GetIterator();
|
||||
while (it.NextVisible(true))
|
||||
{
|
||||
if (it.name.Equals("layers"))
|
||||
{
|
||||
for (int i = 0; i < it.arraySize; i++)
|
||||
{
|
||||
if (i <= 7)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
SerializedProperty sp = it.GetArrayElementAtIndex(i);
|
||||
if (string.IsNullOrEmpty(sp.stringValue))
|
||||
{
|
||||
sp.stringValue = layer;
|
||||
tagMagager.ApplyModifiedProperties();
|
||||
Debug.Log("success");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool HasTag(string tag)
|
||||
{
|
||||
for (int i = 0; i < UnityEditorInternal.InternalEditorUtility.tags.Length; i++)
|
||||
{
|
||||
if (UnityEditorInternal.InternalEditorUtility.tags[i].Contains(tag))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool HasLayer(string layer)
|
||||
{
|
||||
SerializedObject tagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/Tagmanager.asset"));
|
||||
SerializedProperty it = tagManager.GetIterator();
|
||||
while (it.NextVisible(true))
|
||||
{
|
||||
if (it.name.Equals("layers"))
|
||||
{
|
||||
for (int i = 0; i < it.arraySize; i++)
|
||||
{
|
||||
if (i <= 7)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
SerializedProperty sp = it.GetArrayElementAtIndex(i);
|
||||
if (!string.IsNullOrEmpty(sp.stringValue))
|
||||
{
|
||||
if (sp.stringValue.Equals(layer))
|
||||
{
|
||||
sp.stringValue = string.Empty;
|
||||
tagManager.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < UnityEditorInternal.InternalEditorUtility.layers.Length; i++)
|
||||
{
|
||||
if (UnityEditorInternal.InternalEditorUtility.layers[i].Contains(layer))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba8fcce423ad01148bd63fa5facf44f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user