Luke Briggs

Added a range of new example scenes; added in PowerSlide (replacing the dialogue…

… system); Added in Loonim editor windows; Table fix; resources:// works better with .json files; fixed issues with querySelector.
Showing 125 changed files with 2938 additions and 253 deletions
fileFormatVersion: 2
guid: ccc6ca7b7af571f4d9841d83739306b3
folderAsset: yes
timeCreated: 1487084086
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
//--------------------------------------
// PowerUI
//
// For documentation or
// if you have any issues, visit
// powerUI.kulestar.com
//
// Copyright 2013 Kulestar Ltd
// www.kulestar.com
//--------------------------------------
using UnityEditor;
using UnityEngine;
using System.Threading;
using System.IO;
namespace Loonim{
public delegate void TickboxChangeEvent(SettingTickbox box);
/// <summary>
/// Represents a checkbox option which toggles a defined symbol.
/// It uses defines symbols for performance purposes; it can short out pieces of code that aren't needed.
/// Used mainly by general settings.
/// </summary>
public class SettingTickbox{
/// <summary>True if its checked.</summary>
public bool Active;
/// <summary>The English name, e.g. "Custom Input".</summary>
public string Name;
/// <summary>The help text.</summary>
public string Help;
/// <summary>Called when the tickbox changes.</summary>
public TickboxChangeEvent OnChanged;
public SettingTickbox(string name,string help,TickboxChangeEvent onChanged){
Name=name;
Help=help;
OnChanged=onChanged;
}
/// <summary>Shows the UI.</summary>
public void OnGUI(){
bool previous=Active;
Active=EditorGUILayout.Toggle(Name,previous);
#if !PRE_UNITY3_5
UnityEditor.EditorGUILayout.HelpBox(Help,MessageType.Info);
#endif
if(previous!=Active){
if(OnChanged!=null){
OnChanged(this);
}
}
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 204420d1068a52f45a84c9f409fe891b
timeCreated: 1487084086
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: e60c1a240b21dc840a9d0f1c5c0892ec
folderAsset: yes
timeCreated: 1487084086
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
//--------------------------------------
// PowerUI
//
// For documentation or
// if you have any issues, visit
// powerUI.kulestar.com
//
// Copyright 2013 Kulestar Ltd
// www.kulestar.com
//--------------------------------------
#if UNITY_2_6 || UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4
#define PRE_UNITY3_5
#endif
#if PRE_UNITY3_5 || UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7
#define PRE_UNITY5
#endif
#if PRE_UNITY5 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
#define PRE_UNITY5_3
#endif
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using System.Threading;
using System.IO;
using System.Collections;
using System.Collections.Generic;
namespace Loonim{
/// <summary>
/// Displays a list of supported texture nodes.
/// </summary>
public class ShaderSettings : EditorWindow{
/// <summary>The last opened window.</summary>
public static EditorWindow Window;
/// <summary>The tickboxes.</summary>
public static SettingTickbox[] Settings;
/// <summary>Gets the graphics settings.</summary>
public static SerializedObject GetGraphics(){
return new SerializedObject(
AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/GraphicsSettings.asset")[0]
);
}
/// <summary>Adds/ removes all available Loonim shaders from the 'always included' list.
/// To not exclude certain ones, just delete the files.</summary>
public static void AddOrRemoveShaders(bool add){
// Open up graphics settings:
SerializedObject graphics=GetGraphics();
// Get hold of the 'always included shaders' property:
SerializedProperty prop=graphics.FindProperty("m_AlwaysIncludedShaders");
// Always remove first:
RemoveLoonimShaders(prop,true);
if(add){
// Add now:
AddLoonimShaders(prop);
}
// Save:
graphics.ApplyModifiedProperties();
}
/// <summary>Removes all Loonim/* shaders from the given property array of shaders.</summary>
public static void AddLoonimShaders(SerializedProperty shaderArray){
// Get all available shaders:
string[] guids = AssetDatabase.FindAssets("t:Shader");
for(int i=0;i<guids.Length;i++){
// Get the path:
string assetPath = AssetDatabase.GUIDToAssetPath( guids[i] );
// Load the shader:
Shader shader = AssetDatabase.LoadAssetAtPath(assetPath,typeof(Shader)) as Shader;
if(shader==null){
continue;
}
// If the shader starts with Loonim/, add it:
if(!shader.name.StartsWith("Loonim/")){
continue;
}
// Loonim shader! Add it now:
shaderArray.arraySize++;
// Create a new entry:
SerializedProperty entry=shaderArray.GetArrayElementAtIndex(shaderArray.arraySize - 1);
// Update it:
entry.objectReferenceValue=shader;
}
}
/// <summary>True if graphics settings already contains at least one Loonim shader.</summary>
public static bool ContainsLoonimShaders(){
// Open up graphics settings:
SerializedObject graphics=GetGraphics();
// Get hold of the 'always included shaders' property:
SerializedProperty shaderArray=graphics.FindProperty("m_AlwaysIncludedShaders");
int size=shaderArray.arraySize;
// Backwards because we're removing entries:
for(int i=size-1;i>=0;i--){
// Get the entry:
SerializedProperty entry=shaderArray.GetArrayElementAtIndex(i);
// If the ref'd shader is a Loonim one..
Shader shader=entry.objectReferenceValue as Shader;
if(shader!=null && shader.name.StartsWith("Loonim/")){
return true;
}
}
return false;
}
/// <summary>Removes all Loonim/* shaders from the given property array of shaders.</summary>
public static void RemoveLoonimShaders(SerializedProperty shaderArray,bool removeNulls){
int size=shaderArray.arraySize;
// Backwards because we're removing entries:
for(int i=size-1;i>=0;i--){
// Get the entry:
SerializedProperty entry=shaderArray.GetArrayElementAtIndex(i);
// If the ref'd shader is a Loonim one..
Shader shader=entry.objectReferenceValue as Shader;
if(shader==null){
if(removeNulls){
shaderArray.DeleteArrayElementAtIndex(i);
}
continue;
}
if(shader.name.StartsWith("Loonim/")){
// Same function twice is correct here!
// Got one! Remove the value:
shaderArray.DeleteArrayElementAtIndex(i);
// And remove the array entry:
shaderArray.DeleteArrayElementAtIndex(i);
}
}
}
// Add menu item named "Shader Settings" to the Loonim menu:
[MenuItem("Window/Loonim/Shader Settings")]
public static void ShowWindow(){
Settings=new SettingTickbox[]{
new SettingTickbox(
"Include Shaders",
"Loonim uses many shaders for its GPU based drawing pipeline. "+
"On some platforms, Unity will strip the shaders out. "+
"Tick the box in here to ensure they're always included. "+
"If you don't want to include all of them, just delete the unwanted shader files.",
delegate(SettingTickbox box){
// Add or remove shaders:
AddOrRemoveShaders(box.Active);
}
)
};
// Check if we contain at least 1 shader:
Settings[0].Active=ContainsLoonimShaders();
// Show existing window instance. If one doesn't exist, make one.
Window=EditorWindow.GetWindow(typeof(ShaderSettings));
// Give it a title:
#if PRE_UNITY5_3
Window.title="Shader Settings";
#else
GUIContent title=new GUIContent();
title.text="Shader Settings";
Window.titleContent=title;
#endif
}
void OnGUI(){
if(Settings==null){
return;
}
foreach(SettingTickbox setting in Settings){
// Draw it:
setting.OnGUI();
}
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: fbb62404e5218c1449d74dbc91af4216
timeCreated: 1487084089
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: d4920f734afb9bd468bc571abff2f1c3
folderAsset: yes
timeCreated: 1487084086
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
//--------------------------------------
// PowerUI
//
// For documentation or
// if you have any issues, visit
// powerUI.kulestar.com
//
// Copyright 2013 Kulestar Ltd
// www.kulestar.com
//--------------------------------------
#if UNITY_2_6 || UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4
#define PRE_UNITY3_5
#endif
#if PRE_UNITY3_5 || UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7
#define PRE_UNITY5
#endif
#if PRE_UNITY5 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
#define PRE_UNITY5_3
#endif
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using System.Threading;
using System.IO;
using System.Collections;
using System.Collections.Generic;
namespace Loonim{
/// <summary>
/// Displays a list of supported texture nodes.
/// </summary>
public class SupportedNodes : EditorWindow{
/// <summary>The list of available nodes.</summary>
private static string[] Nodes;
/// <summary>The selected node index in the Properties array.</summary>
public static int SelectedIndex;
/// <summary>The selected node, if any.</summary>
public static TextureNodeMeta SelectedNode;
/// <summary>The last opened window.</summary>
public static EditorWindow Window;
/// <summary>Instances of the supported nodes.</summary>
private static List<TextureNodeMeta> Instances;
/// <summary>Gets a list of all available nodes.</summary>
public static List<TextureNodeMeta> GetNodes(bool reload){
if(reload){
Reload();
}else if(Instances==null){
Load();
}
return Instances;
}
// Add menu item named "Supported Nodes" to the Loonim menu:
[MenuItem("Window/Loonim/Supported Nodes")]
public static void ShowWindow(){
// Show existing window instance. If one doesn't exist, make one.
Window=EditorWindow.GetWindow(typeof(SupportedNodes));
// Give it a title:
#if PRE_UNITY5_3
Window.title="Supported Nodes";
#else
GUIContent title=new GUIContent();
title.text="Supported Nodes";
Window.titleContent=title;
#endif
Load();
}
/// <summary>Forces a reload. It's a Very Bad Idea to call this whilst the game is running!</summary>
public static void Reload(){
Nodes=null;
// If your game is running, here be gremlins:
TextureNodes.All=null;
Load();
}
/// <summary>Load all available nodes if they've not been loaded yet.</summary>
public static void Load(){
if(Nodes==null){
// Load the nodes:
LoadAvailableNodes();
}
}
void HelpBox(string message){
#if !PRE_UNITY3_5
UnityEditor.EditorGUILayout.HelpBox(message,MessageType.Info);
#endif
}
void OnGUI(){
HelpBox("Here's the nodes that Loonim is currently recognising.");
if(Nodes==null){
Load();
}
// Dropdown list:
int selected=EditorGUILayout.Popup(SelectedIndex,Nodes);
if(selected!=SelectedIndex || SelectedNode==null){
SelectedIndex=selected;
LoadSelected();
}
// Detailed information about the selected node:
if(SelectedNode!=null){
// Show the name:
EditorGUILayout.LabelField(SelectedNode.Name, EditorStyles.boldLabel);
if(!string.IsNullOrEmpty(SelectedNode.Name)){
HelpBox("To find the source file, try searching for this:");
EditorGUILayout.SelectableLabel(SelectedNode.ID+"-"+SelectedNode.Name+".cs");
}
}
}
/// <summary>Gets hold of the selected node and figures out the approximate file name.</summary>
private static void LoadSelected(){
// Get the node:
SelectedNode=Instances[SelectedIndex];
}
/// <summary>All nodes (set by LoadAvailableNodes).</summary>
private static Dictionary<int,TextureNodeMeta> AllNodes;
/// <summary>Loads the set of nodes.</summary>
public static void LoadAvailableNodes(){
// Refresh the node set:
TextureNodes.All=null;
TextureNodes.Get(0);
// Get the full list:
AllNodes=TextureNodes.All;
// The result list:
List<TextureNodeMeta> meta=new List<TextureNodeMeta>();
// For each one..
foreach(KeyValuePair<int,TextureNodeMeta> kvp in AllNodes){
// Add it to the list:
meta.Add(kvp.Value);
}
// Sort it:
meta.Sort(delegate(TextureNodeMeta a,TextureNodeMeta b){
return a.Name.CompareTo(b.Name);
});
// Ok! Time to create a textual list:
Instances=meta;
string[] names=new string[meta.Count];
for(int i=0;i<meta.Count;i++){
names[i]=meta[i].Name;
}
Nodes=names;
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 2fd276dd8a73194468bb1138d298d4e5
timeCreated: 1487084086
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
<!-- Time for a little CSS! --><style type='text/css'> html{ background:url(noise-background.png);} #content-box{ background:#e7e8ee; border:6px solid #cccccc; border-radius:70px 30px 70px 30px; width:300px; padding:40px; color:black; left:10%; } </style> <!-- The PowerUI logo off to the right. We're using direct style here. --><div style='vertical-align:middle;right:10%;width:140px;height:100%;position:fixed;'> <!-- The logo itself. --> <img src='powerUI-logo.png'/> </div> <!-- The rounded box containing the welcome info. Gets its style from the CSS above. --><div id='content-box'> <b>Welcome to PowerUI!</b> <br> <br> The HTML for this example is in a file called Basics.html sitting alongside this scene in your project. <br> <br> <b>To add a UI to a new scene..</b> <br> Go to GameObject &gt; Create Other &gt; Simple Main UI. This creates a gameobject which you can attach a .HTML file to. <br> <br> <b>To quickly make a .HTML file..</b> <br> Right click in your project and go to PowerUI &gt; New HTML File. <br> <br> <b>Need help? No problem!</b> <br> PowerUI can do a vast amount of stuff so make sure you check out our <a href='http://powerui.kulestar.com/getting-started/' target='_blank'>help guides</a> or if you're stuck please do get in touch! <br> <br> For the latest updates and free extras see <a href='http://powerui.kulestar.com/me/'>My PowerUI</a>.</div>
\ No newline at end of file
<!-- Time for a little CSS! --><style type='text/css'> html{ background:url(noise-background.png);} #content-box{ background:#e7e8ee; border:6px solid #cccccc; border-radius:70px 30px 70px 30px; width:300px; padding:40px; color:black; left:10%; } </style> <!-- The PowerUI logo off to the right. We're using direct style here (and a shortcut for vertical aligning). --><div style='vertical-align:table-middle;right:10%;width:140px;height:100%;position:fixed;'> <!-- The logo itself. --> <img src='powerUI-logo.png'/> </div> <!-- The rounded box containing the welcome info. Gets its style from the CSS above. --><div id='content-box'> <b>Welcome to PowerUI!</b> <br> <br> The HTML for this example is in a file called Basics.html sitting alongside this scene in your project. <br> <br> <b>To add a UI to a new scene..</b> <br> Go to GameObject &gt; Create Other &gt; Simple Main UI. This creates a gameobject which you can attach a .HTML file to. <br> <br> <b>To quickly make a .HTML file..</b> <br> Right click in your project and go to PowerUI &gt; New HTML File. <br> <br> <b>Need help? No problem!</b> <br> PowerUI can do a vast amount of stuff so make sure you check out our <a href='http://powerui.kulestar.com/getting-started/' target='_blank'>help guides</a> or if you're stuck please do get in touch! <br> <br> For the latest updates and free extras see <a href='http://powerui.kulestar.com/me/'>My PowerUI</a>.</div>
\ No newline at end of file
......
......@@ -13,13 +13,22 @@ public class AdvancedHealth : MonoBehaviour {
// Use this for initialization
void Start () {
/* Future update: This will instead be bars of any shape using SVG and stroke */
// Create our dynamic textures:
PowerBarGraphic=new PowerBar();
HealthBarGraphic=new HealthBar();
// Internally they have now setup
// dynamic://healthbar and dynamic://powerbar
// links for easy access from the html.
// Get a reference to the document:
var document=UI.document;
// Get the elements (using the shortcut for HtmlElement):
var powerBar=document.getById("powerbar");
var healthBar=document.getById("healthbar");
// Apply the graphics to them:
powerBar.SetImage(PowerBarGraphic);
healthBar.SetImage(HealthBarGraphic);
}
......
......@@ -10,13 +10,12 @@ html{
<!-- The PowerUI logo in the middle of the screen. -->
<div style='background:url(powerUI-logo.png) no-repeat;background-position:center;height:100%;position:fixed;'></div>
<div style='position:fixed;left:30px;top:30px;padding:20px;width:240px;z-index:100;'>
<img src='dynamic://powerbar' style='top:11px;left:3px;'/>
<img src='dynamic://healthbar'/>
<img src='healthPower.png' style='bottom:84px;'>
<img src='player.png' style='bottom:153px;left:124px;'/>
<div style='font-size:14px;bottom:200px;left:20px;'>
<div style='position:fixed;left:30px;top:30px;padding:20px;width:240px;'>
<img id='powerbar' style='position:relative;top:11px;left:3px;'/>
<img id='healthbar'/>
<img src='healthPower.png' style='position:relative;bottom:84px;'>
<img src='player.png' style='position:relative;bottom:153px;left:124px;'/>
<div style='position:relative;font-size:14px;bottom:200px;left:20px;'>
<b>
PowerUI
<br>
......@@ -34,7 +33,7 @@ html{
<br>
Dynamic textures draw their content straight to the UI's graphics.<br><br>
Textures that require being drawn at runtime like the curved healthbar above can get great flexibility from this.<br><br>
Note that if you want to display custom drawn Texture2D images or RenderTextures on the UI, use ImageCache.Add.
Note that if you want to display custom drawn Texture2D images or RenderTextures on the UI, use element.image=tex; or ImageCache.Add.
</div>
</center>
......
using System;using UnityEngine;using PowerUI; public class PowerBar:DynamicTexture{ /// <summary>A value from 0->1 that represents how full the bar is.</summary> public float Power=0f; /// <summary>The number of vertical lines drawn to display the bar.</summary> public int PixelLines=0; /// <summary>The colour of a full bar.</summary> public Color LitColour=Color.blue; /// <summary>The colour of an empty bar.</summary> public Color UnlitColour=Color.black; /// <summary>The y pixel coordinates using the array index as x to draw a quarter circle. /// The values are essentially mirrored over x to produce a half circle for the ends of the bar.</summary> public int[] HalfCircleY=new int[]{5,4,4,3,1}; public PowerBar():base(166,11){ // 166 (w) x 11 (h) px. // This texture will be accessible with dynamic://powerbar. PixelLines=166; } /// <summary>Increases (or decreases for a negative) the current value of the bar.</summary> /// <param name="delta">A value from 0->1 representing how much the bar should change by.</param> public void IncreasePower(float delta){ SetPower(Power+delta); } /// <summary>Sets the active value of this bar.</summary> /// <param name="power">A value from 0->1 indicating how full the bar is.</param> public void SetPower(float power){ if(power<0f){ power=0f; }else if(power>1f){ power=1f; } if(power==Power){ return; } Power=power; // The bar changed, so request a refresh: Refresh(); } /// <summary>Writes the pixels out to the screen.</summary> public override void Flush(){ // First, clear the graphic: Clear(); int linesActive=(int)(Power*PixelLines); if(linesActive<0){ linesActive=0; }else if(linesActive>PixelLines){ linesActive=PixelLines; } // Now draw the ends of the bar: int left=linesActive-(PixelLines-5); if(left<0){ left=0; } // Left half circle: DrawLeftHalfCircle(4,5,left); // Right half circle: DrawRightHalfCircle(165,5,linesActive); // And the rectangular section of the bar: int unlitLineCount=PixelLines-5-linesActive; if(unlitLineCount<0){ unlitLineCount=0; } Color colour=UnlitColour; int lineCount=0; for(int x=5;x<=160;x++){ if(lineCount==unlitLineCount){ colour=LitColour; } lineCount++; DrawLine(x,10,x,0,colour); } } /// <summary>Draws the right half of a circle to the image.</summary> /// <param name="x0">The x location in pixels of the middle of the circle.</param> /// <param name="y0">The y location in pixels of the middle of the circle.</param> /// <param name="linesGreen">The number of lines out of 5 that should be coloured green, counting up from the right.</param> public void DrawRightHalfCircle(int x0,int y0,int linesGreen){ // y^2 = 25 - x^2. // Radius is always 5. => x^2 + y^2 = 25. // Must use this as we need to scan from the left to right for linesGreen. int lineCount=0; Color colour=LitColour; for(int i=0;i<5;i++){ if(lineCount==linesGreen){ colour=UnlitColour; } lineCount++; int y=HalfCircleY[4-i]; DrawLine(x0-i,y0-y,x0-i,y0+y,colour); } } /// <summary>Draws the left half of a circle to the image.</summary> /// <param name="x0">The x location in pixels of the middle of the circle.</param> /// <param name="y0">The y location in pixels of the middle of the circle.</param> /// <param name="linesGreen">The number of lines out of 5 that should be coloured green, counting up from the right.</param> public void DrawLeftHalfCircle(int x0,int y0,int linesGreen){ // y^2 = 25 - x^2. // Radius is always 5. => x^2 + y^2 = 25. // Must use this as we need to scan from the left to right for linesGreen. int lineCount=0; Color colour=LitColour; for(int i=0;i<5;i++){ if(lineCount==linesGreen){ colour=UnlitColour; } lineCount++; int y=HalfCircleY[i]; DrawLine(x0-i,y0-y,x0-i,y0+y,colour); } } }
\ No newline at end of file
using System;using UnityEngine;using PowerUI; public class PowerBar:DynamicTexture{ /// <summary>A value from 0->1 that represents how full the bar is.</summary> public float Power=0f; /// <summary>The number of vertical lines drawn to display the bar.</summary> public int PixelLines=0; /// <summary>The colour of a full bar.</summary> public Color LitColour=Color.blue; /// <summary>The colour of an empty bar.</summary> public Color UnlitColour=Color.black; /// <summary>The y pixel coordinates using the array index as x to draw a quarter circle. /// The values are essentially mirrored over x to produce a half circle for the ends of the bar.</summary> public int[] HalfCircleY=new int[]{5,4,4,3,1}; public PowerBar():base(166,11){ // 166 (w) x 11 (h) px. PixelLines=166; } /// <summary>Increases (or decreases for a negative) the current value of the bar.</summary> /// <param name="delta">A value from 0->1 representing how much the bar should change by.</param> public void IncreasePower(float delta){ SetPower(Power+delta); } /// <summary>Sets the active value of this bar.</summary> /// <param name="power">A value from 0->1 indicating how full the bar is.</param> public void SetPower(float power){ if(power<0f){ power=0f; }else if(power>1f){ power=1f; } if(power==Power){ return; } Power=power; // The bar changed, so request a refresh: Refresh(); } /// <summary>Writes the pixels out to the screen.</summary> public override void Flush(){ // First, clear the graphic: Clear(); int linesActive=(int)(Power*PixelLines); if(linesActive<0){ linesActive=0; }else if(linesActive>PixelLines){ linesActive=PixelLines; } // Now draw the ends of the bar: int left=linesActive-(PixelLines-5); if(left<0){ left=0; } // Left half circle: DrawLeftHalfCircle(4,5,left); // Right half circle: DrawRightHalfCircle(165,5,linesActive); // And the rectangular section of the bar: int unlitLineCount=PixelLines-5-linesActive; if(unlitLineCount<0){ unlitLineCount=0; } Color colour=UnlitColour; int lineCount=0; for(int x=5;x<=160;x++){ if(lineCount==unlitLineCount){ colour=LitColour; } lineCount++; DrawLine(x,10,x,0,colour); } } /// <summary>Draws the right half of a circle to the image.</summary> /// <param name="x0">The x location in pixels of the middle of the circle.</param> /// <param name="y0">The y location in pixels of the middle of the circle.</param> /// <param name="linesGreen">The number of lines out of 5 that should be coloured green, counting up from the right.</param> public void DrawRightHalfCircle(int x0,int y0,int linesGreen){ // y^2 = 25 - x^2. // Radius is always 5. => x^2 + y^2 = 25. // Must use this as we need to scan from the left to right for linesGreen. int lineCount=0; Color colour=LitColour; for(int i=0;i<5;i++){ if(lineCount==linesGreen){ colour=UnlitColour; } lineCount++; int y=HalfCircleY[4-i]; DrawLine(x0-i,y0-y,x0-i,y0+y,colour); } } /// <summary>Draws the left half of a circle to the image.</summary> /// <param name="x0">The x location in pixels of the middle of the circle.</param> /// <param name="y0">The y location in pixels of the middle of the circle.</param> /// <param name="linesGreen">The number of lines out of 5 that should be coloured green, counting up from the right.</param> public void DrawLeftHalfCircle(int x0,int y0,int linesGreen){ // y^2 = 25 - x^2. // Radius is always 5. => x^2 + y^2 = 25. // Must use this as we need to scan from the left to right for linesGreen. int lineCount=0; Color colour=LitColour; for(int i=0;i<5;i++){ if(lineCount==linesGreen){ colour=UnlitColour; } lineCount++; int y=HalfCircleY[i]; DrawLine(x0-i,y0-y,x0-i,y0+y,colour); } } }
\ No newline at end of file
......
......@@ -38,8 +38,8 @@ public class MyContextMenus : MonoBehaviour {
myElement.oncontextmenu=delegate(ContextEvent ce){
// If you'd like to use some other window template, you'd do that here:
// (This way, your 3D context menu's can look totally different, for example).
// ce.window="menulist";
// (This way, your 3D context menus can look totally different, for example).
// ce.template="menulist";
// Add the options (supports HTML, localisation and custom Option classes):
ce.add("About",delegate(Option sender){
......@@ -55,7 +55,7 @@ public class MyContextMenus : MonoBehaviour {
});
// The add methods return the Option object it created.
// You can add to them too - they're also lists:
// You can add to them too to make a submenu:
option.add("Email",delegate(Option sender){
Debug.Log("powerui@kulestar.com");
......
fileFormatVersion: 2
guid: fe52ec1f9e72c3d4ea5d4a3676cdbe25
folderAsset: yes
timeCreated: 1487037579
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections;
using PowerUI;
using PowerSlide; // <-- Don't forget me!
public class MyPowerSlideAnimations : MonoBehaviour {
void Start(){
// Get a reference to the main UI document so everything else looks wonderfully familiar:
var document=UI.document;
// Get the tips element:
var tips=document.getById("toptips");
// -1- We'll just setup a mousedown event which will trigger the slides to play for us.
document.getElementById("starter").onmousedown=delegate(MouseEvent e){
// Trigger it! This is done with the slides CSS property,
// which is structured exactly the same as the animation CSS property.
// (getById is e.getElementById cast to a HtmlElement so we can get style)
// Runs Resources/powerSlideExample.json on the 'toptips' example, making the whole thing last for 3s.
// The json file doesn't declare any durations so the 4s is split evenly amongst the slides.
// To allow interruptions, you must clear it first (i.e. spam the button - it resets the animation):
tips.style.slides=null;
tips.style.slides="url(PowerSlideExample.json) 3s";
};
// Catch the slides end event:
tips.addEventListener("slidesend",delegate(PowerSlide.SlideEvent se){
Dom.Log.Add("Slide complete!");
});
}
}
fileFormatVersion: 2
guid: 1dc43a3c3f574684291ee9b70fd42241
timeCreated: 1487037580
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
<style>
/* Style for the document so we can have something positioned at the bottom */
body{
margin:0;
height:100%;
}
html{
height:100%;
}
/* Style for the tip bar */
#toptips{
box-sizing:border-box;
height:200px;
background:white;
padding:20px;
position:fixed;
bottom:0px;
color:black;
margin-bottom:-200px;
}
.tipTitle{
margin-left:-100%;
height:100%;
}
.tipMessage{
padding:20px;
margin-top:100%;
}
/* Used by the first slide to bring the whole tip up */
@keyframes tipUp{
0%{ margin-bottom:-200px;opacity:0; }
100%{ margin-bottom:0px;opacity:1; }
}
/* Used by the second slide to bring the title in from the left */
@keyframes titleIn{
0%{ margin-left:-100%;opacity:0; }
100%{ margin-left:0%;opacity:1; }
}
/* Used by the third slide to bring the tip body in from the bottom */
@keyframes messageUp{
0%{ margin-top:100%;opacity:0; }
100%{ margin-top:0%;opacity:1; }
}
/*
Note: In the near future, these keyframes and any other associated style
will be able to be declared in the slides file
making it completely self-contained and easy to share.
*/
</style>
<div style='padding:20px;'>
PowerSlide is used to declare <b>sequences of things</b>. It's great for animations and dialogue (speech between people).
<br>
<br>
This example <i>(inspired by SimCity)</i> shows PowerSlide being used to create a series of animations - check it out!
<br>
<br>
<input type='button' id='starter' value='Run PowerSlide!'/>
<br>
<br>
<b>A quick note about competing selectors:</b> If you have a selector "untriggering" whilst an animation is playing, it will cause a style refresh which 'wins' and drops the animation. For example, when an <b>active</b> selector no longer matches an element and it untriggers, an animation on that element may be cancelled. This will be getting attention in the future.