Skip to content

Instantly share code, notes, and snippets.

@martinvium
martinvium / gist:421d1742103d1c360563
Created November 11, 2014 18:56
Unity Learn Syntax Highlighting
var classes = "(Input|KeyCode|Time|KeyCode|Vector3|Color|MonoBehaviour|Mathf)";
Prism.languages.unity = Prism.languages.extend('java', {
'docs-static': new RegExp("(" + classes + "\\.[A-Z][a-zA-Z0-9]+)", "g"),
'docs-instance': new RegExp("(" + classes + "\\.[a-z][a-zA-Z0-9]+)", "g"),
'punctuation': false
});
// Unity Languages
Prism.languages.csharp = Prism.languages.extend('unity', {
'keyword': /\b(abstract|event|new|struct|as|explicit|null|switch|base|extern|object|this|bool|false|operator|throw|break|finally|out|true|byte|fixed|override|try|case|float|params|typeof|catch|for|private|uint|char|foreach|protected|ulong|checked|goto|public|unchecked|class|if|readonly|unsafe|const|implicit|ref|ushort|continue|in|return|using|decimal|int|sbyte|virtual|default|interface|sealed|volatile|delegate|internal|short|void|do|is|sizeof|while|double|lock|stackalloc|else|long|static|enum|namespace|string)\b/g
<?php
$engine = new EntityEngine();
$entity = new SimpleEntity($engine);
$entity->setComponent(new CollisionComponent());
foreach($engine->getAll('Collision') as $comp) {
$comp->update();
}
<?php
$engine = new EntityEngine();
$entity = new SimpleEntity($engine);
$entity->setComponent(new DialogComponent());
$entity->getComponent('Dialog')->talk();
// or just
$engine->getComponent($entity, 'Dialog')->talk();
<?php
class EntityEngine
{
private $components = array();
/**
* @param Entity $entity
* @param string $componentName
* @return Component
*/