Last active
August 31, 2015 10:24
-
-
Save grimmdev/ae60a46ad28888e389bb to your computer and use it in GitHub Desktop.
Custom PowerUI Protocols for Unity3D for some savory and simple functions.
This file contains hidden or 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
using PowerUI.Css; | |
using UnityEngine; | |
namespace PowerUI{ | |
/// <summary> | |
/// This additive:// protocol enables a link to point to another scene. | |
/// E.g. href="additive://sceneName" will load the scene additive called 'sceneName' when clicked. | |
/// </summary> | |
public class AdditiveProtocol:FileProtocol{ | |
public override string[] GetNames(){ | |
return new string[]{"additive","sceneadditive","sceneadd"}; | |
} | |
public override void OnFollowLink(Element linkElement,FilePath path){ | |
Application.LoadLevelAdditive (path.Directory + path.File); | |
} | |
} | |
} |
This file contains hidden or 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
using PowerUI.Css; | |
using UnityEngine; | |
namespace PowerUI{ | |
/// <summary> | |
/// This error:// protocol enables a link to debug an error to the console. | |
/// E.g. href="error://Test Error!" will debug error in the console 'Test Error!' when clicked. | |
/// </summary> | |
public class ErrorProtocol:FileProtocol{ | |
public override string[] GetNames(){ | |
return new string[]{"error"}; | |
} | |
public override void OnFollowLink(Element linkElement,FilePath path){ | |
Debug.LogError (path.Directory + path.File); | |
} | |
} | |
} |
This file contains hidden or 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
using PowerUI.Css; | |
using UnityEngine; | |
using System.Reflection; | |
using System.Collections; | |
using System.Collections.Generic; | |
namespace PowerUI{ | |
/// <summary> | |
/// This gameobject:// protocol enables a link to instantiate a gameobject. | |
/// E.g. href="gameobject://Test" will instantiate the gameobject called 'Test' when clicked. | |
/// </summary> | |
public class GameObjectProtocol:FileProtocol{ | |
public override string[] GetNames(){ | |
return new string[]{"object","gameobject"}; | |
} | |
public override void OnFollowLink(Element linkElement,FilePath path){ | |
GameObject.Instantiate (Resources.Load<GameObject>(path.Directory + path.File)); | |
} | |
} | |
} |
This file contains hidden or 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
using PowerUI.Css; | |
using UnityEngine; | |
namespace PowerUI{ | |
/// <summary> | |
/// This log:// protocol enables a link to debug log to the console. | |
/// E.g. href="log://Test Log!" will debug log in the console 'Test Log!' when clicked. | |
/// </summary> | |
public class LogProtocol:FileProtocol{ | |
public override string[] GetNames(){ | |
return new string[]{"log"}; | |
} | |
public override void OnFollowLink(Element linkElement,FilePath path){ | |
Debug.Log (path.Directory + path.File); | |
} | |
} | |
} |
This file contains hidden or 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
using PowerUI.Css; | |
using UnityEngine; | |
namespace PowerUI{ | |
/// <summary> | |
/// This warning:// protocol enables a link to debug a warning to the console. | |
/// E.g. href="warning://Test Warning!" will debug warning in the console 'Test Warning!' when clicked. | |
/// </summary> | |
public class WarningProtocol:FileProtocol{ | |
public override string[] GetNames(){ | |
return new string[]{"warning"}; | |
} | |
public override void OnFollowLink(Element linkElement,FilePath path){ | |
Debug.LogWarning (path.Directory + path.File); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment