Skip to content

Instantly share code, notes, and snippets.

View mzandvliet's full-sized avatar

Mar Zandvliet mzandvliet

View GitHub Profile
var Child = React.createClass({
render: function() {
if(this.props.isHighlighted) {
return <h1>{this.props.name}</h1>;
} else {
return <span>{this.props.name}</span>;
}
}
});
@mzandvliet
mzandvliet / broken_value_type_wrapping.cs
Last active August 29, 2015 14:26
Broken Value Type Wrapping
// This is broken in Unity 5.x's built-in version of Mono, which is admittedly rather old.
// Compiling with VS2013 it works as intended.
public struct WrapperType<T> {
public float Timestamp;
public T Value;
}
public struct MyValueType {
public float floatA;
private void OnClientAddPlayer(NetworkMessage netmsg) {
var msg = netmsg.ReadMessage<AddPlayerMessage>();
Debug.Log("Spawning object for player: " + msg.playerControllerId);
/* First, create instance and spawn it */
var instance = (GameObject)Instantiate(_playerPrefab, Vector3.zero, Quaternion.identity);
NetworkServer.AddPlayerForConnection(netmsg.conn, instance, msg.playerControllerId);
/* Then add role-specific components and resolve dependencies, if prefab needs it */
@mzandvliet
mzandvliet / HapticTest.cs
Created January 3, 2018 17:12
OVR Haptics Example
using UnityEngine;
/*
* Haptics internal update (Process()) is triggered by OVRManager, which
* you need to have in your scene.
*/
public class HapticTest : MonoBehaviour {
private OVRHapticsClip _clip;
Files and paths mentioned:
Assets/Videos/01/1.mp4
Assets/Videos/ending/ending2.mp4
also mentioned:
new-video-scene7
new-videos-scene0
new-videos-scene1-7-8
november-fixes
- alley_walkway_4x4 (5): 36 texels
- border_76: 36 texels
- border_25: 36 texels
- border_70: 36 texels
- border_31: 36 texels
- border_22: 36 texels
- alley_walkway_4x4 (14): 36 texels
- border_72: 36 texels
- border_55: 36 texels
-------------------------------------------------------------------------------
Build Report
Uncompressed usage by category:
Textures 2165.0 mb 19.4%
Meshes 7832.8 mb 70.2%
Animations 1.1 mb 0.0%
Sounds 148.2 mb 1.3%
Shaders 58.7 mb 0.5%
Other Assets 676.7 mb 6.1%
Levels 218.6 mb 2.0%
/*
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.0/pattern-matching
Cool proposal. Here I do a quick rewrite using the Unity ~C#6 syntax:
*/
namespace Algebra {
public abstract class Expr { }
@mzandvliet
mzandvliet / DspApplication.cs
Last active July 23, 2022 00:13
A quick example of how to play a mouse-controlled sine wave using the DSPGraph preview package
using UnityEngine;
using Unity.Collections;
using Unity.Audio;
using Unity.Mathematics;
using Unity.Burst;
using System.Collections;
/*
For allocations inside AudioKernels, use Allocator.AudioKernel
*/
@mzandvliet
mzandvliet / NativeCollectionUtilities.cs
Created October 26, 2019 10:53
Some utilities for copying data between native and managed containers as quickly as possible
using Unity.Collections;
using Unity.Mathematics;
using UnityEngine;
using Unity.Collections.LowLevel.Unsafe;
/*
Utility for memcopying data from native to managed containers and vice versa.
Todo: Is it possible to generic memcopy implementations, where Source, Dest : struct?
If not, you know what to do: *** code generation ***