From 235c13f924fc253cbddff76eef04293bd7f6bd24 Mon Sep 17 00:00:00 2001 From: Happyrobot33 Date: Wed, 12 Apr 2023 18:35:36 -0400 Subject: [PATCH] Bring in a bunch of old tools --- .github/workflows/release.yml | 2 +- .../com.happyrobot33.editorgames/Editor.meta | 8 + .../Editor/Editor Games.asmdef | 3 + .../Editor/Editor Games.asmdef.meta | 7 + .../Editor/Inspectactoe.cs | 269 ++++++++++++++++++ .../Editor/Inspectactoe.cs.meta | 11 + .../Editor/InspectorCubeRender.cs | 101 +++++++ .../Editor/InspectorCubeRender.cs.meta | 11 + .../com.happyrobot33.editorgames/package.json | 10 + .../package.json.meta | 2 +- .../Editor.meta | 8 + .../Editor/Inspector Tweaks.asmdef | 3 + .../Editor/Inspector Tweaks.asmdef.meta | 7 + .../Editor/TransformComponent.cs | 148 ++++++++++ .../Editor/TransformComponent.cs.meta | 11 + .../package.json | 10 + .../package.json.meta | 7 + .../com.happyrobot33.placeholder/package.json | 10 - .../com.happyrobot33.shaderfinder/Editor.meta | 8 + .../Editor/Shader Finder.asmdef | 3 + .../Editor/Shader Finder.asmdef.meta | 7 + .../Editor/Shader_Finder.cs | 158 ++++++++++ .../Editor/Shader_Finder.cs.meta | 11 + .../package.json | 10 + .../package.json.meta | 7 + Packages/packages-lock.json | 24 +- 26 files changed, 838 insertions(+), 18 deletions(-) create mode 100644 Packages/com.happyrobot33.editorgames/Editor.meta create mode 100644 Packages/com.happyrobot33.editorgames/Editor/Editor Games.asmdef create mode 100644 Packages/com.happyrobot33.editorgames/Editor/Editor Games.asmdef.meta create mode 100644 Packages/com.happyrobot33.editorgames/Editor/Inspectactoe.cs create mode 100644 Packages/com.happyrobot33.editorgames/Editor/Inspectactoe.cs.meta create mode 100644 Packages/com.happyrobot33.editorgames/Editor/InspectorCubeRender.cs create mode 100644 Packages/com.happyrobot33.editorgames/Editor/InspectorCubeRender.cs.meta create mode 100644 Packages/com.happyrobot33.editorgames/package.json rename Packages/{com.happyrobot33.placeholder => com.happyrobot33.editorgames}/package.json.meta (76%) create mode 100644 Packages/com.happyrobot33.inspectortweaks/Editor.meta create mode 100644 Packages/com.happyrobot33.inspectortweaks/Editor/Inspector Tweaks.asmdef create mode 100644 Packages/com.happyrobot33.inspectortweaks/Editor/Inspector Tweaks.asmdef.meta create mode 100644 Packages/com.happyrobot33.inspectortweaks/Editor/TransformComponent.cs create mode 100644 Packages/com.happyrobot33.inspectortweaks/Editor/TransformComponent.cs.meta create mode 100644 Packages/com.happyrobot33.inspectortweaks/package.json create mode 100644 Packages/com.happyrobot33.inspectortweaks/package.json.meta delete mode 100644 Packages/com.happyrobot33.placeholder/package.json create mode 100644 Packages/com.happyrobot33.shaderfinder/Editor.meta create mode 100644 Packages/com.happyrobot33.shaderfinder/Editor/Shader Finder.asmdef create mode 100644 Packages/com.happyrobot33.shaderfinder/Editor/Shader Finder.asmdef.meta create mode 100644 Packages/com.happyrobot33.shaderfinder/Editor/Shader_Finder.cs create mode 100644 Packages/com.happyrobot33.shaderfinder/Editor/Shader_Finder.cs.meta create mode 100644 Packages/com.happyrobot33.shaderfinder/package.json create mode 100644 Packages/com.happyrobot33.shaderfinder/package.json.meta diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ef4e9cc..363474f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - packageID: [com.happyrobot33.packagewindowconsolidator, com.happyrobot33.placeholder] + packageID: [com.happyrobot33.editorgames, com.happyrobot33.inspectortweaks, com.happyrobot33.packagewindowconsolidator, com.happyrobot33.shaderfinder] steps: - name: Checkout uses: actions/checkout@v3 diff --git a/Packages/com.happyrobot33.editorgames/Editor.meta b/Packages/com.happyrobot33.editorgames/Editor.meta new file mode 100644 index 0000000..98bbf9d --- /dev/null +++ b/Packages/com.happyrobot33.editorgames/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b73491ee7e8ec8e4db3fc337ee830be1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.happyrobot33.editorgames/Editor/Editor Games.asmdef b/Packages/com.happyrobot33.editorgames/Editor/Editor Games.asmdef new file mode 100644 index 0000000..07017fc --- /dev/null +++ b/Packages/com.happyrobot33.editorgames/Editor/Editor Games.asmdef @@ -0,0 +1,3 @@ +{ + "name": "EditorGames" +} diff --git a/Packages/com.happyrobot33.editorgames/Editor/Editor Games.asmdef.meta b/Packages/com.happyrobot33.editorgames/Editor/Editor Games.asmdef.meta new file mode 100644 index 0000000..1d3bf2f --- /dev/null +++ b/Packages/com.happyrobot33.editorgames/Editor/Editor Games.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ee774f1f1d7f45b4486cc35c147b5945 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.happyrobot33.editorgames/Editor/Inspectactoe.cs b/Packages/com.happyrobot33.editorgames/Editor/Inspectactoe.cs new file mode 100644 index 0000000..ecf3445 --- /dev/null +++ b/Packages/com.happyrobot33.editorgames/Editor/Inspectactoe.cs @@ -0,0 +1,269 @@ +/* +Created by: Happyrobot33 +Date: 4/12/2022 +Version: 1.0 +*/ + +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using UnityEngine.UI; + +public class Inspectactoe : EditorWindow +{ + public int[,] board = new int[3, 3]; //0 is empty, 1 is X, 2 is O + public bool isPlayersTurn = true; + + [MenuItem("VRC Packages/Editor Games/Inspectactoe")] + public static void ShowWindow() + { + //create a new window + EditorWindow window = EditorWindow.GetWindow(typeof(Inspectactoe)); + window.Show(); + } + + private void OnGUI() + { + var centeredStyle = new GUIStyle(GUI.skin.GetStyle("BoldLabel")); + centeredStyle.alignment = TextAnchor.UpperCenter; + centeredStyle.fontSize = 30; + GUILayout.Label("Inspectactoe v1.0", centeredStyle); + GUILayout.Label("Yes! You are seeing this right, completely functional tic-tac-toe in an editor window! Dont ask why, just play!", EditorStyles.wordWrappedLabel); + GUILayout.Label("Credit: Happyrobot33", EditorStyles.wordWrappedLabel); + + //button to reset / start a new game + if (GUILayout.Button("Reset / Start New Game")) + { + ResetBoard(); + } + + if (checkForWin() == "Player") + { + GUILayout.Label("Player wins!"); + drawBoard(); + } + else if (checkForWin() == "Computer") + { + GUILayout.Label("Computer wins!"); + drawBoard(); + } + else if (checkForWin() == "Draw") + { + GUILayout.Label("Draw!"); + drawBoard(); + } + else + { + drawBoard(); + } + } + + public string checkForWin() + { + //create a array with all the possible winning patterns + bool[,,] winningPositions = new bool[9, 3, 3]; + + //horizontal + winningPositions[0, 0, 0] = true; + winningPositions[0, 0, 1] = true; + winningPositions[0, 0, 2] = true; + winningPositions[1, 1, 0] = true; + winningPositions[1, 1, 1] = true; + winningPositions[1, 1, 2] = true; + winningPositions[2, 2, 0] = true; + winningPositions[2, 2, 1] = true; + winningPositions[2, 2, 2] = true; + + //vertical + winningPositions[3, 0, 0] = true; + winningPositions[3, 1, 0] = true; + winningPositions[3, 2, 0] = true; + winningPositions[4, 0, 1] = true; + winningPositions[4, 1, 1] = true; + winningPositions[4, 2, 1] = true; + winningPositions[5, 0, 2] = true; + winningPositions[5, 1, 2] = true; + winningPositions[5, 2, 2] = true; + + //diagonal + //top right to bottom left + winningPositions[6, 0, 0] = true; + winningPositions[6, 1, 1] = true; + winningPositions[6, 2, 2] = true; + //top left to bottom right + winningPositions[7, 0, 2] = true; + winningPositions[7, 1, 1] = true; + winningPositions[7, 2, 0] = true; + + //check for a win + for (int i = 0; i < 9; i++) + { + int count = 0; + for (int j = 0; j < 3; j++) + { + for (int k = 0; k < 3; k++) + { + if (winningPositions[i, j, k] == true) + { + if (board[j, k] == 1) + { + count++; + } + else if (board[j, k] == 2) + { + count--; + } + } + } + } + + if (count == 3) + { + return "Player"; + } + else if (count == -3) + { + return "Computer"; + } + } + + bool boardFull = true; + //check for draw + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + if (board[i, j] == 0) + { + boardFull = false; + } + } + } + + if (boardFull) + { + return "Draw"; + } + else + { + return ""; + } + } + + public void ResetBoard() + { + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + board[i, j] = 0; + } + } + + isPlayersTurn = true; + } + + public void drawBoard() + { + if (isPlayersTurn) + { + GUILayout.Label("Player's Turn", EditorStyles.boldLabel); + } + else + { + GUILayout.Label("Computer's Turn", EditorStyles.boldLabel); + } + + //draw a 3 x 3 grid of boolean buttons + for (int i = 0; i < 3; i++) + { + //start row + GUILayout.BeginHorizontal(); + for (int j = 0; j < 3; j++) + { + string cellStatus = ""; + + //determine the status of the cell + switch (board[i, j]) + { + case 0: + cellStatus = "_"; + break; + case 1: + cellStatus = "X"; + break; + case 2: + cellStatus = "O"; + break; + } + + //check if the cell is empty + if (board[i, j] == 0) + { + //coloring + GUIStyle buttonStyle = new GUIStyle(GUI.skin.button); + //set the button background + buttonStyle.normal.background = MakeBackgroundTexture(1, 1, Color.white); + buttonStyle.padding = new RectOffset(0, 0, 0, 0); + buttonStyle.margin = new RectOffset(0, 0, 0, 0); + buttonStyle.border = new RectOffset(0, 0, 0, 0); + + if (GUILayout.Button(cellStatus, buttonStyle) && checkForWin() == "") + { + board[i, j] = 1; + isPlayersTurn = false; + } + else if (Random.value < 0.5 && isPlayersTurn == false && checkForWin() == "") + { + board[i, j] = 2; + isPlayersTurn = true; + } + } + else + { + //turn the GUI interaction off, draw the button, and turn the GUI interaction back on + GUI.enabled = false; + + //coloring + GUIStyle buttonStyle = new GUIStyle(GUI.skin.button); + Texture2D color = new Texture2D(1, 1); + if (board[i, j] == 1) + { + color = MakeBackgroundTexture(1, 1, Color.red); + } + else if (board[i, j] == 2) + { + color = MakeBackgroundTexture(1, 1, Color.blue); + } + //set the button background + buttonStyle.normal.background = color; + buttonStyle.padding = new RectOffset(0, 0, 0, 0); + buttonStyle.margin = new RectOffset(0, 0, 0, 0); + buttonStyle.border = new RectOffset(0, 0, 0, 0); + + GUILayout.Button(cellStatus, buttonStyle); + GUI.enabled = true; + } + } + GUILayout.EndHorizontal(); + } + } + + private Texture2D MakeBackgroundTexture(int width, int height, Color color) + { + Color[] pixels = new Color[width * height]; + + for (int i = 0; i < pixels.Length; i++) + { + pixels[i] = color; + } + + Texture2D backgroundTexture = new Texture2D(width, height); + + backgroundTexture.SetPixels(pixels); + backgroundTexture.Apply(); + + return backgroundTexture; + } +} \ No newline at end of file diff --git a/Packages/com.happyrobot33.editorgames/Editor/Inspectactoe.cs.meta b/Packages/com.happyrobot33.editorgames/Editor/Inspectactoe.cs.meta new file mode 100644 index 0000000..ea2bf10 --- /dev/null +++ b/Packages/com.happyrobot33.editorgames/Editor/Inspectactoe.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7693cb5cf4031f2478ef14b81f2a527f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.happyrobot33.editorgames/Editor/InspectorCubeRender.cs b/Packages/com.happyrobot33.editorgames/Editor/InspectorCubeRender.cs new file mode 100644 index 0000000..0eed491 --- /dev/null +++ b/Packages/com.happyrobot33.editorgames/Editor/InspectorCubeRender.cs @@ -0,0 +1,101 @@ +/* +Created by: Happyrobot33 +Date: 4/12/2022 +Version: 1.0 +*/ + +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +public class InspectorCubeRender : EditorWindow +{ + private static int rez = 30; + private static bool[,] screen = new bool[rez, rez]; + [MenuItem("VRC Packages/Editor Games/Cube Renderer")] + public static void ShowWindow() + { + //create a new window + EditorWindow window = EditorWindow.GetWindow(typeof(InspectorCubeRender)); + //name the window + window.titleContent = new GUIContent("Cube Renderer"); + window.Show(); + } + + public void OnGUI() + { + GenerateSpinningCube(); + DrawScreen(); + } + + public void GenerateSpinningCube() + { + int cubeSize = rez / 2; + int cubeCenter = rez / 2; + + for (int x = 0; x < rez; x++) + { + for (int y = 0; y < rez; y++) + { + if (x < cubeSize && y < cubeSize) + { + screen[x, y] = true; + } + else if (x > cubeCenter && y > cubeCenter) + { + screen[x, y] = true; + } + else + { + screen[x, y] = false; + } + } + } + } + + public void DrawScreen() + { + //get inspector window width + float width = Mathf.Max(position.width, position.height); + + //create a container of specified size + GUILayout.BeginArea(new Rect(0, 0, width, width)); + + GUILayout.BeginVertical(); + //do for each collumn + for (int y = 0; y < screen.GetLength(1); y++) + { + GUILayout.BeginHorizontal(); + //do for each row + for (int x = 0; x < screen.GetLength(0); x++) + { + GUI.skin.box.padding = new RectOffset(0, 0, 0, 0); + GUI.skin.box.margin = new RectOffset(0, 0, 0, 0); + //render box, white if true, black if false + Color color = screen[x, y] ? Color.white : Color.black; + GUILayout.Box(CreatePixelTexture(width / screen.GetLength(0), color), GUILayout.Width(width / screen.GetLength(0)), GUILayout.Height(width / screen.GetLength(0))); + } + GUILayout.EndHorizontal(); + } + GUILayout.BeginVertical(); + + //end container + GUILayout.EndArea(); + } + + //create pixel texture + public Texture CreatePixelTexture(float insize, Color color) + { + Texture2D texture = new Texture2D((int)insize, (int)insize); + for (int x = 0; x < texture.width; x++) + { + for (int y = 0; y < texture.height; y++) + { + texture.SetPixel(x, y, color); + } + } + texture.Apply(); + return texture; + } +} \ No newline at end of file diff --git a/Packages/com.happyrobot33.editorgames/Editor/InspectorCubeRender.cs.meta b/Packages/com.happyrobot33.editorgames/Editor/InspectorCubeRender.cs.meta new file mode 100644 index 0000000..d55021c --- /dev/null +++ b/Packages/com.happyrobot33.editorgames/Editor/InspectorCubeRender.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 306bfb4a4b184d641b0f6d274a9ccebf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.happyrobot33.editorgames/package.json b/Packages/com.happyrobot33.editorgames/package.json new file mode 100644 index 0000000..5350c65 --- /dev/null +++ b/Packages/com.happyrobot33.editorgames/package.json @@ -0,0 +1,10 @@ +{ + "name": "com.happyrobot33.editorgames", + "displayName": "Editor Games", + "version": "1.0.0", + "unity": "2019.4", + "description": "This is a collection of games that I have made that run in the Unity Editor itself", + "author": { + "name": "Happyrobot33" + } +} diff --git a/Packages/com.happyrobot33.placeholder/package.json.meta b/Packages/com.happyrobot33.editorgames/package.json.meta similarity index 76% rename from Packages/com.happyrobot33.placeholder/package.json.meta rename to Packages/com.happyrobot33.editorgames/package.json.meta index 07ad6fa..2c286eb 100644 --- a/Packages/com.happyrobot33.placeholder/package.json.meta +++ b/Packages/com.happyrobot33.editorgames/package.json.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e80eabb15c6d21541b0321cc5910c95d +guid: 7e0ed1122692105489807bb7f56c2728 PackageManifestImporter: externalObjects: {} userData: diff --git a/Packages/com.happyrobot33.inspectortweaks/Editor.meta b/Packages/com.happyrobot33.inspectortweaks/Editor.meta new file mode 100644 index 0000000..b6c9754 --- /dev/null +++ b/Packages/com.happyrobot33.inspectortweaks/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 83504f7c26b23d944966554e6614a549 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.happyrobot33.inspectortweaks/Editor/Inspector Tweaks.asmdef b/Packages/com.happyrobot33.inspectortweaks/Editor/Inspector Tweaks.asmdef new file mode 100644 index 0000000..c169886 --- /dev/null +++ b/Packages/com.happyrobot33.inspectortweaks/Editor/Inspector Tweaks.asmdef @@ -0,0 +1,3 @@ +{ + "name": "InspectorTweaks" +} diff --git a/Packages/com.happyrobot33.inspectortweaks/Editor/Inspector Tweaks.asmdef.meta b/Packages/com.happyrobot33.inspectortweaks/Editor/Inspector Tweaks.asmdef.meta new file mode 100644 index 0000000..97dc6a1 --- /dev/null +++ b/Packages/com.happyrobot33.inspectortweaks/Editor/Inspector Tweaks.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 127b18fbecbb34e4abf39508541369a5 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.happyrobot33.inspectortweaks/Editor/TransformComponent.cs b/Packages/com.happyrobot33.inspectortweaks/Editor/TransformComponent.cs new file mode 100644 index 0000000..ee1452e --- /dev/null +++ b/Packages/com.happyrobot33.inspectortweaks/Editor/TransformComponent.cs @@ -0,0 +1,148 @@ +/* +Created by: Happyrobot33 +Date: 4/12/2022 +Version: 1.0 +*/ + +using System; +using System.Reflection; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +public class CustomTransform : MonoBehaviour +{ + +} + +[CustomEditor(typeof(Transform), true)] +[CanEditMultipleObjects] +public class CustomTransformInspector : Editor { + //Unity's built-in editor + Editor defaultEditor; + Transform transform; + + void OnEnable(){ + //When this inspector is created, also create the built-in inspector + defaultEditor = Editor.CreateEditor(targets, Type.GetType("UnityEditor.TransformInspector, UnityEditor")); + transform = target as Transform; + } + + void OnDisable(){ + //When OnDisable is called, the default editor we created should be destroyed to avoid memory leakage. + //Also, make sure to call any required methods like OnDisable + MethodInfo disableMethod = defaultEditor.GetType().GetMethod("OnDisable", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); + if (disableMethod != null) + disableMethod.Invoke(defaultEditor,null); + DestroyImmediate(defaultEditor); + } + + public override void OnInspectorGUI(){ + GUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Local Space", EditorStyles.boldLabel); + //create a copy button that is only as long as the label + if (GUILayout.Button("Copy", GUILayout.Width(50))) { + //copy the transform's local position, rotation, and scale to the clipboard + string clipboard = ""; + clipboard += transform.localPosition.x + "," + transform.localPosition.y + "," + transform.localPosition.z + "\n"; + clipboard += transform.localRotation.x + "," + transform.localRotation.y + "," + transform.localRotation.z + "," + transform.localRotation.w + "\n"; + clipboard += transform.localScale.x + "," + transform.localScale.y + "," + transform.localScale.z + "\n"; + EditorGUIUtility.systemCopyBuffer = clipboard; + } + GUILayout.EndHorizontal(); + defaultEditor.OnInspectorGUI(); + + //Show World Space Transform + EditorGUILayout.Space(); + GUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("World Space", EditorStyles.boldLabel); + //create a copy button that is only as long as the label + if (GUILayout.Button("Copy", GUILayout.Width(50))) { + //copy the transform's world position, rotation, and scale to the clipboard + string clipboard = ""; + clipboard += transform.position.x + "," + transform.position.y + "," + transform.position.z + "\n"; + clipboard += transform.rotation.x + "," + transform.rotation.y + "," + transform.rotation.z + "," + transform.rotation.w + "\n"; + clipboard += transform.localScale.x + "," + transform.localScale.y + "," + transform.localScale.z + "\n"; + EditorGUIUtility.systemCopyBuffer = clipboard; + } + GUILayout.EndHorizontal(); + + GUI.enabled = false; + Vector3 localPosition = transform.localPosition; + Quaternion localRotation = transform.localRotation; + Vector3 localScale = transform.localScale; + + //defaultEditor.OnInspectorGUI(); + //draw world space transform + EditorGUILayout.Vector3Field("Position", transform.position); + EditorGUILayout.Vector3Field("Rotation", transform.rotation.eulerAngles); + EditorGUILayout.Vector3Field("Scale", transform.localScale); + GUI.enabled = true; + + //add a space + EditorGUILayout.Space(); + + GUILayout.BeginVertical(); + EditorGUILayout.LabelField("Mirroring Tools", EditorStyles.boldLabel); + EditorGUILayout.LabelField("Experimental! May not work as expected!", EditorStyles.miniLabel); + GUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Local Space"); + //create a button to mirror across an axis, not using scale + if (GUILayout.Button("X")) { + //undo state + Undo.RecordObject(transform, "Mirror across X"); + //mirror the transform across the X axis + transform.localPosition = new Vector3(-transform.localPosition.x, transform.localPosition.y, transform.localPosition.z); + //mirror the angle using purely quaternion calculations + transform.localRotation = Quaternion.Euler(new Vector3(-transform.localRotation.eulerAngles.x, transform.localRotation.eulerAngles.y, transform.localRotation.eulerAngles.z)); + } + if (GUILayout.Button("Y")) { + //undo state + Undo.RecordObject(transform, "Mirror across Y"); + //mirror the transform across the Y axis + transform.localPosition = new Vector3(transform.localPosition.x, -transform.localPosition.y, transform.localPosition.z); + transform.localRotation = Quaternion.Euler(new Vector3(transform.localRotation.eulerAngles.x, -transform.localRotation.eulerAngles.y, transform.localRotation.eulerAngles.z)); + } + if (GUILayout.Button("Z")) { + //undo state + Undo.RecordObject(transform, "Mirror across Z"); + //mirror the transform across the Z axis + transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, -transform.localPosition.z); + transform.localRotation = Quaternion.Euler(new Vector3(transform.localRotation.eulerAngles.x, transform.localRotation.eulerAngles.y, -transform.localRotation.eulerAngles.z)); + } + GUILayout.EndHorizontal(); + + GUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("World Space"); + //create a button to mirror across an axis, not using scale + if (GUILayout.Button("X")) { + //undo state + Undo.RecordObject(transform, "Mirror across X"); + //mirror the transform across the X axis + transform.position = new Vector3(-transform.position.x, transform.position.y, transform.position.z); + //ensure rotation is mirrored properly too + transform.rotation = Quaternion.Euler(new Vector3(-transform.rotation.eulerAngles.x, 180 - transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z)); + } + if (GUILayout.Button("Y")) { + //undo state + Undo.RecordObject(transform, "Mirror across Y"); + //mirror the transform across the Y axis + transform.position = new Vector3(transform.position.x, -transform.position.y, transform.position.z); + transform.rotation = Quaternion.Euler(new Vector3(transform.rotation.eulerAngles.x, -transform.rotation.eulerAngles.y, -transform.rotation.eulerAngles.z)); + } + if (GUILayout.Button("Z")) { + //undo state + Undo.RecordObject(transform, "Mirror across Z"); + //mirror the transform across the Z axis + transform.position = new Vector3(transform.position.x, transform.position.y, -transform.position.z); + //ensure rotation is mirrored properly too + transform.rotation = Quaternion.Euler(new Vector3(-transform.rotation.eulerAngles.x, -transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z)); + } + GUILayout.EndHorizontal(); + GUILayout.EndVertical(); + + //add text to the inspector indicating who made these mods + EditorGUILayout.LabelField("Modified Transform Script by Happyrobot33", EditorStyles.wordWrappedLabel); + } +} \ No newline at end of file diff --git a/Packages/com.happyrobot33.inspectortweaks/Editor/TransformComponent.cs.meta b/Packages/com.happyrobot33.inspectortweaks/Editor/TransformComponent.cs.meta new file mode 100644 index 0000000..38acd16 --- /dev/null +++ b/Packages/com.happyrobot33.inspectortweaks/Editor/TransformComponent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c2d1d17041289bc40a31f0a6ebb74195 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.happyrobot33.inspectortweaks/package.json b/Packages/com.happyrobot33.inspectortweaks/package.json new file mode 100644 index 0000000..54482f5 --- /dev/null +++ b/Packages/com.happyrobot33.inspectortweaks/package.json @@ -0,0 +1,10 @@ +{ + "name": "com.happyrobot33.inspectortweaks", + "displayName": "Inspector Tweaks", + "version": "1.0.0", + "unity": "2019.4", + "description": "Collection of tweaks to various Unity inspectors to improve workflows", + "author": { + "name": "Happyrobot33" + } +} diff --git a/Packages/com.happyrobot33.inspectortweaks/package.json.meta b/Packages/com.happyrobot33.inspectortweaks/package.json.meta new file mode 100644 index 0000000..772c59b --- /dev/null +++ b/Packages/com.happyrobot33.inspectortweaks/package.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 13b3ec4e562c46340af08918e8370fe4 +PackageManifestImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.happyrobot33.placeholder/package.json b/Packages/com.happyrobot33.placeholder/package.json deleted file mode 100644 index 524045f..0000000 --- a/Packages/com.happyrobot33.placeholder/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "com.happyrobot33.placeholder", - "displayName": "Testing Package", - "version": "1.4.3", - "unity": "2019.4", - "description": "Testing package. Does nothing. Will likely be removed later", - "author": { - "name": "Happyrobot33" - } -} diff --git a/Packages/com.happyrobot33.shaderfinder/Editor.meta b/Packages/com.happyrobot33.shaderfinder/Editor.meta new file mode 100644 index 0000000..8949b6c --- /dev/null +++ b/Packages/com.happyrobot33.shaderfinder/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9eda9631d1ba7124493da23e98280cf1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.happyrobot33.shaderfinder/Editor/Shader Finder.asmdef b/Packages/com.happyrobot33.shaderfinder/Editor/Shader Finder.asmdef new file mode 100644 index 0000000..8b44299 --- /dev/null +++ b/Packages/com.happyrobot33.shaderfinder/Editor/Shader Finder.asmdef @@ -0,0 +1,3 @@ +{ + "name": "ShaderFinder" +} diff --git a/Packages/com.happyrobot33.shaderfinder/Editor/Shader Finder.asmdef.meta b/Packages/com.happyrobot33.shaderfinder/Editor/Shader Finder.asmdef.meta new file mode 100644 index 0000000..dc1a175 --- /dev/null +++ b/Packages/com.happyrobot33.shaderfinder/Editor/Shader Finder.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 22abd2948bf88df46a59023db7d5621a +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.happyrobot33.shaderfinder/Editor/Shader_Finder.cs b/Packages/com.happyrobot33.shaderfinder/Editor/Shader_Finder.cs new file mode 100644 index 0000000..72de9f2 --- /dev/null +++ b/Packages/com.happyrobot33.shaderfinder/Editor/Shader_Finder.cs @@ -0,0 +1,158 @@ +/* +Created by: Happyrobot33 +Date: 4/12/2022 +Version: 1.0 +*/ + +using UnityEngine; +using System; +using System.Collections; +using UnityEditor; +using UnityEngine.UI; + +public class Shader_Finder : EditorWindow +{ + //create a shader list + public static Shader[] shaderList = new Shader[0]; + public static string[] shaderNameList = new string[0]; + public int index = 0; + public GameObject ObjectToSearch; + public int objectCountFound = 0; + + [MenuItem("VRC Packages/Shader Finder")] + public static void ShowWindow() + { + //create a new window + EditorWindow window = EditorWindow.GetWindow(typeof(Shader_Finder)); + //set name of window + window.titleContent = new GUIContent("Shader Finder"); + window.Show(); + } + + private void OnGUI(){ + //create a new label + GUILayout.Label("Shader Finder", EditorStyles.boldLabel); + //create a description label + GUILayout.Label("This tool will find all the shaders in the scene, and select the relevant gameobjects. If you are using a shader that locks itself into a 'optimized' mode, then you will need to search for it under Hidden, IE for Poiyomi it will be under Hidden -> Locked", EditorStyles.wordWrappedLabel); + //create a new dropdown menu + index = EditorGUILayout.Popup(index, shaderNameList); + + //find every shader in the project and add it to the list + if (shaderList.Length == 0) + { + shaderList = Resources.FindObjectsOfTypeAll(); + shaderNameList = new string[shaderList.Length]; + for (int i = 0; i < shaderList.Length; i++) + { + shaderNameList[i] = shaderList[i].name; + } + } + + //add a field to input a gameobject from the scene + ObjectToSearch = EditorGUILayout.ObjectField("Object to search", ObjectToSearch, typeof(GameObject), true) as GameObject; + + if(shaderList.Length > 0 && ObjectToSearch != null) + { + //get every object in the scene + //GameObject[] objects = (GameObject[])FindObjectsOfTypeAll(typeof(GameObject)); + Transform[] objectsTRANSFORMS = ObjectToSearch.GetComponentsInChildren(true); + + //turn the objects array into an array of gameobjects, not transforms + GameObject[] objects = new GameObject[objectsTRANSFORMS.Length]; + for (int i = 0; i < objects.Length; i++) + { + objects[i] = objectsTRANSFORMS[i].gameObject; + } + + //list the ammount of objects with the selected shader + EditorGUILayout.LabelField("Total Objects to search: " + objects.Length); + EditorGUILayout.LabelField("Objects with the selected shader on last search: " + objectCountFound); + + //create a new button + if(GUILayout.Button("Select objects with specified Shader")){ + //clear selection + Selection.activeGameObject = null; + //get every object in the list with a renderer of some kind + foreach (GameObject obj in objects) + { + if (obj.GetComponent() != null) + { + //check if the object has multiple materials + if (obj.GetComponent().sharedMaterials.Length > 1) + { + //check if the object has the selected shader + for (int i = 0; i < obj.GetComponent().sharedMaterials.Length; i++) + { + //check to make sure the material isnt null + if (obj.GetComponent().sharedMaterials[i] != null) + { + //check if the material is the selected shader + if (obj.GetComponent().sharedMaterials[i].shader == shaderList[index]) + { + //select the object + Selection.objects = addToArray(Selection.objects, obj); + } + } + } + } + else + { + //check if the object has the selected shader + if (obj.GetComponent().sharedMaterial.shader == shaderList[index]) + { + //select the object + Selection.objects = addToArray(Selection.objects, obj); + } + } + } + else if (obj.GetComponent() != null) + { + //check if the object has multiple materials + if (obj.GetComponent().sharedMaterials.Length > 1) + { + //check if the object has the selected shader + for (int i = 0; i < obj.GetComponent().sharedMaterials.Length; i++) + { + //check to make sure the material isnt null + if (obj.GetComponent().sharedMaterials[i] != null) + { + if (obj.GetComponent().sharedMaterials[i].shader == shaderList[index]) + { + //select the object + Selection.objects = addToArray(Selection.objects, obj); + } + } + } + } + else + { + //check if the object has the selected shader + if (obj.GetComponent().sharedMaterial.shader == shaderList[index]) + { + //select the object + Selection.objects = addToArray(Selection.objects, obj); + } + } + } + } + } + } + + objectCountFound = Selection.objects.Length; + } + + private UnityEngine.Object[] addToArray(UnityEngine.Object[] array, GameObject obj) + { + //create a new array + UnityEngine.Object[] newArray = new UnityEngine.Object[array.Length + 1]; + //add the old array to the new array + for (int i = 0; i < array.Length; i++) + { + newArray[i] = array[i]; + } + //add the new object to the new array + newArray[array.Length] = obj; + //return the new array + return newArray; + } +} \ No newline at end of file diff --git a/Packages/com.happyrobot33.shaderfinder/Editor/Shader_Finder.cs.meta b/Packages/com.happyrobot33.shaderfinder/Editor/Shader_Finder.cs.meta new file mode 100644 index 0000000..48d8242 --- /dev/null +++ b/Packages/com.happyrobot33.shaderfinder/Editor/Shader_Finder.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5ff48ba192fabaa4b9c88c7f7f362cd6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.happyrobot33.shaderfinder/package.json b/Packages/com.happyrobot33.shaderfinder/package.json new file mode 100644 index 0000000..82c499c --- /dev/null +++ b/Packages/com.happyrobot33.shaderfinder/package.json @@ -0,0 +1,10 @@ +{ + "name": "com.happyrobot33.shaderfinder", + "displayName": "Shader Finder", + "version": "1.0.0", + "unity": "2019.4", + "description": "A tool to find shaders in your project, so you can figure out why the VRC SDK wont let you upload your quest avatar", + "author": { + "name": "Happyrobot33" + } +} diff --git a/Packages/com.happyrobot33.shaderfinder/package.json.meta b/Packages/com.happyrobot33.shaderfinder/package.json.meta new file mode 100644 index 0000000..bd4dda7 --- /dev/null +++ b/Packages/com.happyrobot33.shaderfinder/package.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4f2099337506f3d4caf632fca7530350 +PackageManifestImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 6e8b3f5..794840b 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -1,11 +1,29 @@ { "dependencies": { + "com.happyrobot33.editorgames": { + "version": "file:com.happyrobot33.editorgames", + "depth": 0, + "source": "embedded", + "dependencies": {} + }, + "com.happyrobot33.inspectortweaks": { + "version": "file:com.happyrobot33.inspectortweaks", + "depth": 0, + "source": "embedded", + "dependencies": {} + }, "com.happyrobot33.packagewindowconsolidator": { "version": "file:com.happyrobot33.packagewindowconsolidator", "depth": 0, "source": "embedded", "dependencies": {} }, + "com.happyrobot33.shaderfinder": { + "version": "file:com.happyrobot33.shaderfinder", + "depth": 0, + "source": "embedded", + "dependencies": {} + }, "com.unity.burst": { "version": "1.4.11", "depth": 1, @@ -168,12 +186,6 @@ "com.unity.textmeshpro": "2.1.6" } }, - "test.example.package": { - "version": "file:test.example.package", - "depth": 0, - "source": "embedded", - "dependencies": {} - }, "com.unity.modules.ai": { "version": "1.0.0", "depth": 0,