This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* © 2022 Vitalii Stepanenko | |
* Licensed under the MIT License | |
* | |
* Base Singleton class | |
* | |
* Features: | |
* - Can be loaded with object from resources (may be useful if you need some configuration of singleton instance made in editor, but dont want to store it in each scene) | |
* - Can be placed to scene as regular Monobehaviour | |
* - Can be instantiated with DontDestroyOnLoad if persistance between scenes needed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
method_exists(\App::getInstance(),'version') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
the easiest way to use multiple constructors: | |
<?php | |
class A | |
{ | |
function __construct() | |
{ | |
$a = func_get_args(); | |
$i = func_num_args(); | |
if (method_exists($this,$f='__construct'.$i)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function makeInstance($class, $arguments = []) | |
{ | |
switch (count($arguments)) { | |
case 0: return new $class(); | |
case 1: return new $class(array_shift($arguments)); | |
case 2: return new $class(array_shift($arguments), array_shift($arguments)); | |
default: | |
$reflection = new \ReflectionClass($class); | |
return $reflection->newInstanceArgs($arguments); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class FullAccessWrapper | |
{ | |
protected $_self; | |
protected $_refl; | |
public function __construct($self) | |
{ | |
$this->_self = $self; | |
$this->_refl = new ReflectionObject($self); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (typeof window !== 'undefined') { | |
/** | |
* client based path.js | |
* | |
*/ | |
require.register("path.js", function(module, exports, require){ | |
var list = []; | |
module.exports = { | |
dirname : function(path) { | |
path = path || ""; |