Skip to content

Instantly share code, notes, and snippets.

View zhaoguohao's full-sized avatar
🚩
🐬

zhaoguohao

🚩
🐬
  • SkyStar Studio
  • YeShan Planet Earth
View GitHub Profile
@zhaoguohao
zhaoguohao / CustomThumbnail.cs
Created March 7, 2025 10:25 — forked from unitycoder/CustomThumbnail.cs
Save Thumbnails for Scenes (unity editor script)
using System.IO;
using UnityEditor;
using UnityEngine;
namespace UnityLibrary
{
[CustomEditor(typeof(SceneAsset))]
public class CustomThumbnail : Editor
{
public override bool HasPreviewGUI() => true;
@zhaoguohao
zhaoguohao / CameraFollow.cs
Created September 5, 2024 13:37 — forked from yasirkula/CameraFollow.cs
A camera follow script with numerous parameters for Unity
using UnityEngine;
[ExecuteInEditMode]
public class CameraFollow : MonoBehaviour
{
[Tooltip( "Object to follow" )]
public Transform Target;
[Tooltip( "Target distance to the followed object" )]
public Vector3 DistanceToTarget = new Vector3( 0f, 3f, -5f );
@zhaoguohao
zhaoguohao / HierarchyFolderObject.cs
Created September 5, 2024 13:35 — forked from yasirkula/HierarchyFolderObject.cs
Create folder objects in Hierarchy that automatically detach all their children while building the game (for Unity3D)
#define ENABLE_LOGGING // Logs the folder objects that were flattened to the console
//#define SIMULATE_BUILD_BEHAVIOUR_ON_PLAY_MODE // Simulates Execution.AtBuildTime when entering Play Mode in the Editor, as well
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEngine.SceneManagement;
using System.Collections.Generic;
using System.Reflection;
#endif
@zhaoguohao
zhaoguohao / DirectoryComparer.cs
Created September 5, 2024 13:35 — forked from yasirkula/DirectoryComparer.cs
Compare the contents of two directories and apply any changes to the target directory to synchronize these two directories
#define COMPARE_FILE_CONTENTS
#if COMPARE_FILE_CONTENTS
#define USE_THREADS
#endif
using System;
using System.Collections.Generic;
using System.IO;
#if USE_THREADS
using System.Threading;
@zhaoguohao
zhaoguohao / ScrollViewFocusFunctions.cs
Created September 5, 2024 13:32 — forked from yasirkula/ScrollViewFocusFunctions.cs
Focus/center Scroll View to the specified point/item in Unity
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public static class ScrollViewFocusFunctions
{
public static Vector2 CalculateFocusedScrollPosition( this ScrollRect scrollView, Vector2 focusPoint )
{
Vector2 contentSize = scrollView.content.rect.size;
Vector2 viewportSize = ( (RectTransform) scrollView.content.parent ).rect.size;
@zhaoguohao
zhaoguohao / BatchExtractMaterials.cs
Created September 5, 2024 13:27 — forked from DevJamesC/BatchExtractMaterials.cs
Batch extract materials from 3D model assets in Unity
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.IO;
using System;
using System.Reflection;
public class BatchExtractMaterials : EditorWindow
{
private enum ExtractMode { Extract = 0, Remap = 1, Ignore = 2 };
@zhaoguohao
zhaoguohao / BatchExtractMaterials.cs
Created September 5, 2024 13:26 — forked from yasirkula/BatchExtractMaterials.cs
Batch extract materials from 3D model assets in Unity
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.IO;
public class BatchExtractMaterials : EditorWindow
{
private enum ExtractMode { Extract = 0, Remap = 1, Ignore = 2 };
[System.Serializable]
@zhaoguohao
zhaoguohao / CustomRectHandles.cs
Created September 5, 2024 13:26 — forked from yasirkula/CustomRectHandles.cs
Drawing Rect handles in Unity (similar to built-in Rect tool)
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
public class CustomRectHandles : ScriptableObject
{
public class Rect3D
{
@zhaoguohao
zhaoguohao / BoxColliderWizard.cs
Created September 5, 2024 13:25 — forked from yasirkula/BoxColliderWizard.cs
Creating & editing BoxColliders intuitively in Unity
#if UNITY_EDITOR
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine.Rendering;
#endif
using UnityEngine;
public class BoxColliderWizard : MonoBehaviour
@zhaoguohao
zhaoguohao / WavyImage.cs
Created September 5, 2024 13:18 — forked from yasirkula/WavyImage.cs
Create UI image with wave animation in Unity
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Sprites;
using UnityEngine.UI;
#if UNITY_2017_4 || UNITY_2018_2_OR_NEWER
using UnityEngine.U2D;
#endif
#if UNITY_EDITOR
using UnityEditor;