Skip to content

Instantly share code, notes, and snippets.

View tk009999's full-sized avatar
🇹🇼

AceLee tk009999

🇹🇼
View GitHub Profile
@tk009999
tk009999 / SaveRenderTextureToFile.cs
Created January 11, 2023 15:30 — forked from krzys-h/SaveRenderTextureToFile.cs
[Unity] Save RenderTexture to image file
using UnityEngine;
using UnityEditor;
public class SaveRenderTextureToFile {
[MenuItem("Assets/Save RenderTexture to file")]
public static void SaveRTToFile()
{
RenderTexture rt = Selection.activeObject as RenderTexture;
RenderTexture.active = rt;
@tk009999
tk009999 / ShowFPS.cs
Created November 25, 2021 06:20 — forked from freemanlam/ShowFPS.cs
Show FPS in Unity
using UnityEngine;
using System.Collections;
public class ShowFPS : MonoBehaviour
{
const float fpsMeasurePeriod = 0.5f;
private int m_FpsAccumulator = 0;
private float m_FpsNextPeriod = 0;
private int m_CurrentFps;
@tk009999
tk009999 / SimpleGravitational.cs
Created June 20, 2021 07:28
Simulate Gravitational of Planet
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SimpleGravitational : MonoBehaviour
{
public float planetMass;
public float asteroidMass;
@tk009999
tk009999 / DebugNode.hlsl
Created June 10, 2021 08:49 — forked from aras-p/DebugNode.hlsl
"Print a value" custom function node code for Unity ShaderGraph
// Quick try at doing a "print value" node for Unity ShaderGraph.
// Tested on Unity 2019.2.17 with ShaderGraph 6.9.2.
//
// Use with CustomFunction node, with two inputs:
// - Vector1 Value, the value to display,
// - Vector2 UV, the UVs of area to display at.
// And one output:
// - Vector4 Color, the color.
// Function name is DoDebug.
@tk009999
tk009999 / VirtualJoystick.cs
Created June 1, 2021 02:36 — forked from Vonflaken/VirtualJoystick.cs
Virtual joystick component for Unity mobile projects.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
#if UNITY_EDITOR && !UNITY_CLOUD_BUILD
using UnityEditor;
#endif
@tk009999
tk009999 / MathParabola.cs
Created May 20, 2021 19:51 — forked from ditzel/MathParabola.cs
A simple Math class to calculate a point in 2D or 3D space lying on a parabola. And a more complex parabola controller that you can put on an object.
using UnityEngine;
using System;
public class MathParabola
{
public static Vector3 Parabola(Vector3 start, Vector3 end, float height, float t)
{
Func<float, float> f = x => -4 * height * x * x + 4 * height * x;
@tk009999
tk009999 / Timer.cs
Created May 16, 2021 08:48 — forked from valryon/Timer.cs
Unity simple Timer with co-routine
// 2014 - Pixelnest Studio
using System;
using System.Collections;
using UnityEngine;
/// <summary>
/// Ready to use timers for coroutines
/// </summary>
/// <summary>
/// Ready to use timers for coroutines
namespace UnityEngine.Audio
{
public static class AudioExtensions
{
/// <summary>
///
/// </summary>
/// <param name="mixer"></param>
/// <param name="exposedName">The name of 'The Exposed to Script' variable</param>
/// <param name="value">value must be between 0 and 1</param>
using UnityEngine;
public static class RendererExtensions
{
public static bool IsVisibleFrom(this Renderer renderer, Camera camera)
{
Plane[] planes = GeometryUtility.CalculateFrustumPlanes(camera);
return GeometryUtility.TestPlanesAABB(planes, renderer.bounds);
}
}
@tk009999
tk009999 / MeshDestroy.cs
Created January 25, 2021 02:37 — forked from ditzel/MeshDestroy.cs
MeshDestroy => Put it on a game object with a mesh filter and renderer. Make sure to have read/write enabled on fbx import
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MeshDestroy : MonoBehaviour
{
private bool edgeSet = false;
private Vector3 edgeVertex = Vector3.zero;
private Vector2 edgeUV = Vector2.zero;