Skip to content

Instantly share code, notes, and snippets.

View Grave18's full-sized avatar

Grave Grave18

  • Kyrgystan
  • 21:31 (UTC +05:00)
View GitHub Profile
@attilam
attilam / RevealPersistentDataDirectory.cs
Created December 6, 2012 17:20
Reveal Persistent Data Directory for current project in Unity
using UnityEngine;
using UnityEditor;
using System.Diagnostics;
public class RevealPersistentDataDirectory : MonoBehaviour {
[MenuItem("Assets/Reveal Persistent Data Directory")]
static void DoMenu() {
Process process = new Process();
process.StartInfo.FileName = ( (Application.platform == RuntimePlatform.WindowsEditor) ? "explorer.exe" : "open" );
process.StartInfo.Arguments = "file://"+Application.persistentDataPath;
@ftvs
ftvs / CameraShake.cs
Last active May 17, 2024 12:21
Simple camera shake effect for Unity3d, written in C#. Attach to your camera GameObject. To shake the camera, set shakeDuration to the number of seconds it should shake for. It will start shaking if it is enabled.
using UnityEngine;
using System.Collections;
public class CameraShake : MonoBehaviour
{
// Transform of the camera to shake. Grabs the gameObject's transform
// if null.
public Transform camTransform;
// How long the object should shake for.
@djcsdy
djcsdy / Unity with source control.md
Last active July 9, 2024 10:40
Unity with source control

In the Unity editor:

  1. Edit -> Project Settings -> Editor
  2. In the inspector panel, set:
  3. Version Control -> Mode: Visible Meta Files
  4. Asset Serialization -> Mode: Force Text

“Visible Meta Files” causes Unity to place .meta files next to each of your assets. It’s important to check these files into version control because they contain the settings associated with those assets that you set in the Unity editor.

“Asset Serialization: Force Text” causes Unity to write its .meta and other files in a more-or-less human-readable text format, which makes it a lot easier to understand what has changed when you look at version control logs. Also it’s feasible to merge these text files by hand, whereas it’s not really possible to do that with Unity’s default binary file format.

@johnsoncodehk
johnsoncodehk / ClampAngle.cs
Last active April 12, 2024 16:31
Unity Clamp Angle
public static float ClampAngle(float angle, float min, float max) {
float start = (min + max) * 0.5f - 180;
float floor = Mathf.FloorToInt((angle - start) / 360) * 360;
return Mathf.Clamp(angle, min + floor, max + floor);
}
@sebtoun
sebtoun / JsonSerialisableScriptableObject.cs
Last active February 27, 2024 17:25
Unity's ScriptableObjects that easily serialize to JSON
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using UnityEngine;
public class JsonSerialisableScriptableObject<T> : ScriptableObject where T : JsonSerialisableScriptableObject<T>
{
@mkanenobu
mkanenobu / pbcopy
Created January 30, 2019 05:10
pbcopy for Cygwin, MSYS2
### append to .bashrc
alias pbcopy="iconv -f UTF-8 -t CP932 | /c/Windows/System32/clip.exe"
@quabug
quabug / Example.cs
Created April 14, 2019 09:23
Create Unity ECS systems by zenject way which automaticly inject necessary instances into constructor of system.
class MainInstaller : MonoInstaller<MainInstaller>
{
public override void InstallBindings() {
Container.BindInstance(World.Active);
Container.Bind<WorldSystemCreatorFactory>().AsSingle().WithArguments(Container);
Container.Bind<SomeService>().ToSelf().AsSingle();
Container.Bind<Example>().ToSelf().AsSingle().NonLazy();
}
}
@KarlRamstedt
KarlRamstedt / FirstPersonCameraRotation.cs
Created January 8, 2020 10:17
A simple First Person Camera rotation script for Unity.
using UnityEngine;
/// <summary>
/// A simple FPP (First Person Perspective) camera rotation script.
/// Like those found in most FPS (First Person Shooter) games.
/// </summary>
public class FirstPersonCameraRotation : MonoBehaviour {
public float Sensitivity {
get { return sensitivity; }
@shanecelis
shanecelis / NativeArrayOfArrays.cs
Last active May 19, 2024 14:17
Make one long linear NativeArray look like a two-dimensional jagged array.
/* Original code[1] Copyright (c) 2022 Shane Celis[2]
Licensed under the MIT License[3]
[1]: https://gist.github.com/shanecelis/f0e295b12ec1ab09f67ad5980ac9b324
[2]: https://twitter.com/shanecelis
[3]: https://opensource.org/licenses/MIT
*/
using System;
using System.Collections.Generic;
Netcode package:
com.unity.netcode.gameobjects
Mutiplayer helpers (ClientNetworkTransform):
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop.git?path=/Packages/com.unity.multiplayer.samples.coop#main
ParrelSync:
https://github.com/VeriorPies/ParrelSync.git?path=/ParrelSync