Skip to content

Instantly share code, notes, and snippets.

@vrobel
vrobel / AddCleanupForRealtimeView.cs
Last active December 14, 2021 22:14
Add context menu to RealtimeView component of Normcore. It allows to clean up Deprecated View references. Deprecated View references can cause issues with Unity's bug in serialization OnAfterDeserialize causing InvalidOperationException: EnsureRunningOnMainThread.
using Normal.Realtime;
using UnityEditor;
using UnityEngine;
namespace Normcore.Editor
{
public static class AddCleanupForRealtimeView
{
[MenuItem("CONTEXT/RealtimeView/Cleanup child views")]
static void RealtimeViewCleanupChildViews(MenuCommand command)
@vrobel
vrobel / CoexistiveSceneManager.cs
Last active August 29, 2015 14:03
Multiple SceneManagers in one Scene
using System.Collections.Generic;
using UnityEngine;
//All SceneManagers that I want to keep in one scene needs te extend this class.
//I had to fix it in designer generated code which is poor, or it can be copy pasted to each Scene class.
//Add all root GameObjects for each scene so they will get enabled when scene is activated
public class CoexistiveSceneManager : SceneManager
{
public List<GameObject> SceneRoots;
@vrobel
vrobel / gist:5868022
Created June 26, 2013 14:53
How to check if a coroutine has finished its execution in the first frame or yield break was called
var coroutineEnumerator = StartCoroutine();
var coroutine = StartCoroutine(coroutineEnumerator);
if(coroutineEnumerator.Current != null)
yield return coroutine;
else
//we are here in the same frame if the coroutine ended
@vrobel
vrobel / hosts
Last active December 16, 2015 07:19
facebook killer in hosts file
#add lines below to the hosts file
0.0.0.0 facebook.com
0.0.0.0 www.facebook.com
0.0.0.0 https://facebook.com
0.0.0.0 https://www.facebook.com
@vrobel
vrobel / KinematicCollisionDetectionBug.as
Last active December 15, 2015 21:29
Replicates bug in NAPE when 2 kinematic/static bodies collide with each other and only one begin contact listener is dispatched
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Rectangle;
import nape.util.ShapeDebug;
public class KinematicCollisionDetectionBug extends Sprite
{
@vrobel
vrobel / ActionList.as
Last active December 12, 2015 01:28
ActionList based on Ash EntityStateMachine
package com.blackmoondev.ashes.fsm
{
import ash.fsm.EntityStateMachine;
public class ActionList implements IActionList
{
public function ActionList( fsm : EntityStateMachine, states : Vector.<String> ) {
this.fsm = fsm;
this.states = states || new Vector.<String>();
}
@vrobel
vrobel / SQuadBatchTest.as
Created January 30, 2013 16:36
Starling QuadBatch test
/**
* Created with IntelliJ IDEA.
* User: wrobel221
* Date: 10.10.12
* Time: 00:13
* To change this template use File | Settings | File Templates.
*/
package com.blackmoondev.panda.boot.test
{
import com.blackmoondev.ashes.debug.DebugFunctionCaller;
@vrobel
vrobel / example.as
Last active December 10, 2015 14:08
Make a Nape v2 Triangle shape of given width and height
var verts : Array = Polygon.regular( width *.5, height, 4, -Math.PI * .5 );
verts.splice( 2, 1 );
var shape:Shape = new Polygon( verts );
@vrobel
vrobel / deeperinjection.as
Created August 25, 2012 00:42 — forked from alecmce/deeperinjection.as
injecting data deeper?
//this one works fine
package
{
import flash.display.Sprite;
import robotlegs.bender.bundles.mvcs.MVCSBundle;
import robotlegs.bender.extensions.signalCommandMap.SignalCommandMapExtension;
import robotlegs.bender.framework.api.IContext;
import robotlegs.bender.framework.impl.Context;
@vrobel
vrobel / gist:3388643
Created August 18, 2012 17:38
What do you do if you find something like this
//poziom 2 //
slowa_losowanie=random(300)+1;
if (slowa_losowanie==1){
slowa="lorem";
}
else if (slowa_losowanie==2){
slowa="ipsum";
}
else if (slowa_losowanie==3){
slowa="dolor";