Skip to content

Instantly share code, notes, and snippets.

View Denchyaknow's full-sized avatar

Dencho Taylor Denchyaknow

View GitHub Profile
@Denchyaknow
Denchyaknow / 💻 My Code::Stats XP (Top Languages)
Last active March 6, 2024 15:02
💻 My Code::Stats XP (Top Languages)
Total XP :::::::::::::::::::::: lvl 53 (4,497,475 XP)
C# :::::::::::::::::::::::::::: lvl 52 (4,417,075 XP)
Documentation ::::::::::::::::: lvl 5 ( 40,987 XP)
JavaScript :::::::::::::::::::: lvl 2 ( 12,477 XP)
CSS ::::::::::::::::::::::::::: lvl 2 ( 6,870 XP)
Arduino ::::::::::::::::::::::: lvl 1 ( 6,354 XP)
Web ::::::::::::::::::::::::::: lvl 1 ( 4,762 XP)
JSON :::::::::::::::::::::::::: lvl 1 ( 4,700 XP)
JavaScript (JSX) :::::::::::::: lvl 0 ( 1,582 XP)
Backend ::::::::::::::::::::::: lvl 0 ( 1,058 XP)
@Denchyaknow
Denchyaknow / HowTo_CoolEnumPopup_MarkdownFilesInDir.cs
Created January 5, 2024 18:11
A HowTo on making a nice little popup selector for a list of markdown files in a given directory
private void DrawMainPageSelector()
{
bool isMainPageSet = !string.IsNullOrEmpty(setMainPage);
var mainPageTitle = !isMainPageSet ? "NONE" : Path.GetFileName(setMainPage.ToUpper());
//Display a Popup selector with default of non if exisitng value is not in the list
using (var mainPageScope = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
{
GUILayout.Label(string.Format("Main Page Setting\nCurrent: {0}", isMainPageSet?setMainPage.ToUpper():"NONE"), EditorStyles.centeredGreyMiniLabel);
using (var selectionScope = new EditorGUILayout.HorizontalScope(EditorStyles.toolbar))
@Denchyaknow
Denchyaknow / Ext.cs
Last active December 5, 2023 17:42
Magical_Extensions
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//Made by Dencho, Just some useful extensions for Unity types, wrote them over the years for my own use, enjoi thx!
namespace Yakno
{
#region Debugging
public static class DebugExt
@Denchyaknow
Denchyaknow / HowTo_Deselect_GUILayout_Inputs
Created August 21, 2023 07:41
A HowTo on forcing a Custom Inspector to Deselect the current input
if (GUILayout.Button("Your Button"))
{
GUI.FocusControl(null);
}
_data.ItemValue = EditorGUILayout.IntField("VALUE", (int)_data.ItemValue, textAreaStyle);
@Denchyaknow
Denchyaknow / HowTo_Json_FormatAsCustomDataType
Created July 18, 2023 10:08
A HowTo on Converting incomming Json data as a Custom Datatype
//Say you have incommingJson like this:
{
"name": "Bob",
"url": "https://example.com/bob.png"
}
//And you have a DataClass like this you use for you Avatar Loading or Refferences
[System.Serializable]
@Denchyaknow
Denchyaknow / API_Unity_Paths
Created June 3, 2023 10:05
Examples of the different types of paths in Unity and their outputs
Examples of the different types of paths in Unity and their outputs:
Application.dataPath: //This property returns the path to the Assets folder of the project. In the editor, it returns the path to the Assets folder. In a build, it returns the path to the data folder of the build.
// Usage
Debug.Log(string.Format("Assets path: {0}", Application.dataPath));
// Example output in the editor: "Assets path: C:/MyProject/Assets"
// Example output in a Windows build: "Assets path: C:/MyGame/MyGame_Data"
Application.persistentDataPath: //This property returns the path to a persistent data directory. This directory is where you can store data that needs to persist between game sessions. The exact location of this directory depends on the platform.
@Denchyaknow
Denchyaknow / HowTo_CustomInspector_Prefabbing
Created March 27, 2023 08:57
HowTo_CustomInspector_Prefabbing
//Creating a Prefab from Custom Inspector To create a Prefab from a custom inspector, you can use the PrefabUtility.CreatePrefab method. Here's an example of how you can use this method:
using UnityEditor;
using UnityEngine;
public class MyCustomEditor : EditorWindow
{
[MenuItem("MyTools/CreatePrefab")]
static void CreatePrefab()
{
@Denchyaknow
Denchyaknow / UnityEditorIcons.cs
Last active May 9, 2023 15:17 — forked from MattRix/UnityEditorIcons.txt
A list of all the built-in EdtiorGUI icons in Unity. Use EditorGUIUtility.IconContent([icon name]) to access them.
//How to USe:
private Texture2D icon_PlayButton = null;
private Texture2D icon_Refresh = null;
private GUIContent iconGUI_PlayButton;
private GUIContent iconGUI_Refresh;
private void InitStyles()
{
icon_PlayButton = EditorGUIUtility.IconContent("PlayButton").image as Texture2D;
@Denchyaknow
Denchyaknow / HowTo_RotateAlongNormal.cs
Last active May 31, 2023 14:23
HowTo_RotateAlongNormal is a small example on how to rotate an object along a surfaces normal
private void ProcessRotationSnappingSubroutine(Vector3 surfaceNormal, float rotationAngleInDegrees)
{
// Set the up direction of the object's transform to the surface normal
transform.up = surfaceNormal;
// Calculate the rotation axis as the object's up direction
Vector3 rotateAxis = transform.up;
// Calculate the rotation angle in radians
float rotationAngleInRadians = Mathf.Deg2Rad * rotationAngleInDegrees;
@Denchyaknow
Denchyaknow / HowTo_ISerializationCallbackReceiver.cs
Created February 8, 2023 00:30
ISerializationCallbackReceiver can help control how data is Serialized and Deserialized between app restarts. Here is some notes on using it.
//Make all reffs are already serialized that are to be used when OnAfterDeserialize() is called.
public bool IsReady { get => isInitialized && Cells.Count > 0; }
public Config_CellData Storage { get => cellDataStorage; }
public bool IsInitialized { get => isInitialized; private set => isInitialized = value; }
[SerializeField]
private bool isInitialized = false;
[SerializeField]
private Config_CellData cellDataStorage = null;