Extension:UnityEmbed

The UnityEmbed extension allows users to embed Unity 3D games on their wiki. You will need to upload the webplayer unity3d file to the wiki in order for the game to embed correctly on the page.

Usage
Once installed you can use the tag on any wiki page in this format: file=myLocalFile.unity3d|width=550|height=400

Installation
To install this extension, add the following to LocalSettings.php:

Code
Paste the following code into a file called unity.php in your extensions folder: tag', 'url' => 'https://www.mediawiki.org/wiki/Extension:UnityEmbed', );

$wgExtensionFunctions[] = "wfUnityExtension";

class Unity{ /* Constructor */ function Unity( $input ) { Unity::parseInput( $input ); // Parse the input Unity::genCode; // Generate the final code }

function parseInput( $input ) { for($pos=0; $posinstr = $this->tmp; $this->tmp = ''; }           else if($input{$pos}=='|') {// separator between arguments Unity::setValue; $this->tmp=''; }           else{ $this->tmp .= $input{$pos}; }       }        if($this->tmp!='') Unity::setValue; // Deal with the rest of the input string }

function setValue { if($this->instr=='file'|| // Whitelist of flash commands. Anything else but flash commands is ignored.               $this->instr=='width'||                $this->instr=='height') { $this->{$this->instr} = $this->tmp; }   }

function genCode{ $title = wfLocalFile(Title::newFromText(trim($this->file), NS_FILE)); if($title){ $url = $title->getFullURL; $this->code = 'width.'" height="'.$this->height.'" codebase="http://webplayer.unity3d.com/download_webplayer/UnityWebPlayer.cab#version=2,0,0,0">width.'" height="'.$this->height.'" type="application/vnd.unity" pluginspage="http://www.unity3d.com/unity-web-player-2.x" /> '; return $this->code; }   } }

function wfUnityExtension { global $wgParser; $wgParser->setHook( "unity", "renderUnity" ); }

function renderUnity( $input ) { $game = new Unity( $input );//creates a unity object return $game->code; // send the final code to the wiki }

Check if the extension was installed correctly by going to Special:Version, if you see "Unity Embed" under the Parser Hooks section of the page you've installed it correctly.