Skip to content

Instantly share code, notes, and snippets.

View mdotstrange's full-sized avatar
💭
Remote procedure call

Imagination Rabbit mdotstrange

💭
Remote procedure call
View GitHub Profile
@mdotstrange
mdotstrange / get random enum
Created February 22, 2022 05:08
Get random enum
cardSuit = (CardSuit)Random.Range(0, 3);
//cardsuit is enum 0,3 is length
@mdotstrange
mdotstrange / Thread safe code in Unity
Last active February 18, 2022 10:27
Thread Safe code in Unity
using System.Collections.Concurrent;
//
public static readonly ConcurrentQueue<Action> RunOnMainThread = new ConcurrentQueue<Action>();
// to run it
private void Update()
{
if (!RunOnMainThread.IsEmpty)
{
while (RunOnMainThread.TryDequeue(out var action))
@mdotstrange
mdotstrange / GiantAudioClip.cs
Last active February 18, 2022 10:28
Giant Audio Clip- combine audio clips
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Sirenix.OdinInspector;
// I used this script to get around Unitys lack of support for long audio clips ~2 hours for feature films
//Break the clip up into several pieces- make sure there are no gaps between clips!
// Use this wherever you need to play audio on the long clips
//If you don't use Odin delete "[Button]" refs and "using Sirenix.OdinInspector;"
public class GiantAudioClip : MonoBehaviour
@mdotstrange
mdotstrange / lookAtCursorWorld.cs
Last active February 18, 2022 10:28
Look at world cursor
//in Update
Vector3 basePoint = (head.position);
Plane newPlane = new Plane(Vector3.forward, (basePoint));
Vector3 point1 = basePoint ;
Vector3 point2 = basePoint + ((Vector3.up + -transform.right )* 2f);
Vector3 point3 = basePoint + ((Vector3.down + transform.right) * 2f);
newPlane.Set3Points(point1, point2, point3);
float dist = Vector3.Distance(head.position, Camera.transform.position);
var v3 = Input.mousePosition;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using SGoap;
using System.Linq;
using Sirenix.OdinInspector;
using UnityEngine.UI;
public class GetPlan : MonoBehaviour
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StopFrameAnimator : MonoBehaviour
{
public Animator Animator;
public int StopFrameInterval;
int liveFrameInterval;
bool isNormalSpeed;
//call these to open the load image window
SetFilters();
StartCoroutine(ShowLoadDialogCoroutine());
IEnumerator ShowLoadDialogCoroutine()
{
// Show a load file dialog and wait for a response from user
// Load file/folder: file, Initial path: default (Documents), Title: "Load File", submit button text: "Load"
yield return FileBrowser.WaitForLoadDialog(false, null, "Load File", "Load");
// Dialog is closed
// Print whether a file is chosen (FileBrowser.Success)
// and the path to the selected file (FileBrowser.Result) (null, if FileBrowser.Success is false)
// Debug.Log(FileBrowser.Success + " " + FileBrowser.Result);
void SetFilters()
{
FileBrowser.SetFilters(true, new FileBrowser.Filter("ImageFiles", ".png", ".jpg"), new FileBrowser.Filter("Image files", ".png", ".jpg"));
FileBrowser.SetDefaultFilter(".png");
FileBrowser.SetExcludedExtensions(".lnk", ".tmp", ".zip", ".rar", ".exe");
//if mac or linux just use bool check here and change directory?
FileBrowser.AddQuickLink("Users", System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop), null);
if (FileBrowser.IsOpen)
if (StopFrameIsActive)
{
liveFrameInterval++;
if (liveFrameInterval >= StopFrameInterval)
{
liveFrameInterval = 0;
if (isNormalSpeed)
{