Skip to content

Instantly share code, notes, and snippets.

@dimmduh
Last active December 21, 2018 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimmduh/ab8b28e72748784acedb19a6f0c208d5 to your computer and use it in GitHub Desktop.
Save dimmduh/ab8b28e72748784acedb19a6f0c208d5 to your computer and use it in GitHub Desktop.
To any Editor folder - Ctrl + Shift + X - cut/paste ; Ctrl + G - no parent
using System;
using UnityEditor;
using UnityEngine;
namespace IOGames.Utils
{
public class IOEditorUtils
{
[MenuItem("IO Games/Удалить Player Prefs", false, -1)]
public static void DeletePlayerPrefs()
{
PlayerPrefs.DeleteAll();
}
[MenuItem("IO Games/Увеличить кеш превью", false, -1)]
public static void Delete()
{
AssetPreview.SetPreviewTextureCacheSize(10000000);
}
[MenuItem("IO Games/Очистить память", false, -1)]
public static void ClearMemory()
{
EditorUtility.UnloadUnusedAssetsImmediate();
GC.Collect();
}
private static GameObject[] cutGameObjects;
[MenuItem("IO Games/Hotkeys/CutAndPaste %#x", false, -1)]
public static void CutAndPaste()
{
//cut
if (cutGameObjects == null)
{
cutGameObjects = Selection.gameObjects;
}
else
{
//paste
var parent = Selection.activeGameObject ? Selection.activeGameObject.transform : null;
foreach (var go in cutGameObjects)
{
Undo.SetTransformParent(go.transform, parent, "Change parent");
go.transform.SetAsFirstSibling();
}
cutGameObjects = null;
}
}
[MenuItem("IO Games/Hotkeys/NoParent %g", false, -1)]
public static void NoParent()
{
if (Selection.gameObjects.Length > 0)
{
foreach (var go in Selection.gameObjects)
{
Undo.SetTransformParent(go.transform, null, "Set no parent");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment