导入leg插件,完成腿部动画
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 505cfa9eacb239c4cab04a64cb91877a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,187 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
namespace FIMSpace.FEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// FM: Class with basic tools for working in Unity Editor level
|
||||
/// </summary>
|
||||
public static partial class FEditor_MenuAddOptions
|
||||
{
|
||||
|
||||
[MenuItem("CONTEXT/Collider/Generate NavMesh Obstacle")]
|
||||
private static void GenerateNavMeshObstacle(MenuCommand menuCommand)
|
||||
{
|
||||
Collider targetComponent = (Collider)menuCommand.context;
|
||||
|
||||
if (targetComponent)
|
||||
{
|
||||
NavMeshObstacle obstacle = targetComponent.gameObject.GetComponent<NavMeshObstacle>();
|
||||
if (obstacle == null) obstacle = targetComponent.gameObject.AddComponent<NavMeshObstacle>();
|
||||
obstacle.center = targetComponent.bounds.center;
|
||||
obstacle.size = targetComponent.bounds.size;
|
||||
obstacle.carving = true;
|
||||
|
||||
EditorUtility.SetDirty(targetComponent.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[MenuItem("CONTEXT/Transform/Fit child objects to bottom origin")]
|
||||
private static void ChildBottomOrigin(MenuCommand menuCommand)
|
||||
{
|
||||
Transform t = (Transform)menuCommand.context;
|
||||
FitToBottom(t);
|
||||
}
|
||||
|
||||
[MenuItem("CONTEXT/Transform/Hide Transform In The Inspector View (Use Components Hider to unhide)")]
|
||||
private static void HideTransformInInspector(MenuCommand menuCommand)
|
||||
{
|
||||
Transform t = (Transform)menuCommand.context;
|
||||
|
||||
if (t)
|
||||
{
|
||||
t.hideFlags = HideFlags.HideInInspector;
|
||||
EditorUtility.SetDirty(t);
|
||||
}
|
||||
}
|
||||
|
||||
private static void FitToBottom(Transform t)
|
||||
{
|
||||
if (t.childCount > 0)
|
||||
{
|
||||
float lowestY = float.MaxValue;
|
||||
Renderer rr = null;
|
||||
|
||||
for (int i = 0; i < t.childCount; i++)
|
||||
{
|
||||
Renderer r = t.GetChild(i).GetComponent<Renderer>();
|
||||
|
||||
if (r.bounds.min.y < lowestY)
|
||||
{
|
||||
lowestY = r.bounds.min.y;
|
||||
rr = r;
|
||||
}
|
||||
}
|
||||
|
||||
if (rr)
|
||||
{
|
||||
Vector3 offset = new Vector3(0, t.position.y - rr.bounds.min.y, 0);
|
||||
for (int i = 0; i < t.childCount; i++)
|
||||
{
|
||||
t.GetChild(i).position += offset;
|
||||
}
|
||||
}
|
||||
|
||||
EditorUtility.SetDirty(t.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("CONTEXT/Transform/Generate parent + Fit objects to bottom")]
|
||||
private static void GenerateParentAndFit(MenuCommand menuCommand)
|
||||
{
|
||||
Transform t = (Transform)menuCommand.context;
|
||||
int sibl = t.GetSiblingIndex();
|
||||
GameObject parent = new GameObject(t.name);
|
||||
parent.transform.SetParent(t.parent);
|
||||
parent.transform.position = t.position;
|
||||
parent.transform.rotation = t.rotation;
|
||||
parent.transform.localScale = t.localScale;
|
||||
t.SetParent(parent.transform);
|
||||
FitToBottom(parent.transform);
|
||||
EditorUtility.SetDirty(t.gameObject);
|
||||
parent.transform.SetSiblingIndex(sibl);
|
||||
if (Selection.activeGameObject == t.gameObject) Selection.activeGameObject = parent;
|
||||
}
|
||||
|
||||
[MenuItem("CONTEXT/AudioReverbZone/Fit To Collider")]
|
||||
private static void AudioReverbZoneFit(MenuCommand menuCommand)
|
||||
{
|
||||
AudioReverbZone targetComponent = (AudioReverbZone)menuCommand.context;
|
||||
|
||||
if (targetComponent)
|
||||
{
|
||||
Collider c = targetComponent.gameObject.GetComponent<Collider>();
|
||||
|
||||
if (c)
|
||||
{
|
||||
targetComponent.minDistance = Vector3.Distance(c.bounds.min, c.bounds.max) * 0.45f;
|
||||
targetComponent.maxDistance = targetComponent.minDistance * 1.35f;
|
||||
}
|
||||
|
||||
EditorUtility.SetDirty(targetComponent.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[MenuItem("CONTEXT/ReflectionProbe/Fit To Collider")]
|
||||
private static void ReflectionProbeFit(MenuCommand menuCommand)
|
||||
{
|
||||
ReflectionProbe targetComponent = (ReflectionProbe)menuCommand.context;
|
||||
|
||||
if (targetComponent)
|
||||
{
|
||||
Collider c = targetComponent.gameObject.GetComponent<Collider>();
|
||||
BoxCollider bc = c as BoxCollider;
|
||||
|
||||
if (c)
|
||||
{
|
||||
if (bc)
|
||||
{
|
||||
targetComponent.center = bc.center;
|
||||
targetComponent.size = bc.size;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetComponent.center = c.bounds.center;
|
||||
targetComponent.size = c.bounds.size;
|
||||
}
|
||||
}
|
||||
|
||||
EditorUtility.SetDirty(targetComponent.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("GameObject/Add Separator", false, 0)]
|
||||
static void AddSeparatorObject()
|
||||
{
|
||||
GameObject go = new GameObject();
|
||||
go.name = "-------------------";
|
||||
go.gameObject.SetActive(false);
|
||||
go.transform.position = Vector3.zero;
|
||||
go.transform.rotation = Quaternion.identity;
|
||||
go.transform.localScale = Vector3.one;
|
||||
}
|
||||
|
||||
[MenuItem("CONTEXT/MeshFilter/Save Mesh As Asset")]
|
||||
private static void SaveFilterMeshAsAsset(MenuCommand menuCommand)
|
||||
{
|
||||
MeshFilter targetComponent = (MeshFilter)menuCommand.context;
|
||||
|
||||
if (targetComponent == null) return;
|
||||
if (targetComponent.sharedMesh == null) return;
|
||||
|
||||
Mesh newMesh = GameObject.Instantiate(targetComponent.sharedMesh) as Mesh;
|
||||
|
||||
string nameFormatted = targetComponent.sharedMesh.name.Replace(":", "-");
|
||||
nameFormatted = nameFormatted.Replace("=", "_");
|
||||
|
||||
string path = EditorUtility.SaveFilePanel("Select Directory", Application.dataPath, nameFormatted, "");
|
||||
if (path == "") return;
|
||||
|
||||
if (path.StartsWith(Application.dataPath))
|
||||
{
|
||||
path = "Assets" + path.Substring(Application.dataPath.Length);
|
||||
}
|
||||
|
||||
AssetDatabase.CreateAsset(newMesh, path + ".asset");
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
var obj = AssetDatabase.LoadAssetAtPath(path + ".asset", typeof(Mesh));
|
||||
if (obj) EditorGUIUtility.PingObject(obj);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1bd3c56bdf13284ebc28a5a22890ef6
|
||||
timeCreated: 1531406488
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,111 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace FIMSpace.FEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// FM: Class with basic tools for working in Unity Editor level
|
||||
/// </summary>
|
||||
public static partial class FEditor_MenuAddOptions
|
||||
{
|
||||
|
||||
[MenuItem("Assets/Utilities/Copy Full Path To Directory")]
|
||||
private static void CopyWholePathToDir(MenuCommand menuCommand)
|
||||
{
|
||||
if (Selection.objects.Length == 0) return;
|
||||
string assetPath = AssetDatabase.GetAssetPath(Selection.objects[0]);
|
||||
string fullPath = Path.Combine(Directory.GetCurrentDirectory(), assetPath);
|
||||
GUIUtility.systemCopyBuffer = Path.GetDirectoryName(fullPath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[MenuItem("CONTEXT/MonoBehaviour/Go To Script's Directory")]
|
||||
private static void GoToBehaviourDirectory(MenuCommand menuCommand)
|
||||
{
|
||||
if (menuCommand.context is MonoBehaviour)
|
||||
{
|
||||
MonoBehaviour targetComponent = (MonoBehaviour)menuCommand.context;
|
||||
|
||||
if (targetComponent)
|
||||
{
|
||||
MonoScript script = MonoScript.FromMonoBehaviour(targetComponent);
|
||||
if (script) EditorGUIUtility.PingObject(script);
|
||||
}
|
||||
}
|
||||
else if (menuCommand.context is ScriptableObject)
|
||||
{
|
||||
ScriptableObject targetComponent = (ScriptableObject)menuCommand.context;
|
||||
|
||||
if (targetComponent)
|
||||
{
|
||||
MonoScript script = MonoScript.FromScriptableObject(targetComponent);
|
||||
if (script) EditorGUIUtility.PingObject(script);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Utilities/Name iterative selected assets", true)]
|
||||
static bool SetFilenamesCheck(MenuCommand menuCommand)
|
||||
{ return Selection.gameObjects.Length > 0; }
|
||||
|
||||
[MenuItem("Assets/Utilities/Name iterative selected assets", false)]
|
||||
private static void SetFilenames(MenuCommand menuCommand)
|
||||
{
|
||||
if (Selection.gameObjects.Length == 0) return;
|
||||
|
||||
string filename = EditorUtility.SaveFilePanelInProject("Type your target filename (no file will be created)", Selection.gameObjects[0].name, "", "Type your target filename (no file will be created)");
|
||||
filename = filename.Replace("Assets/", "");
|
||||
if (string.IsNullOrEmpty(filename)) return;
|
||||
|
||||
List<GameObject> toRename = new List<GameObject>();
|
||||
GameObject ctx = (GameObject)menuCommand.context;
|
||||
if (ctx) toRename.Add(ctx);
|
||||
|
||||
for (int i = 0; i < Selection.gameObjects.Length; i++)
|
||||
{
|
||||
if (!toRename.Contains(Selection.gameObjects[i])) toRename.Add(Selection.gameObjects[i]);
|
||||
}
|
||||
|
||||
int objects = 0;
|
||||
for (int i = 0; i < toRename.Count; i++)
|
||||
{
|
||||
if (toRename[i] == null) continue;
|
||||
string assetPath = AssetDatabase.GetAssetPath(toRename[i]);
|
||||
if (string.IsNullOrEmpty(assetPath)) continue;
|
||||
|
||||
AssetDatabase.RenameAsset(assetPath, filename + "_" + objects + Path.GetExtension(assetPath));
|
||||
objects++;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
[MenuItem("Assets/Utilities/Add name prefixes for selection", true)]
|
||||
static bool SetPrefixesCheck(MenuCommand menuCommand)
|
||||
{ return Selection.objects.Length > 0; }
|
||||
|
||||
[MenuItem("Assets/Utilities/Add name prefixes for selection", false)]
|
||||
private static void SetPrefixes(MenuCommand menuCommand)
|
||||
{
|
||||
if (Selection.objects.Length == 0) return;
|
||||
|
||||
for (int i = 0; i < Selection.objects.Length; i++)
|
||||
{
|
||||
if (Selection.objects[i] == null) continue;
|
||||
|
||||
string assetPath = AssetDatabase.GetAssetPath(Selection.objects[i]);
|
||||
if (string.IsNullOrEmpty(assetPath)) continue;
|
||||
|
||||
string prefix = GetPrefix(Selection.objects[i], assetPath);
|
||||
if (string.IsNullOrEmpty(prefix)) continue;
|
||||
{
|
||||
AssetDatabase.RenameAsset(assetPath, prefix + Selection.objects[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b29f5ef3617d5fc4593ec345c43482f8
|
||||
timeCreated: 1531406488
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,180 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace FIMSpace.FEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// FM: Class with basic tools for working in Unity Editor level
|
||||
/// </summary>
|
||||
public static partial class FEditor_MenuAddOptions
|
||||
{
|
||||
|
||||
[MenuItem("Assets/Utilities/Create Prefab and Add Collider", true)]
|
||||
private static bool CreatePrefabOutOfModelAssetCollCheck(MenuCommand menuCommand)
|
||||
{ return IsAnyPrefabable(Selection.objects); }
|
||||
|
||||
[MenuItem("Assets/Utilities/Create Prefab", true)]
|
||||
private static bool CreatePrefabOutOfModelAssetCheck(MenuCommand menuCommand)
|
||||
{ return IsAnyPrefabable(Selection.objects); }
|
||||
|
||||
|
||||
[MenuItem("Assets/Utilities/Create Prefab and Add Collider")]
|
||||
private static void CreatePrefabOutOfModelAssetColl(MenuCommand menuCommand)
|
||||
{
|
||||
if (Selection.objects.Length == 0) return;
|
||||
|
||||
for (int i = 0; i < Selection.objects.Length; i++)
|
||||
{
|
||||
Object ob = Selection.objects[i];
|
||||
var type = PrefabUtility.GetPrefabAssetType(ob);
|
||||
if (type == PrefabAssetType.NotAPrefab || type == PrefabAssetType.MissingAsset) continue;
|
||||
|
||||
string directory = Path.GetDirectoryName(AssetDatabase.GetAssetPath(ob));
|
||||
GameObject toSave = GeneratePrePrefabObject(ob);
|
||||
|
||||
if (toSave == null) return;
|
||||
|
||||
MeshFilter f = toSave.GetComponentInChildren<MeshFilter>();
|
||||
if (f == null) f = FTransformMethods.FindComponentInAllChildren<MeshFilter>(toSave.transform);
|
||||
|
||||
if (f)
|
||||
f.gameObject.AddComponent<BoxCollider>();
|
||||
else
|
||||
toSave.AddComponent<BoxCollider>();
|
||||
|
||||
directory = Path.Combine(directory, toSave.name + ".prefab");
|
||||
PrefabUtility.SaveAsPrefabAsset(toSave, directory);
|
||||
|
||||
if (toSave) GameObject.DestroyImmediate(toSave);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[MenuItem("Assets/Utilities/Create Prefab")]
|
||||
private static void CreatePrefabOutOfModelAsset(MenuCommand menuCommand)
|
||||
{
|
||||
if (Selection.objects.Length == 0) return;
|
||||
|
||||
for (int i = 0; i < Selection.objects.Length; i++)
|
||||
{
|
||||
Object ob = Selection.objects[i];
|
||||
var type = PrefabUtility.GetPrefabAssetType(ob);
|
||||
if (type == PrefabAssetType.NotAPrefab || type == PrefabAssetType.MissingAsset) continue;
|
||||
|
||||
string directory = Path.GetDirectoryName(AssetDatabase.GetAssetPath(ob));
|
||||
|
||||
GameObject toSave = GeneratePrePrefabObject(ob);
|
||||
|
||||
directory = Path.Combine(directory, toSave.name + ".prefab");
|
||||
PrefabUtility.SaveAsPrefabAsset(toSave, directory);
|
||||
|
||||
if (toSave) GameObject.DestroyImmediate(toSave);
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Utilities/Create Material with this as Default Texture", true)]
|
||||
private static bool CreateMaterialWithTexCheck(MenuCommand menuCommand)
|
||||
{ return IsAnyTexture(Selection.objects); }
|
||||
|
||||
[MenuItem("Assets/Utilities/Create Material with this as Default Texture", false)]
|
||||
private static void CreateMaterialWithTex(MenuCommand menuCommand)
|
||||
{
|
||||
if (!IsAnyTexture(Selection.objects)) return;
|
||||
if (Selection.objects.Length == 0) return;
|
||||
|
||||
Shader defSh = Shader.Find("Standard");
|
||||
|
||||
if (defSh is null)
|
||||
{
|
||||
UnityEngine.Debug.Log("No Default Shader!");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < Selection.objects.Length; i++)
|
||||
{
|
||||
Object ob = Selection.objects[i];
|
||||
|
||||
TextureImporter texImp = (TextureImporter)AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(ob));
|
||||
if (texImp is null) continue;
|
||||
|
||||
string directory = Path.GetDirectoryName(AssetDatabase.GetAssetPath(ob));
|
||||
|
||||
Material newMat = new Material(defSh);
|
||||
newMat.SetTexture("_MainTex", (Texture2D)ob);
|
||||
newMat.SetFloat("_Glossiness", 0f);
|
||||
|
||||
newMat.name = ClearMaterialTypeNames(ob.name);
|
||||
|
||||
directory = Path.Combine(directory, newMat.name + ".mat");
|
||||
AssetDatabase.CreateAsset(newMat, directory);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Utilities/Sub-Assets/Destroy Sub Asset", true)]
|
||||
private static bool DestroySubAssetCheck(MenuCommand menuCommand)
|
||||
{ if( Selection.objects.Length == 0 ) return false; return AssetDatabase.IsSubAsset(Selection.objects[0]); }
|
||||
|
||||
[MenuItem("Assets/Utilities/Sub-Assets/Destroy Sub Asset", false)]
|
||||
private static void DestroySubAsset(MenuCommand menuCommand)
|
||||
{
|
||||
if (Selection.objects.Length == 0) return;
|
||||
if (AssetDatabase.IsSubAsset(Selection.objects[0]) == false) return;
|
||||
GameObject.DestroyImmediate(Selection.objects[0], true);
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Utilities/Sub-Assets/Unhide All Sub Assets", false)]
|
||||
private static void UnhideSubAssets(MenuCommand menuCommand)
|
||||
{
|
||||
if (Selection.objects.Length == 0) return;
|
||||
var allAtPath = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(Selection.objects[0]));
|
||||
|
||||
for (int i = 0; i < allAtPath.Length; i++)
|
||||
{
|
||||
if (allAtPath[i].hideFlags != HideFlags.HideInHierarchy) continue;
|
||||
//if (AssetDatabase.IsSubAsset(allAtPath[i]) == false) continue;
|
||||
allAtPath[i].hideFlags = HideFlags.None;
|
||||
EditorUtility.SetDirty(allAtPath[i]);
|
||||
}
|
||||
|
||||
EditorUtility.SetDirty(Selection.objects[0]);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
|
||||
[MenuItem("Assets/Utilities/Sub-Assets/Hide All Sub Assets", false)]
|
||||
private static void HideSubAssets(MenuCommand menuCommand)
|
||||
{
|
||||
if (Selection.objects.Length == 0) return;
|
||||
var allAtPath = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(Selection.objects[0]));
|
||||
|
||||
for (int i = 0; i < allAtPath.Length; i++)
|
||||
{
|
||||
if (AssetDatabase.IsSubAsset(allAtPath[i]) == false) continue;
|
||||
allAtPath[i].hideFlags = HideFlags.HideInHierarchy;
|
||||
EditorUtility.SetDirty(allAtPath[i]);
|
||||
}
|
||||
|
||||
EditorUtility.SetDirty(Selection.objects[0]);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
|
||||
private static string ClearMaterialTypeNames(string name)
|
||||
{
|
||||
name = name.Replace("Albedo", "");
|
||||
name = name.Replace("ALBEDO", "");
|
||||
name = name.Replace("Texture", "Material");
|
||||
name = name.Replace("TEXTURE", "MATERIAL");
|
||||
name = name.Replace("Diffuse", "");
|
||||
name = name.Replace("Normal", "");
|
||||
name = name.Replace("TEX", "MAT");
|
||||
name = name.Replace("Tex", "Mat");
|
||||
name = name.Replace("tex", "mat");
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cec1e196f2e27048bdc5dd89e35a0eb
|
||||
timeCreated: 1531406488
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,116 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace FIMSpace.FEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// FM: Class with basic tools for working in Unity Editor level
|
||||
/// </summary>
|
||||
public static partial class FEditor_MenuAddOptions
|
||||
{
|
||||
|
||||
#region Prefixes
|
||||
|
||||
private static string GetPrefix(UnityEngine.Object o, string path)
|
||||
{
|
||||
AssetImporter a = AssetImporter.GetAtPath(path);
|
||||
if (a == null) return "";
|
||||
|
||||
if (HaveAnyPrefix(o.name)) return "";
|
||||
|
||||
string targetPrefix = "";
|
||||
if (PrefabUtility.IsPartOfAnyPrefab(o))
|
||||
{
|
||||
PrefabAssetType type = PrefabUtility.GetPrefabAssetType(o);
|
||||
if (type == PrefabAssetType.Regular) return "PR_";
|
||||
else if (type == PrefabAssetType.Variant) return "PR_V_";
|
||||
}
|
||||
|
||||
if (a is TextureImporter) targetPrefix = "TEX_";
|
||||
else if (a is AudioImporter) targetPrefix = "AC_";
|
||||
else if (a is ModelImporter)
|
||||
{
|
||||
PrefabAssetType type = PrefabUtility.GetPrefabAssetType(o);
|
||||
if (type == PrefabAssetType.Regular || type == PrefabAssetType.Variant)
|
||||
targetPrefix = "PR_";
|
||||
else
|
||||
targetPrefix = "";// "MDL_";
|
||||
}
|
||||
else if (a is ShaderImporter) targetPrefix = "SH_";
|
||||
else if (o is Material) targetPrefix = "MAT_";
|
||||
|
||||
if (HavePrefix(o.name, targetPrefix)) return "";
|
||||
|
||||
return targetPrefix;
|
||||
}
|
||||
|
||||
private static bool HaveAnyPrefix(string sourceName)
|
||||
{
|
||||
if (sourceName.Length > 3) if (sourceName[2] == '_') return true;
|
||||
if (sourceName.Length > 4) if (sourceName[3] == '_') return true;
|
||||
if (sourceName.Length > 5) if (sourceName[4] == '_') return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool HavePrefix(string sourceName, string targetPrefix)
|
||||
{
|
||||
if (sourceName.StartsWith(targetPrefix)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Helper Prefabs Methods
|
||||
|
||||
static bool IsAnyPrefabable(Object[] list)
|
||||
{
|
||||
if (list.Length == 0) return false;
|
||||
|
||||
for (int i = 0; i < list.Length; i++)
|
||||
{
|
||||
Object ob = Selection.objects[i];
|
||||
var type = PrefabUtility.GetPrefabAssetType(ob);
|
||||
if (type == PrefabAssetType.NotAPrefab || type == PrefabAssetType.MissingAsset) continue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static GameObject GeneratePrePrefabObject(Object ob)
|
||||
{
|
||||
var type = PrefabUtility.GetPrefabAssetType(ob);
|
||||
if (type == PrefabAssetType.NotAPrefab || type == PrefabAssetType.MissingAsset) return null;
|
||||
|
||||
string path = AssetDatabase.GetAssetPath(ob);
|
||||
|
||||
GameObject toSave = (GameObject)PrefabUtility.InstantiatePrefab(ob);
|
||||
|
||||
toSave.name = "PR_" + Path.GetFileNameWithoutExtension(path);
|
||||
|
||||
return toSave;
|
||||
}
|
||||
|
||||
static bool IsAnyTexture(Object[] list)
|
||||
{
|
||||
if (list.Length == 0) return false;
|
||||
|
||||
for (int i = 0; i < list.Length; i++)
|
||||
{
|
||||
Object ob = Selection.objects[i];
|
||||
if (AssetDatabase.Contains(ob) == false) continue;
|
||||
if (ob is Texture2D ) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf5da5e9bac57f54a9e8033aea6bd9ab
|
||||
timeCreated: 1531406488
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user