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 / CanvasMesh.cs
Created January 20, 2022 06:06 — forked from YclepticStudios/CanvasMesh.cs
Unity script for rendering a mesh inside the canvas UI.
/**
* ============================================================================
* MIT License
*
* Copyright (c) 2017 Eric Phillips
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
using UnityEngine;
using UnityEngine.UI;
// For a discussion of the code, see: https://www.hallgrimgames.com/blog/2018/11/25/custom-unity-ui-meshes
public class MyUiElement : MaskableGraphic
{
public float GridCellSize = 40f;
[SerializeField]
@zhaoguohao
zhaoguohao / CursorManager.cs
Created January 20, 2022 08:39 — forked from SixWays/CursorManager.cs
Nicer cursor hiding/locking for Unity, including automatic alt-tab handling. Tested on 5.4+, probably fine 5.0+.
using UnityEngine;
using System.Collections;
public class CursorManager : MonoBehaviour {
#region Static
#region Singleton
/* Class is a MonoBehaviour to recieve OnApplicationFocus(bool) message
* If no instance already present, one will be created BEFORE scene load
* CursorManager placed in scene will override auto-created instance
* Any created instance will call DontDestroyOnLoad on itself, but still gets overridden by scene
@zhaoguohao
zhaoguohao / QuadTreeTest.cs
Created February 15, 2022 07:25 — forked from MohHeader/QuadTreeTest.cs
Quadtree in Unity
using UnityEngine;
using System.Collections;
public class QuadTreeTest : MonoBehaviour {
public class TestObject : IQuadTreeObject{
private Vector3 m_vPosition;
public TestObject(Vector3 position){
m_vPosition = position;
}
public Vector2 GetPosition(){
@zhaoguohao
zhaoguohao / DecoratorEditor.cs
Created February 21, 2022 07:49 — forked from liortal53/DecoratorEditor.cs
Extend Unity's built-in inspectors
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
/// <summary>
/// A base class for creating editors that decorate Unity's built-in editor types.
/// </summary>
public abstract class DecoratorEditor : Editor
@zhaoguohao
zhaoguohao / DisableOnPlatforms.cs
Created March 24, 2022 17:58 — forked from emadkhezri/DisableOnPlatforms.cs
This component disables game object on specific platforms
/// <summary>
/// Put this component on game objects that you wish to disable on specific platforms
/// </summary>
public class DisableOnPlatforms : MonoBehaviour {
[SerializeField]
[Tooltip("Selected Platforms to disable game object")]
private RuntimePlatform[] _platforms;
private void OnEnable() {
if (_platforms.Contains(Application.platform)) {
using System;
using UnityEngine;
public static class ApplicationState
{
/// <summary>
/// Is editor either currently in play mode, or about to switch to it?
/// </summary>
public static bool isPlayingOrWillChangePlaymode { get { return Application.isEditor ? InternalEditorState.isPlayingOrWillChangePlaymode : true; } }
/// <summary>
@zhaoguohao
zhaoguohao / git_and_unity.md
Created August 10, 2022 12:30 — forked from Ikalou/git_and_unity.md
Git and Unity

EDIT: this is an old post and a lof the information in this document is outdated.

Using Git with Unity

Git logo

Git is a popular free and open source distributed version control system.

I am new to Unity, but as a long time git user, I wanted to use git for my

@zhaoguohao
zhaoguohao / AsyncBundleLoader.cs
Created August 10, 2022 13:22 — forked from ryanc-unity/AsyncBundleLoader.cs
Dummy object generator for project testing
using System.Collections;
using System.IO;
using UnityEngine;
public class AsyncBundleLoader : MonoBehaviour
{
// Used for visual debugging as to not generate unnecessary allocations
public GameObject worldLight;
// Private fields to keep track of loaded objects