Skip to content

Instantly share code, notes, and snippets.

@nicolasmbatista
nicolasmbatista / gist:5119b3ef0fcbfe1a9cee
Created May 9, 2014 01:43
SmartButtonEditor.cs for Unity3D
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor (typeof(SmartButton))]
public class SmartButtonEditor : Editor {
/// <summary>
/// The smart button itself. Here we will have stored all of his variables
/// </summary>
using UnityEngine;
using System.Collections;
public class SmartButton : MonoBehaviour {
public enum Usage {
Default,
URL,
SceneLoader,
return Movie;
Movie.prototype = {
constructor : Movie
,getAttribute : function (key){
return attributes[key];
}
,setAttribute : function (key,value){
attributes[key] = value;
}
};
//Private vars and functions
var attributes = {};
//Constructor
var Movie = function () {
};
define("movie", function () {
//Constructor
var Movie = function () {
};
//Private vars and functions
var attributes = {};
Movie.prototype = {
constructor : Movie
,getAttribute : function (key){
// Here we are loading a "movie" module to use in our callback function
require(["movie"], function(Movie) {
var a = new Movie();
a.setAttribute('name','terminator');
console.log(a.getAttribute('name'));
});
Project
Project/index.html
Project/scripts
Project/scripts/require.js
Project/scripts/main.js
Project/scripts/movie.js
<!DOCTYPE html>
<html>
<head>
<title>Using RequireJS</title>
<!-- we reference requirejs and tell it that what we want to load is specified in data-main -->
<script data-main="scripts/main" src="scripts/require.js"></script>
</head>
<body>
</body>
</html>