Initial Commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85203140d08dec248979689b1f7dc379
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,378 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class AssetBundler
|
||||
{
|
||||
/// <summary>
|
||||
/// The types of assets to search for in checks.
|
||||
/// </summary>
|
||||
private static readonly string ASSET_SEARCH_QUERY = "t:prefab,t:textAsset,t:audioclip";
|
||||
|
||||
/// <summary>
|
||||
/// Temporary location for building AssetBundles.
|
||||
/// </summary>
|
||||
private static readonly string TEMP_BUILD_FOLDER = "Temp/AssetBundles";
|
||||
|
||||
/// <summary>
|
||||
/// Name of the output bundle file. This needs to match the bundle that you tag your assets with.
|
||||
/// </summary>
|
||||
private static readonly string BUNDLE_FILENAME = "mod.assets";
|
||||
|
||||
/// <summary>
|
||||
/// The output folder to place the completed bundle in.
|
||||
/// </summary>
|
||||
private static readonly string OUTPUT_FOLDER = "content";
|
||||
|
||||
/// <summary>
|
||||
/// The folders to not search for assets in.
|
||||
/// </summary>
|
||||
private static readonly string[] EXCLUDED_FOLDERS = new string[] { "Assets/Editor", "Packages" };
|
||||
|
||||
/// <summary>
|
||||
/// The build target of the asset bundle. Should either be StandaloneWindows or StandaloneOSX, depending on your platform.
|
||||
/// </summary>
|
||||
private BuildTarget Target = BuildTarget.StandaloneWindows;
|
||||
|
||||
/// <summary>
|
||||
/// Number of warnings encountered.
|
||||
/// </summary>
|
||||
private int NumWarnings;
|
||||
|
||||
/// <summary>
|
||||
/// Number of warnings encountered.
|
||||
/// </summary>
|
||||
private string GeneratedAssetBundleTag;
|
||||
|
||||
[MenuItem("PlateUp!/Build Asset Bundle _F6")]
|
||||
public static void BuildAssetBundle()
|
||||
{
|
||||
Debug.LogFormat("Creating \"{0}\" AssetBundle...", BUNDLE_FILENAME);
|
||||
|
||||
AssetBundler bundler = new AssetBundler();
|
||||
|
||||
if (Application.platform == RuntimePlatform.OSXEditor) bundler.Target = BuildTarget.StandaloneOSX;
|
||||
|
||||
// Randomly generate the resulting name of the asset bundle
|
||||
bundler.GenerateRandomAssetBundleTag();
|
||||
|
||||
bool success = false;
|
||||
try
|
||||
{
|
||||
// Check for assets
|
||||
bundler.WarnIfAssetsAreNotTagged();
|
||||
bundler.WarnIfZeroAssetsAreTagged();
|
||||
bundler.WarnIfMeshAssetsAreTagged();
|
||||
// bundler.WarnIfMaterialsAreTaggedOrIncluded();
|
||||
|
||||
// Delete the contents of OUTPUT_FOLDER
|
||||
bundler.CleanBuildFolder();
|
||||
|
||||
// Temporarily move the tagged assets to the temporary tag
|
||||
bundler.MoveAssetsToTemporaryAssetBundle();
|
||||
|
||||
// Lastly, create the asset bundle itself and copy it to the output folder
|
||||
bundler.CreateAssetBundle();
|
||||
|
||||
success = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogErrorFormat("Failed to build AssetBundle: {0}\n{1}", e.Message, e.StackTrace);
|
||||
}
|
||||
|
||||
// Return assets to the original asset bundle tag
|
||||
bundler.RestoreAssetBundleTags();
|
||||
AssetDatabase.RemoveUnusedAssetBundleNames();
|
||||
|
||||
if (success)
|
||||
{
|
||||
Debug.LogFormat("[{0}] Build complete with {1} warnings! Output: {2} (temporary ID: {3})", DateTime.Now.ToLocalTime(), bundler.NumWarnings, OUTPUT_FOLDER + "/" + BUNDLE_FILENAME, bundler.GeneratedAssetBundleTag);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate the random asset bundle tag to use when building the asset bundle.
|
||||
/// </summary>
|
||||
private void GenerateRandomAssetBundleTag()
|
||||
{
|
||||
System.Random rand = new System.Random();
|
||||
GeneratedAssetBundleTag = $"mod-{rand.Next(0, int.MaxValue)}.assets";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move assets tagged with BUNDLE_FILENAME to the temporary asset bundle
|
||||
/// </summary>
|
||||
private void MoveAssetsToTemporaryAssetBundle()
|
||||
{
|
||||
SubstituteAssetBundleTags(BUNDLE_FILENAME, GeneratedAssetBundleTag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move assets tagged with the temporary asset bundle back to BUNDLE_FILENAME
|
||||
/// </summary>
|
||||
private void RestoreAssetBundleTags()
|
||||
{
|
||||
SubstituteAssetBundleTags(GeneratedAssetBundleTag, BUNDLE_FILENAME);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find all assets tagged with a certain asset bundle tag and replace them with another tag
|
||||
/// </summary>
|
||||
/// <param name="from">The asset bundle tag to search for</param>
|
||||
/// <param name="to">The new asset bundle tag</param>
|
||||
private void SubstituteAssetBundleTags(string from, string to)
|
||||
{
|
||||
string[] assetGUIDs = AssetDatabase.FindAssets($"b:{from}");
|
||||
foreach (var assetGUID in assetGUIDs)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(assetGUID);
|
||||
var importer = AssetImporter.GetAtPath(path);
|
||||
importer.assetBundleName = to;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete and recreate the OUTPUT_FOLDER to ensure a clean build.
|
||||
/// </summary>
|
||||
protected void CleanBuildFolder()
|
||||
{
|
||||
Debug.LogFormat("Cleaning {0}...", OUTPUT_FOLDER);
|
||||
|
||||
if (Directory.Exists(OUTPUT_FOLDER))
|
||||
{
|
||||
Directory.Delete(OUTPUT_FOLDER, true);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(OUTPUT_FOLDER);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Build the AssetBundle itself and copy it to the OUTPUT_FOLDER.
|
||||
/// </summary>
|
||||
protected void CreateAssetBundle()
|
||||
{
|
||||
Debug.Log("Building AssetBundle...");
|
||||
|
||||
// Build all AssetBundles to the TEMP_BUILD_FOLDER
|
||||
if (!Directory.Exists(TEMP_BUILD_FOLDER))
|
||||
{
|
||||
Directory.CreateDirectory(TEMP_BUILD_FOLDER);
|
||||
}
|
||||
|
||||
#pragma warning disable 618
|
||||
// Build the asset bundle with the CollectDependencies flag. This is necessary or else ScriptableObjects will
|
||||
// not be accessible within the asset bundle. Unity has deprecated this flag claiming it is now always active,
|
||||
// but due to a bug we must still include it (and ignore the warning).
|
||||
BuildPipeline.BuildAssetBundles(
|
||||
TEMP_BUILD_FOLDER,
|
||||
BuildAssetBundleOptions.UncompressedAssetBundle | BuildAssetBundleOptions.CollectDependencies,
|
||||
Target);
|
||||
#pragma warning restore 618
|
||||
|
||||
// We are only interested in the BUNDLE_FILENAME bundle (and not any extra AssetBundle or the manifest files
|
||||
// that Unity makes), so just copy that to the final output folder
|
||||
string srcPath = Path.Combine(TEMP_BUILD_FOLDER, GeneratedAssetBundleTag);
|
||||
string destPath = Path.Combine(OUTPUT_FOLDER, BUNDLE_FILENAME);
|
||||
File.Copy(srcPath, destPath, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the given path is a search path.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to check.</param>
|
||||
/// <returns>true if the given path is a search path, otherwise false.</returns>
|
||||
protected static bool IsIncludedAssetPath(string path)
|
||||
{
|
||||
foreach (string excludedPath in EXCLUDED_FOLDERS)
|
||||
{
|
||||
if (path.StartsWith(excludedPath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log a warning for all potential assets that are not currently tagged to be in this AssetBundle.
|
||||
/// </summary>
|
||||
protected void WarnIfAssetsAreNotTagged()
|
||||
{
|
||||
string[] assetGUIDs = AssetDatabase.FindAssets(ASSET_SEARCH_QUERY);
|
||||
foreach (var assetGUID in assetGUIDs)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(assetGUID);
|
||||
if (!IsIncludedAssetPath(path))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var importer = AssetImporter.GetAtPath(path);
|
||||
if (!importer.assetBundleName.Equals(BUNDLE_FILENAME))
|
||||
{
|
||||
// Debug.LogWarningFormat("Asset \"{0}\" is not tagged with \"{1}\" and will not be included in the AssetBundle!", path, BUNDLE_FILENAME);
|
||||
// ++NumWarnings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify that there is at least one asset to be included in the asset bundle.
|
||||
/// </summary>
|
||||
protected void WarnIfZeroAssetsAreTagged()
|
||||
{
|
||||
string[] assetsInBundle = AssetDatabase.FindAssets($"{ASSET_SEARCH_QUERY},b:{BUNDLE_FILENAME}");
|
||||
if (assetsInBundle.Length == 0)
|
||||
{
|
||||
// throw new Exception(string.Format("No assets have been tagged for inclusion in the {0} AssetBundle.", BUNDLE_FILENAME));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Warn if there are any mesh assets tagged. If so, the user probably meant to tag a prefab instead.
|
||||
/// </summary>
|
||||
protected void WarnIfMeshAssetsAreTagged()
|
||||
{
|
||||
string[] assetGUIDs = AssetDatabase.FindAssets($"t:mesh,b:{BUNDLE_FILENAME}");
|
||||
foreach (var assetGUID in assetGUIDs)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(assetGUID);
|
||||
if (!IsIncludedAssetPath(path))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Debug.LogWarningFormat("Mesh asset \"{0}\" is tagged for inclusion in the {1} AssetBundle! This is likely a mistake. You should include a prefab instead.", path, BUNDLE_FILENAME);
|
||||
++NumWarnings;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Warn if there are any material assets tagged. If so, the user probably meant to tag a prefab instead.
|
||||
/// </summary>
|
||||
protected void WarnIfMaterialsAreTaggedOrIncluded()
|
||||
{
|
||||
// Check for directly tagged materials
|
||||
string[] assetGUIDs = AssetDatabase.FindAssets($"t:material,b:{BUNDLE_FILENAME}");
|
||||
foreach (var assetGUID in assetGUIDs)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(assetGUID);
|
||||
if (!IsIncludedAssetPath(path))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Debug.LogWarningFormat("Material asset \"{0}\" is tagged for inclusion in the {1} AssetBundle! This is likely a mistake. You should use generate materials using the vanilla shaders instead.", path, BUNDLE_FILENAME);
|
||||
++NumWarnings;
|
||||
}
|
||||
|
||||
// Check for materials assigned to prefabs
|
||||
assetGUIDs = AssetDatabase.FindAssets($"t:prefab,b:{BUNDLE_FILENAME}");
|
||||
foreach (var assetGUID in assetGUIDs)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(assetGUID);
|
||||
if (!IsIncludedAssetPath(path))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(path);
|
||||
MeshRenderer[] renderers = prefab.GetComponentsInChildren<MeshRenderer>();
|
||||
foreach (MeshRenderer renderer in renderers)
|
||||
{
|
||||
if (renderer.sharedMaterials.Any(m => m != null))
|
||||
{
|
||||
Debug.LogWarningFormat("Material found attached to bundle prefab in \"{0}\" at \"<root>/{1}\"! This is likely a mistake. To avoid log spam and texturing issues, you should remove these materials or set them to \"None\".", path, GetGameObjectPath(renderer.transform).Split(new char[] { '/' }, 3)[2]);
|
||||
++NumWarnings;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetGameObjectPath(Transform current)
|
||||
{
|
||||
if (current.parent == null)
|
||||
return "/" + current.name;
|
||||
return GetGameObjectPath(current.parent) + "/" + current.name;
|
||||
}
|
||||
|
||||
[MenuItem("PlateUp!/Preparation/[Deprecated] Strip Materials From Prefabs")]
|
||||
public static void RemoveAllPrefabMaterials()
|
||||
{
|
||||
if (!EditorUtility.DisplayDialog("Confirm", "Stripping materials from prefabs is an irreversible process. Perform at your own risk.", "Proceed", "Cancel"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string[] assetGUIDs = AssetDatabase.FindAssets($"t:prefab,b:{BUNDLE_FILENAME}");
|
||||
foreach (var assetGUID in assetGUIDs)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(assetGUID);
|
||||
if (!IsIncludedAssetPath(path))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(path);
|
||||
MeshRenderer[] renderers = prefab.GetComponentsInChildren<MeshRenderer>();
|
||||
foreach (MeshRenderer renderer in renderers)
|
||||
{
|
||||
if (renderer.sharedMaterials.Length > 0)
|
||||
{
|
||||
renderer.sharedMaterials = new Material[renderer.sharedMaterials.Length];
|
||||
Debug.LogFormat("Stripped materials from \"{0}\" at \"<root>/{1}\".", path, GetGameObjectPath(renderer.transform).Split(new char[] { '/' }, 3)[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogFormat("[{0}] Done stripping materials.", DateTime.Now.ToLocalTime());
|
||||
}
|
||||
|
||||
|
||||
|
||||
[MenuItem("PlateUp!/Preparation/[Deprecated] Set Prefab Materials to Default")]
|
||||
public static void SetAllPrefabMaterialsToDefault()
|
||||
{
|
||||
if (!EditorUtility.DisplayDialog("Confirm", "Changing the materials of prefabs is an irreversible process. Perform at your own risk.", "Proceed", "Cancel"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string[] assetGUIDs = AssetDatabase.FindAssets($"t:prefab,b:{BUNDLE_FILENAME}");
|
||||
foreach (var assetGUID in assetGUIDs)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(assetGUID);
|
||||
if (!IsIncludedAssetPath(path))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(path);
|
||||
MeshRenderer[] renderers = prefab.GetComponentsInChildren<MeshRenderer>();
|
||||
Material defaultMaterial = AssetDatabase.GetBuiltinExtraResource<Material>("Default-Material.mat");
|
||||
|
||||
foreach (MeshRenderer renderer in renderers)
|
||||
{
|
||||
if (renderer.sharedMaterials.Length > 0)
|
||||
{
|
||||
var newMaterials = new Material[renderer.sharedMaterials.Length];
|
||||
|
||||
for (int i = 0; i < newMaterials.Length; i++)
|
||||
{
|
||||
newMaterials[i] = defaultMaterial;
|
||||
}
|
||||
|
||||
renderer.sharedMaterials = newMaterials;
|
||||
|
||||
Debug.LogFormat("Set materials from \"{0}\" at \"<root>/{1}\".", path, GetGameObjectPath(renderer.transform).Split(new char[] { '/' }, 3)[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogFormat("[{0}] Done setting materials.", DateTime.Now.ToLocalTime());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc5c1f6feac17c346b6276b3d655d94d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
/*Script created by Pierre Stempin*/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace EmptyAtZeroCreator
|
||||
{
|
||||
public class EmptyAtZero_Creator
|
||||
{
|
||||
const string _Space = EmptyCreator._Space;
|
||||
|
||||
const string featureName = EmptyCreator.CreateEmpty_ + EmptyCreator.At + _Space + EmptyCreator.Zero;
|
||||
const string pathName = EmptyCreator._GameObject + EmptyCreator.Slash + featureName + _Space + shortcutName;
|
||||
const string shortcutName = EmptyCreator.AltSymbol + EmptyCreator.ShortcutLetter;
|
||||
|
||||
[MenuItem (pathName, false, -1)]
|
||||
#if UNITY_4_6 || UNITY_4_7 || UNITY_5 || UNITY_2017_1_OR_NEWER
|
||||
public static void CreateEmptyAtZero (MenuCommand menuCommand)
|
||||
{
|
||||
EmptyCreator.CreateEmptyGameObject (featureName, true, false, menuCommand);
|
||||
}
|
||||
#else
|
||||
public static void CreateEmptyAtZero ()
|
||||
{
|
||||
EmptyCreator.CreateEmptyGameObject (featureName, true, false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e5429d19f3bf024687e68116646311f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
/*Script created by Pierre Stempin*/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace EmptyAtZeroCreator
|
||||
{
|
||||
public class EmptyChildAtGlobalZero_Creator
|
||||
{
|
||||
const string _Space = EmptyCreator._Space;
|
||||
const string Slash = EmptyCreator.Slash;
|
||||
|
||||
const string _global = "Global";
|
||||
const string featureName = EmptyCreator.CreateEmptyChildAt_ + _global + _Space + EmptyCreator.Zero;
|
||||
const string pathName = EmptyCreator._GameObject + EmptyCreator.Slash + featureName + _Space + shortcutName;
|
||||
const string shortcutName = EmptyCreator.ControlSymbol + EmptyCreator.AltSymbol + EmptyCreator.ShortcutLetter;
|
||||
|
||||
[MenuItem (pathName, false)]
|
||||
#if UNITY_4_6 || UNITY_4_7 || UNITY_5 || UNITY_2017_1_OR_NEWER
|
||||
public static void CreateEmptyChildAtGlobalZero (MenuCommand menuCommand)
|
||||
{
|
||||
EmptyCreator.CreateEmptyGameObject (featureName, false, false, menuCommand);
|
||||
}
|
||||
#else
|
||||
public static void CreateEmptyChildAtGlobalZero ()
|
||||
{
|
||||
EmptyCreator.CreateEmptyGameObject (featureName, false, false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 456a5f32c7388224f85266f272b674bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
/*Script created by Pierre Stempin*/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace EmptyAtZeroCreator
|
||||
{
|
||||
public class EmptyChildAtLocalZero_Creator
|
||||
{
|
||||
const string _Space = EmptyCreator._Space;
|
||||
const string Slash = EmptyCreator.Slash;
|
||||
|
||||
const string _local = "Local";
|
||||
const string featureName = EmptyCreator.CreateEmptyChildAt_ + _local + _Space + EmptyCreator.Zero;
|
||||
const string pathName = EmptyCreator._GameObject + EmptyCreator.Slash + featureName + _Space + shortcutName;
|
||||
const string shortcutName = EmptyCreator.ControlSymbol + EmptyCreator.AltSymbol + EmptyCreator.ShiftSymbol + EmptyCreator.ShortcutLetter;
|
||||
|
||||
[MenuItem (pathName, false)]
|
||||
#if UNITY_4_6 || UNITY_4_7 || UNITY_5 || UNITY_2017_1_OR_NEWER
|
||||
public static void CreateEmptyChildAtLocalZero (MenuCommand menuCommand)
|
||||
{
|
||||
EmptyCreator.CreateEmptyGameObject (featureName, false, true, menuCommand);
|
||||
}
|
||||
#else
|
||||
public static void CreateEmptyChildAtLocalZero ()
|
||||
{
|
||||
EmptyCreator.CreateEmptyGameObject (featureName, false, true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 429399a95ff47fc4f8a3627665c1f53d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,97 @@
|
||||
/*Script created by Pierre Stempin*/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace EmptyAtZeroCreator
|
||||
{
|
||||
public class EmptyCreator
|
||||
{
|
||||
public const string _GameObject = "GameObject";
|
||||
public const string _Tools = "Tools";
|
||||
|
||||
public const string _Space = " ";
|
||||
public const string Slash = "/";
|
||||
|
||||
public const string CreateEmpty_ = create + _Space + empty + _Space;
|
||||
public const string EmptyAtZeroCreator = empty + _Space + At + _Space + Zero + _Space + creator;
|
||||
public const string CreateEmptyChildAt_ = CreateEmpty_ + Child + _Space + At + _Space;
|
||||
|
||||
const string create = "Create";
|
||||
const string empty = "Empty";
|
||||
const string creator = "Creator";
|
||||
const string Child = "Child";
|
||||
|
||||
public const string At = "At";
|
||||
public const string Zero = "Zero";
|
||||
|
||||
public const string ShortcutLetter = "N";
|
||||
public const string ControlSymbol = "%";
|
||||
public const string ShiftSymbol = "#";
|
||||
public const string AltSymbol = "&";
|
||||
|
||||
#if UNITY_4_6 || UNITY_4_7 || UNITY_5 || UNITY_2017_1_OR_NEWER
|
||||
public static void CreateEmptyGameObject (string _featureName, bool hasToDeselect, bool hasToResetLocalValues, MenuCommand menuCommand)
|
||||
#else
|
||||
public static void CreateEmptyGameObject (string _featureName, bool hasToDeselect, bool hasToResetLocalValues)
|
||||
#endif
|
||||
{
|
||||
if (hasToDeselect)
|
||||
{
|
||||
//Reset selection
|
||||
Selection.activeGameObject = null;
|
||||
}
|
||||
|
||||
//Create the new empty gameObject
|
||||
string gameObjectName = _GameObject;
|
||||
GameObject spawnedGameObject = new GameObject (gameObjectName);
|
||||
|
||||
|
||||
if (hasToDeselect)
|
||||
{
|
||||
#if UNITY_4_6 || UNITY_4_7 || UNITY_5 || UNITY_2017_1_OR_NEWER
|
||||
GameObjectUtility.SetParentAndAlign (spawnedGameObject, menuCommand.context as GameObject);
|
||||
#endif
|
||||
}
|
||||
|
||||
//Undo
|
||||
string undoMethodName = _featureName;
|
||||
Undo.RegisterCreatedObjectUndo (spawnedGameObject, undoMethodName);
|
||||
|
||||
if (Selection.activeGameObject != null)
|
||||
{
|
||||
//Set parent
|
||||
spawnedGameObject.transform.parent = Selection.activeGameObject.transform;
|
||||
|
||||
if (hasToResetLocalValues)
|
||||
{
|
||||
//Reset local values
|
||||
spawnedGameObject.transform.localPosition = Vector3.zero;
|
||||
spawnedGameObject.transform.localRotation = Quaternion.identity;
|
||||
spawnedGameObject.transform.localScale = Vector3.one;
|
||||
}
|
||||
}
|
||||
|
||||
//Select the spawned gameObject
|
||||
Selection.activeGameObject = spawnedGameObject;
|
||||
|
||||
#if UNITY_4_6 || UNITY_4_7 || UNITY_5 || UNITY_2017_1_OR_NEWER
|
||||
//Add a RectTransform if needed
|
||||
if (spawnedGameObject.transform.parent != null)
|
||||
{
|
||||
RectTransform parentRectTransform = spawnedGameObject.transform.parent.GetComponent <RectTransform> ();
|
||||
|
||||
if (parentRectTransform != null)
|
||||
{
|
||||
RectTransform rectTransform = spawnedGameObject.gameObject.AddComponent (typeof (RectTransform)) as RectTransform;
|
||||
rectTransform.anchorMin = Vector2.zero;
|
||||
rectTransform.anchorMax = Vector2.one;
|
||||
rectTransform.offsetMin = Vector2.zero;
|
||||
rectTransform.offsetMax = Vector2.zero;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 303b4b3c0366bd9449eb1ffe35f8adc3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e85d8850e05d97c428056553262fa1d5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: de640fe3d0db1804a85f9fc8f5cadab6, type: 3}
|
||||
m_Name: ForwardRenderer
|
||||
m_EditorClassIdentifier:
|
||||
m_RendererFeatures: []
|
||||
m_RendererFeatureMap:
|
||||
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
|
||||
xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2}
|
||||
shaders:
|
||||
blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3}
|
||||
copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
|
||||
screenSpaceShadowPS: {fileID: 4800000, guid: 0f854b35a0cf61a429bd5dcfea30eddd, type: 3}
|
||||
samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
|
||||
tileDepthInfoPS: {fileID: 0}
|
||||
tileDeferredPS: {fileID: 0}
|
||||
stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
|
||||
fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
|
||||
materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3}
|
||||
m_OpaqueLayerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_TransparentLayerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_DefaultStencilState:
|
||||
overrideStencilState: 0
|
||||
stencilReference: 0
|
||||
stencilCompareFunction: 8
|
||||
passOperation: 0
|
||||
failOperation: 0
|
||||
zFailOperation: 0
|
||||
m_ShadowTransparentReceive: 1
|
||||
m_RenderingMode: 0
|
||||
m_AccurateGbufferNormals: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a8e21d5c33334b11b34a596161b9360
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,118 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-7893295128165547882
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0b2db86121404754db890f4c8dfe81b2, type: 3}
|
||||
m_Name: Bloom
|
||||
m_EditorClassIdentifier:
|
||||
active: 1
|
||||
m_AdvancedMode: 0
|
||||
threshold:
|
||||
m_OverrideState: 1
|
||||
m_Value: 1
|
||||
min: 0
|
||||
intensity:
|
||||
m_OverrideState: 1
|
||||
m_Value: 1
|
||||
min: 0
|
||||
scatter:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.7
|
||||
min: 0
|
||||
max: 1
|
||||
clamp:
|
||||
m_OverrideState: 0
|
||||
m_Value: 65472
|
||||
min: 0
|
||||
tint:
|
||||
m_OverrideState: 0
|
||||
m_Value: {r: 1, g: 1, b: 1, a: 1}
|
||||
hdr: 0
|
||||
showAlpha: 0
|
||||
showEyeDropper: 1
|
||||
highQualityFiltering:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
dirtTexture:
|
||||
m_OverrideState: 0
|
||||
m_Value: {fileID: 0}
|
||||
dirtIntensity:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
min: 0
|
||||
--- !u!114 &-7011558710299706105
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 899c54efeace73346a0a16faa3afe726, type: 3}
|
||||
m_Name: Vignette
|
||||
m_EditorClassIdentifier:
|
||||
active: 1
|
||||
m_AdvancedMode: 0
|
||||
color:
|
||||
m_OverrideState: 0
|
||||
m_Value: {r: 0, g: 0, b: 0, a: 1}
|
||||
hdr: 0
|
||||
showAlpha: 0
|
||||
showEyeDropper: 1
|
||||
center:
|
||||
m_OverrideState: 0
|
||||
m_Value: {x: 0.5, y: 0.5}
|
||||
intensity:
|
||||
m_OverrideState: 1
|
||||
m_Value: 0.25
|
||||
min: 0
|
||||
max: 1
|
||||
smoothness:
|
||||
m_OverrideState: 1
|
||||
m_Value: 0.4
|
||||
min: 0.01
|
||||
max: 1
|
||||
rounded:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
|
||||
m_Name: SampleSceneProfile
|
||||
m_EditorClassIdentifier:
|
||||
components:
|
||||
- {fileID: 849379129802519247}
|
||||
- {fileID: -7893295128165547882}
|
||||
- {fileID: -7011558710299706105}
|
||||
--- !u!114 &849379129802519247
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 97c23e3b12dc18c42a140437e53d3951, type: 3}
|
||||
m_Name: Tonemapping
|
||||
m_EditorClassIdentifier:
|
||||
active: 1
|
||||
m_AdvancedMode: 0
|
||||
mode:
|
||||
m_OverrideState: 1
|
||||
m_Value: 2
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10fc4df2da32a41aaa32d77bc913491c
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
|
||||
m_Name: UniversalRP-HighQuality
|
||||
m_EditorClassIdentifier:
|
||||
k_AssetVersion: 5
|
||||
k_AssetPreviousVersion: 5
|
||||
m_RendererType: 1
|
||||
m_RendererData: {fileID: 0}
|
||||
m_RendererDataList:
|
||||
- {fileID: 11400000, guid: 4a8e21d5c33334b11b34a596161b9360, type: 2}
|
||||
m_DefaultRendererIndex: 0
|
||||
m_RequireDepthTexture: 0
|
||||
m_RequireOpaqueTexture: 0
|
||||
m_OpaqueDownsampling: 1
|
||||
m_SupportsHDR: 1
|
||||
m_MSAA: 2
|
||||
m_RenderScale: 1
|
||||
m_MainLightRenderingMode: 1
|
||||
m_MainLightShadowsSupported: 1
|
||||
m_MainLightShadowmapResolution: 2048
|
||||
m_AdditionalLightsRenderingMode: 1
|
||||
m_AdditionalLightsPerObjectLimit: 4
|
||||
m_AdditionalLightShadowsSupported: 1
|
||||
m_AdditionalLightsShadowmapResolution: 512
|
||||
m_ShadowDistance: 50
|
||||
m_ShadowCascades: 1
|
||||
m_Cascade2Split: 0.25
|
||||
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
|
||||
m_ShadowDepthBias: 1
|
||||
m_ShadowNormalBias: 1
|
||||
m_SoftShadowsSupported: 1
|
||||
m_UseSRPBatcher: 1
|
||||
m_SupportsDynamicBatching: 0
|
||||
m_MixedLightingSupported: 1
|
||||
m_DebugLevel: 0
|
||||
m_ColorGradingMode: 0
|
||||
m_ColorGradingLutSize: 32
|
||||
m_ShadowType: 1
|
||||
m_LocalShadowsSupported: 0
|
||||
m_LocalShadowsAtlasResolution: 256
|
||||
m_MaxPixelLights: 0
|
||||
m_ShadowAtlasResolution: 256
|
||||
m_ShaderVariantLogLevel: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19ba41d7c0026c3459d37c2fe90c55a0
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
|
||||
m_Name: UniversalRP-LowQuality
|
||||
m_EditorClassIdentifier:
|
||||
k_AssetVersion: 5
|
||||
k_AssetPreviousVersion: 5
|
||||
m_RendererType: 1
|
||||
m_RendererData: {fileID: 0}
|
||||
m_RendererDataList:
|
||||
- {fileID: 11400000, guid: 4a8e21d5c33334b11b34a596161b9360, type: 2}
|
||||
m_DefaultRendererIndex: 0
|
||||
m_RequireDepthTexture: 0
|
||||
m_RequireOpaqueTexture: 0
|
||||
m_OpaqueDownsampling: 1
|
||||
m_SupportsHDR: 0
|
||||
m_MSAA: 1
|
||||
m_RenderScale: 1
|
||||
m_MainLightRenderingMode: 1
|
||||
m_MainLightShadowsSupported: 0
|
||||
m_MainLightShadowmapResolution: 2048
|
||||
m_AdditionalLightsRenderingMode: 0
|
||||
m_AdditionalLightsPerObjectLimit: 4
|
||||
m_AdditionalLightShadowsSupported: 0
|
||||
m_AdditionalLightsShadowmapResolution: 512
|
||||
m_ShadowDistance: 50
|
||||
m_ShadowCascades: 0
|
||||
m_Cascade2Split: 0.25
|
||||
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
|
||||
m_ShadowDepthBias: 1
|
||||
m_ShadowNormalBias: 1
|
||||
m_SoftShadowsSupported: 0
|
||||
m_UseSRPBatcher: 1
|
||||
m_SupportsDynamicBatching: 0
|
||||
m_MixedLightingSupported: 1
|
||||
m_DebugLevel: 0
|
||||
m_ColorGradingMode: 0
|
||||
m_ColorGradingLutSize: 16
|
||||
m_ShadowType: 1
|
||||
m_LocalShadowsSupported: 0
|
||||
m_LocalShadowsAtlasResolution: 256
|
||||
m_MaxPixelLights: 0
|
||||
m_ShadowAtlasResolution: 256
|
||||
m_ShaderVariantLogLevel: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a31e9f9f9c9d4b9429ed0d1234e22103
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
|
||||
m_Name: UniversalRP-MediumQuality
|
||||
m_EditorClassIdentifier:
|
||||
k_AssetVersion: 5
|
||||
k_AssetPreviousVersion: 5
|
||||
m_RendererType: 1
|
||||
m_RendererData: {fileID: 0}
|
||||
m_RendererDataList:
|
||||
- {fileID: 11400000, guid: 4a8e21d5c33334b11b34a596161b9360, type: 2}
|
||||
m_DefaultRendererIndex: 0
|
||||
m_RequireDepthTexture: 0
|
||||
m_RequireOpaqueTexture: 0
|
||||
m_OpaqueDownsampling: 1
|
||||
m_SupportsHDR: 0
|
||||
m_MSAA: 1
|
||||
m_RenderScale: 1
|
||||
m_MainLightRenderingMode: 1
|
||||
m_MainLightShadowsSupported: 1
|
||||
m_MainLightShadowmapResolution: 2048
|
||||
m_AdditionalLightsRenderingMode: 1
|
||||
m_AdditionalLightsPerObjectLimit: 4
|
||||
m_AdditionalLightShadowsSupported: 0
|
||||
m_AdditionalLightsShadowmapResolution: 512
|
||||
m_ShadowDistance: 50
|
||||
m_ShadowCascades: 0
|
||||
m_Cascade2Split: 0.25
|
||||
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
|
||||
m_ShadowDepthBias: 1
|
||||
m_ShadowNormalBias: 1
|
||||
m_SoftShadowsSupported: 0
|
||||
m_UseSRPBatcher: 1
|
||||
m_SupportsDynamicBatching: 0
|
||||
m_MixedLightingSupported: 1
|
||||
m_DebugLevel: 0
|
||||
m_ColorGradingMode: 0
|
||||
m_ColorGradingLutSize: 32
|
||||
m_ShadowType: 1
|
||||
m_LocalShadowsSupported: 0
|
||||
m_LocalShadowsAtlasResolution: 256
|
||||
m_MaxPixelLights: 0
|
||||
m_ShadowAtlasResolution: 256
|
||||
m_ShaderVariantLogLevel: 0
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d847b876476d3d6468f5dfcd34266f96
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user