Initial Commit (broken due to version update)
This commit is contained in:
parent
74003df84b
commit
3f7b3b7440
3132 changed files with 1103305 additions and 0 deletions
|
|
@ -0,0 +1,23 @@
|
|||
///Credit ChoMPHi
|
||||
///Sourced from - http://forum.unity3d.com/threads/accordion-type-layout.271818/
|
||||
|
||||
using UnityEngine.UI.Extensions;
|
||||
|
||||
namespace UnityEditor.UI
|
||||
{
|
||||
[CustomEditor(typeof(AccordionElement), true)]
|
||||
public class AccordionElementEditor : ToggleEditor {
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
this.serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(this.serializedObject.FindProperty("m_MinHeight"));
|
||||
this.serializedObject.ApplyModifiedProperties();
|
||||
|
||||
base.serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(base.serializedObject.FindProperty("m_IsOn"));
|
||||
EditorGUILayout.PropertyField(base.serializedObject.FindProperty("m_Interactable"));
|
||||
base.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8882b502b0c65b24ba4623d6a383815b
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
/// Credit dakka
|
||||
/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/#post-1752415
|
||||
/// Notes - Mod from Yilmaz Kiymaz's editor scripts presentation at Unite 2013
|
||||
/// Updated ddreaper - removed Linq use, not required.
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
public class CanvasGroupActivator : EditorWindow
|
||||
{
|
||||
[MenuItem("Window/UI/Extensions/Canvas Groups Activator")]
|
||||
public static void InitWindow()
|
||||
{
|
||||
EditorWindow.GetWindow<CanvasGroupActivator>();
|
||||
}
|
||||
|
||||
CanvasGroup[] canvasGroups;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
ObtainCanvasGroups();
|
||||
}
|
||||
|
||||
void OnFocus()
|
||||
{
|
||||
ObtainCanvasGroups();
|
||||
}
|
||||
|
||||
void ObtainCanvasGroups()
|
||||
{
|
||||
canvasGroups = GameObject.FindObjectsOfType<CanvasGroup>();
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
if (canvasGroups == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GUILayout.Space(10f);
|
||||
GUILayout.Label("Canvas Groups");
|
||||
|
||||
for (int i = 0; i < canvasGroups.Length; i++)
|
||||
{
|
||||
if (canvasGroups[i] == null) { continue; }
|
||||
|
||||
bool initialActive = false;
|
||||
if (canvasGroups[i].alpha == 1.0f)
|
||||
initialActive = true;
|
||||
|
||||
bool active = EditorGUILayout.Toggle(canvasGroups[i].name, initialActive);
|
||||
if (active != initialActive)
|
||||
{
|
||||
//If deactivated and initially active
|
||||
if (!active && initialActive)
|
||||
{
|
||||
//Deactivate this
|
||||
canvasGroups[i].alpha = 0f;
|
||||
canvasGroups[i].interactable = false;
|
||||
canvasGroups[i].blocksRaycasts = false;
|
||||
}
|
||||
//If activated and initially deactive
|
||||
else if (active && !initialActive)
|
||||
{
|
||||
//Deactivate all others and activate this
|
||||
HideAllGroups();
|
||||
|
||||
canvasGroups[i].alpha = 1.0f;
|
||||
canvasGroups[i].interactable = true;
|
||||
canvasGroups[i].blocksRaycasts = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(5f);
|
||||
|
||||
if (GUILayout.Button("Show All"))
|
||||
{
|
||||
ShowAllGroups();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Hide All"))
|
||||
{
|
||||
HideAllGroups();
|
||||
}
|
||||
}
|
||||
|
||||
void ShowAllGroups()
|
||||
{
|
||||
foreach (var group in canvasGroups)
|
||||
{
|
||||
if (group != null)
|
||||
{
|
||||
group.alpha = 1.0f;
|
||||
group.interactable = true;
|
||||
group.blocksRaycasts = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HideAllGroups()
|
||||
{
|
||||
foreach (var group in canvasGroups)
|
||||
{
|
||||
if (group != null)
|
||||
{
|
||||
group.alpha = 0;
|
||||
group.interactable = false;
|
||||
group.blocksRaycasts = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f60a419e63d329f43ba1bf57e98b34bf
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
219
Assets/Scripts/unity-ui-extensions/Editor/CompressionTests.cs
Normal file
219
Assets/Scripts/unity-ui-extensions/Editor/CompressionTests.cs
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
#if UNITY_5_3_OR_NEWER
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI.Extensions;
|
||||
|
||||
public class CompressionTests {
|
||||
|
||||
[Test]
|
||||
public void RandomGUIDCompressionTestLength()
|
||||
{
|
||||
string x = string.Empty;
|
||||
using (var sequence = Enumerable.Range(1, 100).GetEnumerator())
|
||||
{
|
||||
while(sequence.MoveNext()) // string length 3600
|
||||
{
|
||||
x += Guid.NewGuid();
|
||||
}
|
||||
}
|
||||
|
||||
byte[] byteText = Encoding.Unicode.GetBytes(x);
|
||||
var compressed = CLZF2.Compress(byteText);
|
||||
var decompressed = CLZF2.Decompress(compressed);
|
||||
|
||||
Assert.AreEqual(byteText.Length, decompressed.Length);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RandomGUIDCompressionTestBytes()
|
||||
{
|
||||
string x = string.Empty;
|
||||
using (var sequence = Enumerable.Range(1, 100).GetEnumerator())
|
||||
{
|
||||
while (sequence.MoveNext()) // string length 3600
|
||||
{
|
||||
x += Guid.NewGuid();
|
||||
}
|
||||
}
|
||||
|
||||
byte[] byteText = Encoding.Unicode.GetBytes(x);
|
||||
var compressed = CLZF2.Compress(byteText);
|
||||
var decompressed = CLZF2.Decompress(compressed);
|
||||
|
||||
Assert.AreEqual(byteText, decompressed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RandomGUIDCompressionTestString()
|
||||
{
|
||||
string x = string.Empty;
|
||||
using (var sequence = Enumerable.Range(1, 100).GetEnumerator())
|
||||
{
|
||||
while (sequence.MoveNext()) // string length 3600
|
||||
{
|
||||
x += Guid.NewGuid();
|
||||
}
|
||||
}
|
||||
|
||||
byte[] byteText = Encoding.Unicode.GetBytes(x);
|
||||
var compressed = CLZF2.Compress(byteText);
|
||||
var decompressed = CLZF2.Decompress(compressed);
|
||||
var outString = Encoding.Unicode.GetString(decompressed);
|
||||
|
||||
Assert.AreEqual(outString, x);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThousandCharacterCompressionTest()
|
||||
{
|
||||
var x = new string('X', 10000);
|
||||
byte[] byteText = Encoding.Unicode.GetBytes(x);
|
||||
byte[] compressed = CLZF2.Compress(byteText);
|
||||
byte[] decompressed = CLZF2.Decompress(compressed);
|
||||
var outString = Encoding.Unicode.GetString(decompressed);
|
||||
|
||||
Assert.AreEqual(byteText.Length, decompressed.Length);
|
||||
Assert.AreEqual(byteText, decompressed);
|
||||
Assert.AreEqual(outString, x);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LongFormattedStringCompressionTest()
|
||||
{
|
||||
string longstring = "defined input is deluciously delicious.14 And here and Nora called The reversal from ground from here and executed with touch the country road, Nora made of, reliance on, can’t publish the goals of grandeur, said to his book and encouraging an envelope, and enable entry into the chryssial shimmering of hers, so God of information in her hands Spiros sits down the sign of winter? —It’s kind of Spice Christ. It is one hundred birds circle above the text: They did we said. 69 percent dead. Sissy Cogan’s shadow. —Are you x then sings.) I’m 96 percent dead humanoid figure,";
|
||||
byte[] byteText = Encoding.Unicode.GetBytes(longstring);
|
||||
byte[] compressed = CLZF2.Compress(byteText);
|
||||
byte[] decompressed = CLZF2.Decompress(compressed);
|
||||
var outString = Encoding.Unicode.GetString(decompressed);
|
||||
|
||||
Assert.AreEqual(byteText.Length, decompressed.Length);
|
||||
Assert.AreEqual(byteText, decompressed);
|
||||
Assert.AreEqual(outString, longstring);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SavingSimpleObject()
|
||||
{
|
||||
Vector3[] MySaveItem = new Vector3[1000];
|
||||
for (int i = 0; i < MySaveItem.Length; i++)
|
||||
{
|
||||
MySaveItem[i] = Vector3.one * i;
|
||||
}
|
||||
var mySaveObject = ObjectToByteArray(MySaveItem);
|
||||
byte[] compressed = CLZF2.Compress(mySaveObject);
|
||||
byte[] decompressed = CLZF2.Decompress(compressed);
|
||||
var outSaveObject = ObjectToByteArray<Vector3[]>(decompressed);
|
||||
|
||||
Assert.AreEqual(mySaveObject.Length, decompressed.Length);
|
||||
Assert.AreEqual(mySaveObject, decompressed);
|
||||
Assert.AreEqual(outSaveObject, MySaveItem);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SavingComplexObject()
|
||||
{
|
||||
MyComplexObject[] MySaveItem = new MyComplexObject[1000];
|
||||
for (int i = 0; i < MySaveItem.Length; i++)
|
||||
{
|
||||
var item = new MyComplexObject();
|
||||
item.myPosition = Vector3.one * i;
|
||||
item.myPositionHistory = new Vector3[100];
|
||||
item.myChatHistory = new string[100];
|
||||
for (int j = 0; j < 100; j++)
|
||||
{
|
||||
item.myPositionHistory[j] = Vector3.one * j;
|
||||
item.myChatHistory[j] = "Chat line: " + j;
|
||||
}
|
||||
}
|
||||
var mySaveObject = ObjectToByteArray(MySaveItem);
|
||||
byte[] compressed = CLZF2.Compress(mySaveObject);
|
||||
byte[] decompressed = CLZF2.Decompress(compressed);
|
||||
var outSaveObject = ObjectToByteArray<MyComplexObject[]>(decompressed);
|
||||
|
||||
Assert.AreEqual(mySaveObject.Length, decompressed.Length);
|
||||
Assert.AreEqual(mySaveObject, decompressed);
|
||||
Assert.AreEqual(outSaveObject, MySaveItem);
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
struct MyComplexObject
|
||||
{
|
||||
public Vector3 myPosition;
|
||||
public Vector3[] myPositionHistory;
|
||||
public string[] myChatHistory;
|
||||
}
|
||||
|
||||
byte[] ObjectToByteArray(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
BinaryFormatter bf = new BinaryFormatter();
|
||||
// 1. Construct a SurrogateSelector object
|
||||
SurrogateSelector ss = new SurrogateSelector();
|
||||
// 2. Add the ISerializationSurrogates to our new SurrogateSelector
|
||||
AddSurrogates(ref ss);
|
||||
// 3. Have the formatter use our surrogate selector
|
||||
bf.SurrogateSelector = ss;
|
||||
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
bf.Serialize(ms, obj);
|
||||
return ms.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
T ObjectToByteArray<T>(byte[] arrBytes)
|
||||
{
|
||||
if (arrBytes == null)
|
||||
return default(T);
|
||||
|
||||
using (MemoryStream memStream = new MemoryStream())
|
||||
{
|
||||
BinaryFormatter bf = new BinaryFormatter();
|
||||
// 1. Construct a SurrogateSelector object
|
||||
SurrogateSelector ss = new SurrogateSelector();
|
||||
// 2. Add the ISerializationSurrogates to our new SurrogateSelector
|
||||
AddSurrogates(ref ss);
|
||||
// 3. Have the formatter use our surrogate selector
|
||||
bf.SurrogateSelector = ss;
|
||||
memStream.Write(arrBytes, 0, arrBytes.Length);
|
||||
memStream.Seek(0, SeekOrigin.Begin);
|
||||
T obj = (T)bf.Deserialize(memStream);
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddSurrogates(ref SurrogateSelector ss)
|
||||
{
|
||||
Vector2Surrogate Vector2_SS = new Vector2Surrogate();
|
||||
ss.AddSurrogate(typeof(Vector2),
|
||||
new StreamingContext(StreamingContextStates.All),
|
||||
Vector2_SS);
|
||||
Vector3Surrogate Vector3_SS = new Vector3Surrogate();
|
||||
ss.AddSurrogate(typeof(Vector3),
|
||||
new StreamingContext(StreamingContextStates.All),
|
||||
Vector3_SS);
|
||||
Vector4Surrogate Vector4_SS = new Vector4Surrogate();
|
||||
ss.AddSurrogate(typeof(Vector4),
|
||||
new StreamingContext(StreamingContextStates.All),
|
||||
Vector4_SS);
|
||||
ColorSurrogate Color_SS = new ColorSurrogate();
|
||||
ss.AddSurrogate(typeof(Color),
|
||||
new StreamingContext(StreamingContextStates.All),
|
||||
Color_SS);
|
||||
QuaternionSurrogate Quaternion_SS = new QuaternionSurrogate();
|
||||
ss.AddSurrogate(typeof(Quaternion),
|
||||
new StreamingContext(StreamingContextStates.All),
|
||||
Quaternion_SS);
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ff5c7cf8d5ccd284482327cd78debc20
|
||||
timeCreated: 1464888738
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9cac1e572d83dad488ea068b606f4033
|
||||
folderAsset: yes
|
||||
timeCreated: 1509646237
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2379eab8e1f1c41d3a999c4eec534e4e
|
||||
timeCreated: 18446744011573954816
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,215 @@
|
|||
//C# Example
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class Screenshot : EditorWindow
|
||||
{
|
||||
|
||||
int resWidth = Screen.width*4;
|
||||
int resHeight = Screen.height*4;
|
||||
|
||||
public Camera myCamera;
|
||||
int scale = 1;
|
||||
|
||||
string path = "";
|
||||
bool showPreview = true;
|
||||
RenderTexture renderTexture;
|
||||
|
||||
bool isTransparent = false;
|
||||
|
||||
// Add menu item named "My Window" to the Window menu
|
||||
[MenuItem("Tools/Saad Khawaja/Instant High-Res Screenshot")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
//Show existing window instance. If one doesn't exist, make one.
|
||||
EditorWindow editorWindow = EditorWindow.GetWindow(typeof(Screenshot));
|
||||
editorWindow.autoRepaintOnSceneChange = true;
|
||||
editorWindow.Show();
|
||||
editorWindow.title = "Screenshot";
|
||||
}
|
||||
|
||||
float lastTime;
|
||||
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
EditorGUILayout.LabelField ("Resolution", EditorStyles.boldLabel);
|
||||
resWidth = EditorGUILayout.IntField ("Width", resWidth);
|
||||
resHeight = EditorGUILayout.IntField ("Height", resHeight);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
scale = EditorGUILayout.IntSlider ("Scale", scale, 1, 15);
|
||||
|
||||
EditorGUILayout.HelpBox("The default mode of screenshot is crop - so choose a proper width and height. The scale is a factor " +
|
||||
"to multiply or enlarge the renders without loosing quality.",MessageType.None);
|
||||
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
|
||||
GUILayout.Label ("Save Path", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.TextField(path,GUILayout.ExpandWidth(false));
|
||||
if(GUILayout.Button("Browse",GUILayout.ExpandWidth(false)))
|
||||
path = EditorUtility.SaveFolderPanel("Path to Save Images",path,Application.dataPath);
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.HelpBox("Choose the folder in which to save the screenshots ",MessageType.None);
|
||||
EditorGUILayout.Space();
|
||||
|
||||
|
||||
|
||||
//isTransparent = EditorGUILayout.Toggle(isTransparent,"Transparent Background");
|
||||
|
||||
|
||||
|
||||
GUILayout.Label ("Select Camera", EditorStyles.boldLabel);
|
||||
|
||||
|
||||
myCamera = EditorGUILayout.ObjectField(myCamera, typeof(Camera), true,null) as Camera;
|
||||
|
||||
|
||||
if(myCamera == null)
|
||||
{
|
||||
myCamera = Camera.main;
|
||||
}
|
||||
|
||||
isTransparent = EditorGUILayout.Toggle("Transparent Background", isTransparent);
|
||||
|
||||
|
||||
EditorGUILayout.HelpBox("Choose the camera of which to capture the render. You can make the background transparent using the transparency option.",MessageType.None);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.BeginVertical();
|
||||
EditorGUILayout.LabelField ("Default Options", EditorStyles.boldLabel);
|
||||
|
||||
|
||||
if(GUILayout.Button("Set To Screen Size"))
|
||||
{
|
||||
resHeight = (int)Handles.GetMainGameViewSize().y;
|
||||
resWidth = (int)Handles.GetMainGameViewSize().x;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(GUILayout.Button("Default Size"))
|
||||
{
|
||||
resHeight = 1440;
|
||||
resWidth = 2560;
|
||||
scale = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField ("Screenshot will be taken at " + resWidth*scale + " x " + resHeight*scale + " px", EditorStyles.boldLabel);
|
||||
|
||||
if(GUILayout.Button("Take Screenshot",GUILayout.MinHeight(60)))
|
||||
{
|
||||
if(path == "")
|
||||
{
|
||||
path = EditorUtility.SaveFolderPanel("Path to Save Images",path,Application.dataPath);
|
||||
Debug.Log("Path Set");
|
||||
TakeHiResShot();
|
||||
}
|
||||
else
|
||||
{
|
||||
TakeHiResShot();
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
if(GUILayout.Button("Open Last Screenshot",GUILayout.MaxWidth(160),GUILayout.MinHeight(40)))
|
||||
{
|
||||
if(lastScreenshot != "")
|
||||
{
|
||||
Application.OpenURL("file://" + lastScreenshot);
|
||||
Debug.Log("Opening File " + lastScreenshot);
|
||||
}
|
||||
}
|
||||
|
||||
if(GUILayout.Button("Open Folder",GUILayout.MaxWidth(100),GUILayout.MinHeight(40)))
|
||||
{
|
||||
|
||||
Application.OpenURL("file://" + path);
|
||||
}
|
||||
|
||||
if(GUILayout.Button("More Assets",GUILayout.MaxWidth(100),GUILayout.MinHeight(40)))
|
||||
{
|
||||
Application.OpenURL("https://www.assetstore.unity3d.com/en/#!/publisher/5951");
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
|
||||
if (takeHiResShot)
|
||||
{
|
||||
int resWidthN = resWidth*scale;
|
||||
int resHeightN = resHeight*scale;
|
||||
RenderTexture rt = new RenderTexture(resWidthN, resHeightN, 24);
|
||||
myCamera.targetTexture = rt;
|
||||
|
||||
TextureFormat tFormat;
|
||||
if(isTransparent)
|
||||
tFormat = TextureFormat.ARGB32;
|
||||
else
|
||||
tFormat = TextureFormat.RGB24;
|
||||
|
||||
|
||||
Texture2D screenShot = new Texture2D(resWidthN, resHeightN, tFormat,false);
|
||||
myCamera.Render();
|
||||
RenderTexture.active = rt;
|
||||
screenShot.ReadPixels(new Rect(0, 0, resWidthN, resHeightN), 0, 0);
|
||||
myCamera.targetTexture = null;
|
||||
RenderTexture.active = null;
|
||||
byte[] bytes = screenShot.EncodeToPNG();
|
||||
string filename = ScreenShotName(resWidthN, resHeightN);
|
||||
|
||||
System.IO.File.WriteAllBytes(filename, bytes);
|
||||
Debug.Log(string.Format("Took screenshot to: {0}", filename));
|
||||
Application.OpenURL(filename);
|
||||
takeHiResShot = false;
|
||||
}
|
||||
|
||||
EditorGUILayout.HelpBox("In case of any error, make sure you have Unity Pro as the plugin requires Unity Pro to work.",MessageType.Info);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private bool takeHiResShot = false;
|
||||
public string lastScreenshot = "";
|
||||
|
||||
|
||||
public string ScreenShotName(int width, int height) {
|
||||
|
||||
string strPath="";
|
||||
|
||||
strPath = string.Format("{0}/screen_{1}x{2}_{3}.png",
|
||||
path,
|
||||
width, height,
|
||||
System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"));
|
||||
lastScreenshot = strPath;
|
||||
|
||||
return strPath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void TakeHiResShot() {
|
||||
Debug.Log("Taking Screenshot");
|
||||
takeHiResShot = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1f43438d3f4cd402f8f372cbb8930f66
|
||||
timeCreated: 18446744011573954816
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/// Credit Slipp Douglas Thompson
|
||||
/// Sourced from - https://gist.github.com/capnslipp/349c18283f2fea316369
|
||||
///
|
||||
using UnityEditor;
|
||||
using UnityEditor.UI;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[CanEditMultipleObjects, CustomEditor(typeof(NonDrawingGraphic), false)]
|
||||
public class NonDrawingGraphicEditor : GraphicEditor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(base.m_Script, new GUILayoutOption[0]);
|
||||
// skipping AppearanceControlsGUI
|
||||
base.RaycastControlsGUI();
|
||||
base.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ee2802949feca4c4c934331b6a0dc379
|
||||
timeCreated: 1483566748
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Assets/Scripts/unity-ui-extensions/Editor/TextPicEditor.cs
Normal file
38
Assets/Scripts/unity-ui-extensions/Editor/TextPicEditor.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/// Credit drobina, w34edrtfg, playemgames
|
||||
/// Sourced from - http://forum.unity3d.com/threads/sprite-icons-with-text-e-g-emoticons.265927/
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(TextPic))]
|
||||
public class TextPicEditor : UnityEditor.UI.TextEditor
|
||||
{
|
||||
|
||||
private SerializedProperty ImageScalingFactorProp;
|
||||
private SerializedProperty hyperlinkColorProp;
|
||||
private SerializedProperty imageOffsetProp;
|
||||
private SerializedProperty iconList;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
ImageScalingFactorProp = serializedObject.FindProperty("ImageScalingFactor");
|
||||
hyperlinkColorProp = serializedObject.FindProperty("hyperlinkColor");
|
||||
imageOffsetProp = serializedObject.FindProperty("imageOffset");
|
||||
iconList = serializedObject.FindProperty("inspectorIconList");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(imageOffsetProp, new GUIContent("Image Offset"));
|
||||
EditorGUILayout.PropertyField(ImageScalingFactorProp, new GUIContent("Image Scaling Factor"));
|
||||
EditorGUILayout.PropertyField(hyperlinkColorProp, new GUIContent("Hyperlink Color"));
|
||||
EditorGUILayout.PropertyField(iconList, new GUIContent("Icon List"), true);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5fe8e67609bbee14d8ad0805aac72799
|
||||
timeCreated: 1468515486
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1839
Assets/Scripts/unity-ui-extensions/Editor/UIExtensionsMenuOptions.cs
Normal file
1839
Assets/Scripts/unity-ui-extensions/Editor/UIExtensionsMenuOptions.cs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3cac6d35505037446b512aea22d40688
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
115
Assets/Scripts/unity-ui-extensions/Editor/uGUITools.cs
Normal file
115
Assets/Scripts/unity-ui-extensions/Editor/uGUITools.cs
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/// Credit Senshi
|
||||
/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/ (uGUITools link)
|
||||
|
||||
using UnityEditor;
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
public static class uGUITools
|
||||
{
|
||||
[MenuItem("uGUI/Anchors to Corners %[")]
|
||||
static void AnchorsToCorners()
|
||||
{
|
||||
foreach (Transform transform in Selection.transforms)
|
||||
{
|
||||
RectTransform t = transform as RectTransform;
|
||||
RectTransform pt = Selection.activeTransform.parent as RectTransform;
|
||||
|
||||
if (t == null || pt == null) return;
|
||||
|
||||
Vector2 newAnchorsMin = new Vector2(t.anchorMin.x + t.offsetMin.x / pt.rect.width,
|
||||
t.anchorMin.y + t.offsetMin.y / pt.rect.height);
|
||||
Vector2 newAnchorsMax = new Vector2(t.anchorMax.x + t.offsetMax.x / pt.rect.width,
|
||||
t.anchorMax.y + t.offsetMax.y / pt.rect.height);
|
||||
|
||||
t.anchorMin = newAnchorsMin;
|
||||
t.anchorMax = newAnchorsMax;
|
||||
t.offsetMin = t.offsetMax = new Vector2(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("uGUI/Corners to Anchors %]")]
|
||||
static void CornersToAnchors()
|
||||
{
|
||||
foreach (Transform transform in Selection.transforms)
|
||||
{
|
||||
RectTransform t = transform as RectTransform;
|
||||
|
||||
if (t == null) return;
|
||||
|
||||
t.offsetMin = t.offsetMax = new Vector2(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("uGUI/Mirror Horizontally Around Anchors %;")]
|
||||
static void MirrorHorizontallyAnchors()
|
||||
{
|
||||
MirrorHorizontally(false);
|
||||
}
|
||||
|
||||
[MenuItem("uGUI/Mirror Horizontally Around Parent Center %:")]
|
||||
static void MirrorHorizontallyParent()
|
||||
{
|
||||
MirrorHorizontally(true);
|
||||
}
|
||||
|
||||
static void MirrorHorizontally(bool mirrorAnchors)
|
||||
{
|
||||
foreach (Transform transform in Selection.transforms)
|
||||
{
|
||||
RectTransform t = transform as RectTransform;
|
||||
RectTransform pt = Selection.activeTransform.parent as RectTransform;
|
||||
|
||||
if (t == null || pt == null) return;
|
||||
|
||||
if (mirrorAnchors)
|
||||
{
|
||||
Vector2 oldAnchorMin = t.anchorMin;
|
||||
t.anchorMin = new Vector2(1 - t.anchorMax.x, t.anchorMin.y);
|
||||
t.anchorMax = new Vector2(1 - oldAnchorMin.x, t.anchorMax.y);
|
||||
}
|
||||
|
||||
Vector2 oldOffsetMin = t.offsetMin;
|
||||
t.offsetMin = new Vector2(-t.offsetMax.x, t.offsetMin.y);
|
||||
t.offsetMax = new Vector2(-oldOffsetMin.x, t.offsetMax.y);
|
||||
|
||||
t.localScale = new Vector3(-t.localScale.x, t.localScale.y, t.localScale.z);
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("uGUI/Mirror Vertically Around Anchors %'")]
|
||||
static void MirrorVerticallyAnchors()
|
||||
{
|
||||
MirrorVertically(false);
|
||||
}
|
||||
|
||||
[MenuItem("uGUI/Mirror Vertically Around Parent Center %\"")]
|
||||
static void MirrorVerticallyParent()
|
||||
{
|
||||
MirrorVertically(true);
|
||||
}
|
||||
|
||||
static void MirrorVertically(bool mirrorAnchors)
|
||||
{
|
||||
foreach (Transform transform in Selection.transforms)
|
||||
{
|
||||
RectTransform t = transform as RectTransform;
|
||||
RectTransform pt = Selection.activeTransform.parent as RectTransform;
|
||||
|
||||
if (t == null || pt == null) return;
|
||||
|
||||
if (mirrorAnchors)
|
||||
{
|
||||
Vector2 oldAnchorMin = t.anchorMin;
|
||||
t.anchorMin = new Vector2(t.anchorMin.x, 1 - t.anchorMax.y);
|
||||
t.anchorMax = new Vector2(t.anchorMax.x, 1 - oldAnchorMin.y);
|
||||
}
|
||||
|
||||
Vector2 oldOffsetMin = t.offsetMin;
|
||||
t.offsetMin = new Vector2(t.offsetMin.x, -t.offsetMax.y);
|
||||
t.offsetMax = new Vector2(t.offsetMax.x, -oldOffsetMin.y);
|
||||
|
||||
t.localScale = new Vector3(t.localScale.x, -t.localScale.y, t.localScale.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b896154a8dbdc524092e78923478d27a
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
Loading…
Reference in a new issue