Skip to content

Instantly share code, notes, and snippets.

@carefish
carefish / Backend_ConcreteDatabaseObject.cs
Last active May 5, 2021 22:41
using an interface contract to have concrete classes in their appropriate projects (front- and back-end)
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
// .. snip removed a bunch of project (front end specific) usings
using Assets.Scripts.Utilities.Dbo; // to eensure interfaces are known
namespace Assets.Scripts.Utilities
[System.Serializable]
public class ButtonDetailIDProperty
{
public ButtonDetailID buttonID;
}
connection.On("broadcastMessage", (data) =>
{
//do stuff with 'data' from web rpc call
});
//--
connection.InvokeAsync("Send", newData);
[MessagePackObject]
public class AudioData
{
[Key(0)]
public byte[] data { get; set; }
[Key(1)]
public int length { get; set; }
[Key(2)]
public int count { get; set; }
}
if (decoder != null)
{
var pcmLength = decoder.Decode(encodedData, 0, length, pcmBuffer, 0, pcmBuffer.Length);
if (audioClipData == null || audioClipData.Length != pcmLength)
{//make sure that audioclip data length is the same w/ each received packet
audioClipData = new float[pcmLength];
}
Array.Copy(pcmBuffer, audioClipData, pcmLength);
source.clip.SetData(audioClipData, samplePos);
samplePos += pcmLength;
if(receivedSamples.Count != 0)
{
var recv = receivedSamples.Pop();
frameSize = OpusPacketInfo.GetNumSamples(decoder, recv, 0, recv.Length);
float[] recvOutput = new float[frameSize];
int thisFrameSize = decoder.Decode(recv, 0, recv.Length, recvOutput, 0, frameSize);
decodedSamples.Push(recvOutput);
if(decodedSamples.Count >= 100)
{
for(int i = 0; i < decodedSamples.Count; i++)
using CockpitTraining;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
public class YourObject
{
public YourObject() {}//do whatever here
public /*virtual*/ void OnUpdate(float deltaTime) {}
}
public class UnityHook : MonoBehaviour
{
public int TotalObjects;
List<YourObject> objects;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;
[ExecuteInEditMode]
public class SubdivideBoundingBoxIntoSmallerBoxes : MonoBehaviour
{
public Color boundingBoxColor;