Here are the examples of the csharp api UnityEngine.GUILayout.Label(UnityEngine.GUIContent, UnityEngine.GUIStyle, params UnityEngine.GUILayoutOption[]) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
783 Examples
19
Source : ColorCorrectionCurvesEditor.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
public override void OnInspectorGUI () {
serObj.Update ();
GUILayout.Label ("Use curves to tweak RGB channel colors", EditorStyles.miniBoldLabel);
saturation.floatValue = EditorGUILayout.Slider( "Saturation", saturation.floatValue, 0.0f, 5.0f);
EditorGUILayout.PropertyField (mode, new GUIContent ("Mode"));
EditorGUILayout.Separator ();
BeginCurves ();
CurveGui (" Red", redChannel, Color.red);
CurveGui (" Green", greenChannel, Color.green);
CurveGui (" Blue", blueChannel, Color.blue);
EditorGUILayout.Separator ();
if (mode.intValue > 0)
useDepthCorrection.boolValue = true;
else
useDepthCorrection.boolValue = false;
if (useDepthCorrection.boolValue) {
CurveGui (" Red (depth)", depthRedChannel, Color.red);
CurveGui (" Green (depth)", depthGreenChannel, Color.green);
CurveGui (" Blue (depth)", depthBlueChannel, Color.blue);
EditorGUILayout.Separator ();
CurveGui (" Blend Curve", zCurveChannel, Color.grey);
}
EditorGUILayout.Separator ();
EditorGUILayout.PropertyField (selectiveCc, new GUIContent ("Selective"));
if (selectiveCc.boolValue) {
EditorGUILayout.PropertyField (selectiveFromColor, new GUIContent (" Key"));
EditorGUILayout.PropertyField (selectiveToColor, new GUIContent (" Target"));
}
ApplyCurves ();
if (!applyCurveChanges)
serObj.ApplyModifiedProperties ();
}
19
Source : DepthOfFieldEditor.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
public override void OnInspectorGUI()
{
serObj.Update();
UpdateAnimBoolTargets();
EditorGUILayout.LabelField("Simulates camera lens defocus", EditorStyles.miniLabel);
GUILayout.Label("Focal Settings");
EditorGUILayout.PropertyField(visualizeFocus, new GUIContent(" Visualize"));
EditorGUILayout.PropertyField(focalTransform, new GUIContent(" Focus on Transform"));
if (EditorGUILayout.BeginFadeGroup(showFocalDistance.faded))
{
EditorGUILayout.PropertyField(focalLength, new GUIContent(" Focal Distance"));
}
EditorGUILayout.EndFadeGroup();
EditorGUILayout.Slider(focalSize, 0.0f, 2.0f, new GUIContent(" Focal Size"));
EditorGUILayout.Slider(aperture, 0.0f, 1.0f, new GUIContent(" Aperture"));
EditorGUILayout.Separator();
EditorGUILayout.PropertyField(blurType, new GUIContent("Defocus Type"));
if (!(target as DepthOfField).Dx11Support() && blurType.enumValueIndex > 0)
{
EditorGUILayout.HelpBox("DX11 mode not supported (need shader model 5)", MessageType.Info);
}
if (EditorGUILayout.BeginFadeGroup(showDiscBlurSettings.faded))
{
EditorGUILayout.PropertyField(blurSampleCount, new GUIContent(" Sample Count"));
}
EditorGUILayout.EndFadeGroup();
EditorGUILayout.Slider(maxBlurSize, 0.1f, 2.0f, new GUIContent(" Max Blur Distance"));
EditorGUILayout.PropertyField(highResolution, new GUIContent(" High Resolution"));
EditorGUILayout.Separator();
EditorGUILayout.PropertyField(nearBlur, new GUIContent("Near Blur"));
if (EditorGUILayout.BeginFadeGroup(showNearBlurOverlapSize.faded))
{
EditorGUILayout.Slider(foregroundOverlap, 0.1f, 2.0f, new GUIContent(" Overlap Size"));
}
EditorGUILayout.EndFadeGroup();
EditorGUILayout.Separator();
if (EditorGUILayout.BeginFadeGroup(showDX11BlurSettings.faded))
{
GUILayout.Label("DX11 Bokeh Settings");
EditorGUILayout.PropertyField(dx11BokehTexture, new GUIContent(" Bokeh Texture"));
EditorGUILayout.Slider(dx11BokehScale, 0.0f, 50.0f, new GUIContent(" Bokeh Scale"));
EditorGUILayout.Slider(dx11BokehIntensity, 0.0f, 100.0f, new GUIContent(" Bokeh Intensity"));
EditorGUILayout.Slider(dx11BokehThreshold, 0.0f, 1.0f, new GUIContent(" Min Luminance"));
EditorGUILayout.Slider(dx11SpawnHeuristic, 0.01f, 1.0f, new GUIContent(" Spawn Heuristic"));
}
EditorGUILayout.EndFadeGroup();
serObj.ApplyModifiedProperties();
}
19
Source : DepthOfFieldDeprecatedEditor.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
public override void OnInspectorGUI () {
serObj.Update ();
GameObject go = (target as DepthOfFieldDeprecated).gameObject;
if (!go)
return;
if (!go.GetComponent<Camera>())
return;
if (simpleTweakMode.boolValue)
GUILayout.Label ("Current: "+go.GetComponent<Camera>().name+", near "+go.GetComponent<Camera>().nearClipPlane+", far: "+go.GetComponent<Camera>().farClipPlane+", focal: "+focalPoint.floatValue, EditorStyles.miniBoldLabel);
else
GUILayout.Label ("Current: "+go.GetComponent<Camera>().name+", near "+go.GetComponent<Camera>().nearClipPlane+", far: "+go.GetComponent<Camera>().farClipPlane+", focal: "+focalZDistance.floatValue, EditorStyles.miniBoldLabel);
EditorGUILayout.PropertyField (resolution, new GUIContent("Resolution"));
EditorGUILayout.PropertyField (quality, new GUIContent("Quality"));
EditorGUILayout.PropertyField (simpleTweakMode, new GUIContent("Simple tweak"));
EditorGUILayout.PropertyField (visualizeCoc, new GUIContent("Visualize focus"));
EditorGUILayout.PropertyField (bokeh, new GUIContent("Enable bokeh"));
EditorGUILayout.Separator ();
GUILayout.Label ("Focal Settings", EditorStyles.boldLabel);
if (simpleTweakMode.boolValue) {
focalPoint.floatValue = EditorGUILayout.Slider ("Focal distance", focalPoint.floatValue, go.GetComponent<Camera>().nearClipPlane, go.GetComponent<Camera>().farClipPlane);
EditorGUILayout.PropertyField (objectFocus, new GUIContent("Transform"));
EditorGUILayout.PropertyField (smoothness, new GUIContent("Smoothness"));
focalSize.floatValue = EditorGUILayout.Slider ("Focal size", focalSize.floatValue, 0.0f, (go.GetComponent<Camera>().farClipPlane - go.GetComponent<Camera>().nearClipPlane));
}
else {
focalZDistance.floatValue = EditorGUILayout.Slider ("Distance", focalZDistance.floatValue, go.GetComponent<Camera>().nearClipPlane, go.GetComponent<Camera>().farClipPlane);
EditorGUILayout.PropertyField (objectFocus, new GUIContent("Transform"));
focalSize.floatValue = EditorGUILayout.Slider ("Size", focalSize.floatValue, 0.0f, (go.GetComponent<Camera>().farClipPlane - go.GetComponent<Camera>().nearClipPlane));
focalStartCurve.floatValue = EditorGUILayout.Slider ("Start curve", focalStartCurve.floatValue, 0.05f, 20.0f);
focalEndCurve.floatValue = EditorGUILayout.Slider ("End curve", focalEndCurve.floatValue, 0.05f, 20.0f);
}
EditorGUILayout.Separator ();
GUILayout.Label ("Blur (Fore- and Background)", EditorStyles.boldLabel);
EditorGUILayout.PropertyField (bluriness, new GUIContent("Blurriness"));
EditorGUILayout.PropertyField (maxBlurSpread, new GUIContent("Blur spread"));
if (quality.enumValueIndex > 0) {
EditorGUILayout.PropertyField (foregroundBlurExtrude, new GUIContent("Foreground size"));
}
EditorGUILayout.Separator ();
if (bokeh.boolValue) {
EditorGUILayout.Separator ();
GUILayout.Label ("Bokeh Settings", EditorStyles.boldLabel);
EditorGUILayout.PropertyField (bokehDestination, new GUIContent("Destination"));
bokehIntensity.floatValue = EditorGUILayout.Slider ("Intensity", bokehIntensity.floatValue, 0.0f, 1.0f);
bokehThresholdLuminance.floatValue = EditorGUILayout.Slider ("Min luminance", bokehThresholdLuminance.floatValue, 0.0f, 0.99f);
bokehThresholdContrast.floatValue = EditorGUILayout.Slider ("Min contrast", bokehThresholdContrast.floatValue, 0.0f, 0.25f);
bokehDownsample.intValue = EditorGUILayout.IntSlider ("Downsample", bokehDownsample.intValue, 1, 3);
bokehScale.floatValue = EditorGUILayout.Slider ("Size scale", bokehScale.floatValue, 0.0f, 20.0f);
EditorGUILayout.PropertyField (bokehTexture , new GUIContent("Texture mask"));
}
serObj.ApplyModifiedProperties();
}
19
Source : CheckResources.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void OnGUI ()
{
if (GUILayout.Button ("Refresh"))
CheckResources ();
GUILayout.BeginHorizontal ();
GUILayout.Label ("Materials " + ActiveMaterials.Count);
GUILayout.Label ("Textures " + ActiveTextures.Count + " - " + FormatSizeString (TotalTextureMemory));
GUILayout.Label ("Meshes " + ActiveMeshDetails.Count + " - " + TotalMeshVertices + " verts");
GUILayout.EndHorizontal ();
ActiveInspectType = (InspectType)GUILayout.Toolbar ((int)ActiveInspectType, inspectToolbarStrings);
ctrlPressed = Event.current.control || Event.current.command;
switch (ActiveInspectType) {
case InspectType.Textures:
ListTextures ();
break;
case InspectType.Materials:
ListMaterials ();
break;
case InspectType.Meshes:
ListMeshes ();
break;
}
}
19
Source : MemoryProfilerWindow.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void OnGUI(){
var svrGo = GameObject.FindObjectOfType<LuaSvrGameObject>();
if(svrGo == null){
GUILayout.Label("There is no LuaSvrGameObject in you scene. Run your game first");
return;
}
if(GUILayout.Button("Capture")){
System.GC.Collect ();
LuaDLL.lua_gc(svrGo.state.L, LuaGCOptions.LUA_GCCOLLECT, 0);
_destroyedObjectNames = ObjectCache.GetAlreadyDestroyedObjectNames();
_allObjectNames = ObjectCache.GetAllManagedObjectNames();
cachedDelegateCount = LuaState.main.cachedDelegateCount;
}
GUILayout.Label ("LuaDelegate count:" + cachedDelegateCount);
_showDestroyedObject = EditorGUILayout.Foldout(_showDestroyedObject,"Already Destroyed Unity Object:"+_destroyedObjectNames.Count);
if(_showDestroyedObject){
_scrollPos = GUILayout.BeginScrollView(_scrollPos);
foreach(var name in _destroyedObjectNames){
GUILayout.Label(name);
}
GUILayout.EndScrollView();
}
_showAllObject = EditorGUILayout.Foldout(_showAllObject,"All Managed C# Object:"+_allObjectNames.Count);
if(_showAllObject){
_scrollPos2 = GUILayout.BeginScrollView(_scrollPos2);
foreach(var name in _allObjectNames){
GUILayout.Label(name);
}
GUILayout.EndScrollView();
}
}
19
Source : LuaConsole.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void OnGUI()
{
if (!initedStyle)
{
GUIStyle entryInfoTyle = "CN EntryInfo";
textAreaStyle.richText = true;
textAreaStyle.normal.textColor = entryInfoTyle.normal.textColor;
initedStyle = true;
}
string[] statehints = new string[LuaState.statemap.Count];
LuaState[] states = new LuaState[LuaState.statemap.Count];
int n = 0;
foreach(var k in LuaState.statemap.Values) {
states[n] = k;
statehints[n++] = k.Name;
}
stateIndex = EditorGUILayout.Popup(stateIndex,statehints);
LuaState l = null;
if (stateIndex >= 0 && stateIndex <states.Length)
l = states[stateIndex];
if (current != null && current != l)
{
current.logDelegate -= AddLog;
current.errorDelegate -= AddError;
}
if(current!=l && l!=null) {
l.logDelegate += AddLog;
l.errorDelegate += AddError;
current = l;
}
//Output Text Area
scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(Screen.width), GUILayout.ExpandHeight(true));
EditorGUILayout.TextArea(outputText, textAreaStyle, GUILayout.ExpandHeight(true));
GUILayout.EndScrollView();
//Filter Option Toggles
GUILayout.BeginHorizontal();
bool oldToggleLog = toggleLog;
bool oldToggleErr = toggleErr;
toggleLog = GUILayout.Toggle(oldToggleLog, "log", GUILayout.ExpandWidth(false));
toggleErr = GUILayout.Toggle(oldToggleErr, "error", GUILayout.ExpandWidth(false));
//Filter Input Field
GUILayout.Space(10f);
GUILayout.Label("filter:", GUILayout.ExpandWidth(false));
string oldFilterPattern = filterText;
filterText = GUILayout.TextField(oldFilterPattern, GUILayout.Width(200f));
//Menu Buttons
if (GUILayout.Button("clear", GUILayout.ExpandWidth(false)))
{
recordList.Clear();
ConsoleFlush();
}
GUILayout.EndHorizontal();
if (toggleLog != oldToggleLog || toggleErr != oldToggleErr || filterText != oldFilterPattern)
{
ConsoleFlush();
}
if (Event.current.type == EventType.Repaint)
{
inputAreaPosY = GUILayoutUtility.GetLastRect().yMax;
}
//Drag Spliter
ResizeScrollView();
//Input Area
GUI.SetNextControlName("Input");
inputText = EditorGUILayout.TextField(inputText, GUILayout.Height(inputAreaHeight));
if (Event.current.isKey && Event.current.type == EventType.KeyUp)
{
bool refresh = false;
if (Event.current.keyCode == KeyCode.Return)
{
if (inputText != "")
{
if (history.Count == 0 || history[history.Count - 1] != inputText)
{
history.Add(inputText);
}
AddLog(inputText);
DoCommand(inputText);
inputText = "";
refresh = true;
historyIndex = history.Count;
}
}
else if (Event.current.keyCode == KeyCode.UpArrow)
{
if (history.Count > 0)
{
historyIndex = historyIndex - 1;
if (historyIndex < 0)
{
historyIndex = 0;
}
else
{
inputText = history[historyIndex];
refresh = true;
}
}
}
else if (Event.current.keyCode == KeyCode.DownArrow)
{
if (history.Count > 0)
{
historyIndex = historyIndex + 1;
if (historyIndex > history.Count - 1)
{
historyIndex = history.Count - 1;
}
else
{
inputText = history[historyIndex];
refresh = true;
}
}
}
if (refresh)
{
Repaint();
EditorGUIUtility.editingTextField = false;
GUI.FocusControl("Input");
}
}
}
19
Source : UIAtlasInspector.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
public override void OnInspectorGUI ()
{
EditorGUIUtility.LookLikeControls(80f);
mAtlas = target as UIAtlas;
NGUIEditorTools.DrawSeparator();
if (mAtlas.replacement != null)
{
mType = AtlasType.Reference;
mReplacement = mAtlas.replacement;
}
AtlasType after = (AtlasType)EditorGUILayout.EnumPopup("Atlas Type", mType);
if (mType != after)
{
if (after == AtlasType.Normal)
{
OnSelectAtlas(null);
}
else
{
mType = AtlasType.Reference;
}
}
if (mType == AtlasType.Reference)
{
ComponentSelector.Draw<UIAtlas>(mAtlas.replacement, OnSelectAtlas);
NGUIEditorTools.DrawSeparator();
GUILayout.Label("You can have one atlas simply point to\n" +
"another one. This is useful if you want to be\n" +
"able to quickly replace the contents of one\n" +
"atlas with another one, for example for\n" +
"swapping an SD atlas with an HD one, or\n" +
"replacing an English atlas with a Chinese\n" +
"one. All the sprites referencing this atlas\n" +
"will update their references to the new one.");
if (mReplacement != mAtlas && mAtlas.replacement != mReplacement)
{
NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
mAtlas.replacement = mReplacement;
UnityEditor.EditorUtility.SetDirty(mAtlas);
}
return;
}
if (!mConfirmDelete)
{
NGUIEditorTools.DrawSeparator();
Material mat = EditorGUILayout.ObjectField("Material", mAtlas.spriteMaterial, typeof(Material), false) as Material;
if (mAtlas.spriteMaterial != mat)
{
NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
mAtlas.spriteMaterial = mat;
// Ensure that this atlas has valid import settings
if (mAtlas.texture != null) NGUIEditorTools.ImportTexture(mAtlas.texture, false, false);
mAtlas.MarkAsDirty();
mConfirmDelete = false;
}
if (mat != null)
{
Textreplacedet ta = EditorGUILayout.ObjectField("TP Import", null, typeof(Textreplacedet), false) as Textreplacedet;
if (ta != null)
{
// Ensure that this atlas has valid import settings
if (mAtlas.texture != null) NGUIEditorTools.ImportTexture(mAtlas.texture, false, false);
NGUIEditorTools.RegisterUndo("Import Sprites", mAtlas);
NGUIJson.LoadSpriteData(mAtlas, ta);
if (mSprite != null) mSprite = mAtlas.GetSprite(mSprite.name);
mAtlas.MarkAsDirty();
}
UIAtlas.Coordinates coords = (UIAtlas.Coordinates)EditorGUILayout.EnumPopup("Coordinates", mAtlas.coordinates);
if (coords != mAtlas.coordinates)
{
NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
mAtlas.coordinates = coords;
mConfirmDelete = false;
}
float pixelSize = EditorGUILayout.FloatField("Pixel Size", mAtlas.pixelSize, GUILayout.Width(120f));
if (pixelSize != mAtlas.pixelSize)
{
NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
mAtlas.pixelSize = pixelSize;
mConfirmDelete = false;
}
}
}
if (mAtlas.spriteMaterial != null)
{
Color blue = new Color(0f, 0.7f, 1f, 1f);
Color green = new Color(0.4f, 1f, 0f, 1f);
if (mConfirmDelete)
{
if (mSprite != null)
{
// Show the confirmation dialog
NGUIEditorTools.DrawSeparator();
GUILayout.Label("Are you sure you want to delete '" + mSprite.name + "'?");
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
{
GUI.backgroundColor = Color.green;
if (GUILayout.Button("Cancel")) mConfirmDelete = false;
GUI.backgroundColor = Color.red;
if (GUILayout.Button("Delete"))
{
NGUIEditorTools.RegisterUndo("Delete Sprite", mAtlas);
mAtlas.spriteList.Remove(mSprite);
mConfirmDelete = false;
}
GUI.backgroundColor = Color.white;
}
GUILayout.EndHorizontal();
}
else mConfirmDelete = false;
}
else
{
if (mSprite == null && mAtlas.spriteList.Count > 0)
{
string spriteName = EditorPrefs.GetString("NGUI Selected Sprite");
if (!string.IsNullOrEmpty(spriteName)) mSprite = mAtlas.GetSprite(spriteName);
if (mSprite == null) mSprite = mAtlas.spriteList[0];
}
if (!mConfirmDelete && mSprite != null)
{
NGUIEditorTools.DrawSeparator();
NGUIEditorTools.AdvancedSpriteField(mAtlas, mSprite.name, SelectSprite, true);
if (mSprite == null) return;
Texture2D tex = mAtlas.spriteMaterial.mainTexture as Texture2D;
if (tex != null)
{
Rect inner = mSprite.inner;
Rect outer = mSprite.outer;
if (mAtlas.coordinates == UIAtlas.Coordinates.Pixels)
{
GUI.backgroundColor = green;
outer = NGUIEditorTools.IntRect("Dimensions", mSprite.outer);
Vector4 border = new Vector4(
mSprite.inner.xMin - mSprite.outer.xMin,
mSprite.inner.yMin - mSprite.outer.yMin,
mSprite.outer.xMax - mSprite.inner.xMax,
mSprite.outer.yMax - mSprite.inner.yMax);
GUI.backgroundColor = blue;
border = NGUIEditorTools.IntPadding("Border", border);
GUI.backgroundColor = Color.white;
inner.xMin = mSprite.outer.xMin + border.x;
inner.yMin = mSprite.outer.yMin + border.y;
inner.xMax = mSprite.outer.xMax - border.z;
inner.yMax = mSprite.outer.yMax - border.w;
}
else
{
// Draw the inner and outer rectangle dimensions
GUI.backgroundColor = green;
outer = EditorGUILayout.RectField("Outer Rect", mSprite.outer);
GUI.backgroundColor = blue;
inner = EditorGUILayout.RectField("Inner Rect", mSprite.inner);
GUI.backgroundColor = Color.white;
}
if (outer.xMax < outer.xMin) outer.xMax = outer.xMin;
if (outer.yMax < outer.yMin) outer.yMax = outer.yMin;
if (outer != mSprite.outer)
{
float x = outer.xMin - mSprite.outer.xMin;
float y = outer.yMin - mSprite.outer.yMin;
inner.x += x;
inner.y += y;
}
// Sanity checks to ensure that the inner rect is always inside the outer
inner.xMin = Mathf.Clamp(inner.xMin, outer.xMin, outer.xMax);
inner.xMax = Mathf.Clamp(inner.xMax, outer.xMin, outer.xMax);
inner.yMin = Mathf.Clamp(inner.yMin, outer.yMin, outer.yMax);
inner.yMax = Mathf.Clamp(inner.yMax, outer.yMin, outer.yMax);
bool changed = false;
if (mSprite.inner != inner || mSprite.outer != outer)
{
NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
mSprite.inner = inner;
mSprite.outer = outer;
MarkSpriteAsDirty();
changed = true;
}
EditorGUILayout.Separator();
if (mAtlas.coordinates == UIAtlas.Coordinates.Pixels)
{
int left = Mathf.RoundToInt(mSprite.paddingLeft * mSprite.outer.width);
int right = Mathf.RoundToInt(mSprite.paddingRight * mSprite.outer.width);
int top = Mathf.RoundToInt(mSprite.paddingTop * mSprite.outer.height);
int bottom = Mathf.RoundToInt(mSprite.paddingBottom * mSprite.outer.height);
NGUIEditorTools.IntVector a = NGUIEditorTools.IntPair("Padding", "Left", "Top", left, top);
NGUIEditorTools.IntVector b = NGUIEditorTools.IntPair(null, "Right", "Bottom", right, bottom);
if (changed || a.x != left || a.y != top || b.x != right || b.y != bottom)
{
NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
mSprite.paddingLeft = a.x / mSprite.outer.width;
mSprite.paddingTop = a.y / mSprite.outer.height;
mSprite.paddingRight = b.x / mSprite.outer.width;
mSprite.paddingBottom = b.y / mSprite.outer.height;
MarkSpriteAsDirty();
}
}
else
{
// Create a button that can make the coordinates pixel-perfect on click
GUILayout.BeginHorizontal();
{
GUILayout.Label("Correction", GUILayout.Width(75f));
Rect corrected0 = outer;
Rect corrected1 = inner;
if (mAtlas.coordinates == UIAtlas.Coordinates.Pixels)
{
corrected0 = NGUIMath.MakePixelPerfect(corrected0);
corrected1 = NGUIMath.MakePixelPerfect(corrected1);
}
else
{
corrected0 = NGUIMath.MakePixelPerfect(corrected0, tex.width, tex.height);
corrected1 = NGUIMath.MakePixelPerfect(corrected1, tex.width, tex.height);
}
if (corrected0 == mSprite.outer && corrected1 == mSprite.inner)
{
GUI.color = Color.grey;
GUILayout.Button("Make Pixel-Perfect");
GUI.color = Color.white;
}
else if (GUILayout.Button("Make Pixel-Perfect"))
{
outer = corrected0;
inner = corrected1;
GUI.changed = true;
}
}
GUILayout.EndHorizontal();
}
}
// This functionality is no longer used. It became obsolete when the Atlas Maker was added.
/*NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
{
EditorGUILayout.PrefixLabel("Add/Delete");
if (GUILayout.Button("Clone Sprite"))
{
NGUIEditorTools.RegisterUndo("Add Sprite", mAtlas);
UIAtlas.Sprite newSprite = new UIAtlas.Sprite();
if (mSprite != null)
{
newSprite.name = "Copy of " + mSprite.name;
newSprite.outer = mSprite.outer;
newSprite.inner = mSprite.inner;
}
else
{
newSprite.name = "New Sprite";
}
mAtlas.spriteList.Add(newSprite);
mSprite = newSprite;
}
// Show the delete button
GUI.backgroundColor = Color.red;
if (mSprite != null && GUILayout.Button("Delete", GUILayout.Width(55f)))
{
mConfirmDelete = true;
}
GUI.backgroundColor = Color.white;
}
GUILayout.EndHorizontal();*/
if (NGUIEditorTools.previousSelection != null)
{
NGUIEditorTools.DrawSeparator();
GUI.backgroundColor = Color.green;
if (GUILayout.Button("<< Return to " + NGUIEditorTools.previousSelection.name))
{
NGUIEditorTools.SelectPrevious();
}
GUI.backgroundColor = Color.white;
}
}
}
}
}
19
Source : ComponentSelector.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void OnGUI ()
{
EditorGUIUtility.LookLikeControls(80f);
GUILayout.Label("Recently used components", "LODLevelNotifyText");
NGUIEditorTools.DrawSeparator();
if (mObjects.Length == 0)
{
EditorGUILayout.HelpBox("No recently used " + mType.ToString() + " components found.\nTry drag & dropping one instead, or creating a new one.", MessageType.Info);
bool isDone = false;
EditorGUILayout.Space();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (mType == typeof(UIFont))
{
if (GUILayout.Button("Open the Font Maker", GUILayout.Width(150f)))
{
EditorWindow.GetWindow<UIFontMaker>(false, "Font Maker", true);
isDone = true;
}
}
else if (mType == typeof(UIAtlas))
{
if (GUILayout.Button("Open the Atlas Maker", GUILayout.Width(150f)))
{
EditorWindow.GetWindow<UIAtlasMaker>(false, "Atlas Maker", true);
isDone = true;
}
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
if (isDone) Close();
}
else
{
MonoBehaviour sel = null;
foreach (MonoBehaviour o in mObjects)
{
if (DrawObject(o))
{
sel = o;
}
}
if (sel != null)
{
mCallback(sel);
Close();
}
}
}
19
Source : ComponentSelector.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
bool DrawObject (MonoBehaviour mb)
{
bool retVal = false;
GUILayout.BeginHorizontal();
{
if (EditorUtility.IsPersistent(mb.gameObject))
{
GUILayout.Label("Prefab", "AS TextArea", GUILayout.Width(80f), GUILayout.Height(20f));
}
else
{
GUI.color = Color.grey;
GUILayout.Label("Object", "AS TextArea", GUILayout.Width(80f), GUILayout.Height(20f));
}
GUILayout.Label(NGUITools.GetHierarchy(mb.gameObject), "AS TextArea", GUILayout.Height(20f));
GUI.color = Color.white;
retVal = GUILayout.Button("Select", "ButtonLeft", GUILayout.Width(60f), GUILayout.Height(16f));
}
GUILayout.EndHorizontal();
return retVal;
}
19
Source : NGUIEditorTools.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
static public IntVector IntPair (string prefix, string leftCaption, string rightCaption, int x, int y)
{
GUILayout.BeginHorizontal();
if (string.IsNullOrEmpty(prefix))
{
GUILayout.Space(82f);
}
else
{
GUILayout.Label(prefix, GUILayout.Width(74f));
}
EditorGUIUtility.LookLikeControls(48f);
IntVector retVal;
retVal.x = EditorGUILayout.IntField(leftCaption, x, GUILayout.MinWidth(30f));
retVal.y = EditorGUILayout.IntField(rightCaption, y, GUILayout.MinWidth(30f));
EditorGUIUtility.LookLikeControls(80f);
GUILayout.EndHorizontal();
return retVal;
}
19
Source : NGUIEditorTools.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
static public void SpriteField (string fieldName, UIAtlas atlas, string spriteName,
SpriteSelector.Callback callback, params GUILayoutOption[] options)
{
GUILayout.BeginHorizontal();
GUILayout.Label(fieldName, GUILayout.Width(76f));
if (GUILayout.Button(spriteName, "MiniPullDown", options))
{
SpriteSelector.Show(atlas, spriteName, callback);
}
GUILayout.EndHorizontal();
}
19
Source : NGUIEditorTools.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
static public void SpriteField (string fieldName, string caption, UIAtlas atlas, string spriteName, SpriteSelector.Callback callback)
{
GUILayout.BeginHorizontal();
GUILayout.Label(fieldName, GUILayout.Width(76f));
if (atlas.GetSprite(spriteName) == null)
spriteName = "";
if (GUILayout.Button(spriteName, "MiniPullDown", GUILayout.Width(120f)))
{
SpriteSelector.Show(atlas, spriteName, callback);
}
if (!string.IsNullOrEmpty(caption))
{
GUILayout.Space(20f);
GUILayout.Label(caption);
}
GUILayout.EndHorizontal();
}
19
Source : NGUIEditorTools.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
static public void AdvancedSpriteField (UIAtlas atlas, string spriteName, SpriteSelector.Callback callback, bool editable,
params GUILayoutOption[] options)
{
// Give the user a warning if there are no sprites in the atlas
if (atlas.spriteList.Count == 0)
{
EditorGUILayout.HelpBox("No sprites found", MessageType.Warning);
return;
}
// Sprite selection drop-down list
GUILayout.BeginHorizontal();
{
if (GUILayout.Button("Sprite", "DropDownButton", GUILayout.Width(76f)))
{
SpriteSelector.Show(atlas, spriteName, callback);
}
if (editable)
{
string sn = GUILayout.TextField(spriteName);
if (sn != spriteName)
{
UIAtlas.Sprite sp = atlas.GetSprite(spriteName);
if (sp != null)
{
NGUIEditorTools.RegisterUndo("Edit Sprite Name", atlas);
sp.name = sn;
spriteName = sn;
}
}
}
else
{
GUILayout.BeginHorizontal();
GUILayout.Label(spriteName, "HelpBox", GUILayout.Height(18f));
GUILayout.Space(18f);
GUILayout.EndHorizontal();
if (GUILayout.Button("Edit", GUILayout.Width(40f)))
{
EditorPrefs.SetString("NGUI Selected Sprite", spriteName);
Select(atlas.gameObject);
}
}
}
GUILayout.EndHorizontal();
}
19
Source : SpriteSelector.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void OnGUI ()
{
EditorGUIUtility.LookLikeControls(80f);
if (mAtlas == null)
{
GUILayout.Label("No Atlas selected.", "LODLevelNotifyText");
}
else
{
bool close = false;
GUILayout.Label(mAtlas.name + " Sprites", "LODLevelNotifyText");
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
GUILayout.Space(84f);
string before = NGUISettings.partialSprite;
string after = EditorGUILayout.TextField("", before, "SearchTextField");
NGUISettings.partialSprite = after;
if (GUILayout.Button("", "SearchCancelButton", GUILayout.Width(18f)))
{
NGUISettings.partialSprite = "";
GUIUtility.keyboardControl = 0;
}
GUILayout.Space(84f);
GUILayout.EndHorizontal();
Texture2D tex = mAtlas.texture as Texture2D;
if (tex == null)
{
GUILayout.Label("The atlas doesn't have a texture to work with");
return;
}
BetterList<string> sprites = mAtlas.GetListOfSprites(NGUISettings.partialSprite);
float size = 80f;
float padded = size + 10f;
int columns = Mathf.FloorToInt(Screen.width / padded);
if (columns < 1) columns = 1;
int offset = 0;
Rect rect = new Rect(10f, 0, size, size);
GUILayout.Space(10f);
mPos = GUILayout.BeginScrollView(mPos);
while (offset < sprites.size)
{
GUILayout.BeginHorizontal();
{
int col = 0;
rect.x = 10f;
for (; offset < sprites.size; ++offset)
{
UIAtlas.Sprite sprite = mAtlas.GetSprite(sprites[offset]);
if (sprite == null) continue;
// Button comes first
if (GUI.Button(rect, ""))
{
float delta = Time.realtimeSinceStartup - mClickTime;
mClickTime = Time.realtimeSinceStartup;
if (spriteName != sprite.name)
{
if (mSprite != null)
{
NGUIEditorTools.RegisterUndo("Atlas Selection", mSprite);
mSprite.spriteName = sprite.name;
mSprite.MakePixelPerfect();
EditorUtility.SetDirty(mSprite.gameObject);
}
else if (mCallback != null)
{
mName = sprite.name;
mCallback(sprite.name);
}
}
else if (delta < 0.5f) close = true;
}
if (Event.current.type == EventType.Repaint)
{
// On top of the button we have a checkboard grid
NGUIEditorTools.DrawTiledTexture(rect, NGUIEditorTools.backdropTexture);
Rect uv = sprite.outer;
if (mAtlas.coordinates == UIAtlas.Coordinates.Pixels)
uv = NGUIMath.ConvertToTexCoords(uv, tex.width, tex.height);
// Calculate the texture's scale that's needed to display the sprite in the clipped area
float scaleX = rect.width / uv.width;
float scaleY = rect.height / uv.height;
// Stretch the sprite so that it will appear proper
float aspect = (scaleY / scaleX) / ((float)tex.height / tex.width);
Rect clipRect = rect;
if (aspect != 1f)
{
if (aspect < 1f)
{
// The sprite is taller than it is wider
float padding = size * (1f - aspect) * 0.5f;
clipRect.xMin += padding;
clipRect.xMax -= padding;
}
else
{
// The sprite is wider than it is taller
float padding = size * (1f - 1f / aspect) * 0.5f;
clipRect.yMin += padding;
clipRect.yMax -= padding;
}
}
GUI.DrawTextureWithTexCoords(clipRect, tex, uv);
// Draw the selection
if (spriteName == sprite.name)
{
NGUIEditorTools.DrawOutline(rect, new Color(0.4f, 1f, 0f, 1f));
}
}
if (++col >= columns)
{
++offset;
break;
}
rect.x += padded;
}
}
GUILayout.EndHorizontal();
GUILayout.Space(padded);
rect.y += padded;
}
GUILayout.EndScrollView();
if (close) Close();
}
}
19
Source : UIAtlasMaker.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void OnGUI ()
{
bool create = false;
bool update = false;
bool replace = false;
string prefabPath = "";
string matPath = "";
// If we have an atlas to work with, see if we can figure out the path for it and its material
if (NGUISettings.atlas != null && NGUISettings.atlas.name == NGUISettings.atlasName)
{
prefabPath = replacedetDatabase.GetreplacedetPath(NGUISettings.atlas.gameObject.GetInstanceID());
if (NGUISettings.atlas.spriteMaterial != null) matPath = replacedetDatabase.GetreplacedetPath(NGUISettings.atlas.spriteMaterial.GetInstanceID());
}
// replacedume default values if needed
if (string.IsNullOrEmpty(NGUISettings.atlasName)) NGUISettings.atlasName = "New Atlas";
if (string.IsNullOrEmpty(prefabPath)) prefabPath = NGUIEditorTools.GetSelectionFolder() + NGUISettings.atlasName + ".prefab";
if (string.IsNullOrEmpty(matPath)) matPath = NGUIEditorTools.GetSelectionFolder() + NGUISettings.atlasName + ".mat";
// Try to load the prefab
GameObject go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
if (NGUISettings.atlas == null && go != null) NGUISettings.atlas = go.GetComponent<UIAtlas>();
EditorGUIUtility.LookLikeControls(80f);
GUILayout.Space(6f);
GUILayout.BeginHorizontal();
if (go == null)
{
GUI.backgroundColor = Color.green;
create = GUILayout.Button("Create", GUILayout.Width(76f));
}
else
{
GUI.backgroundColor = Color.red;
create = GUILayout.Button("Replace", GUILayout.Width(76f));
}
GUI.backgroundColor = Color.white;
NGUISettings.atlasName = GUILayout.TextField(NGUISettings.atlasName);
GUILayout.EndHorizontal();
if (create)
{
// If the prefab already exists, confirm that we want to overwrite it
if (go == null || EditorUtility.DisplayDialog("Are you sure?", "Are you sure you want to replace the contents of the " +
NGUISettings.atlasName + " atlas with the textures currently selected in the Project View? All other sprites will be deleted.", "Yes", "No"))
{
replace = true;
// Try to load the material
Material mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;
// If the material doesn't exist, create it
if (mat == null)
{
Shader shader = Shader.Find("Unlit/Transparent Colored");
mat = new Material(shader);
// Save the material
replacedetDatabase.Createreplacedet(mat, matPath);
replacedetDatabase.Refresh();
// Load the material so it's usable
mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;
}
if (NGUISettings.atlas == null || NGUISettings.atlas.name != NGUISettings.atlasName)
{
// Create a new prefab for the atlas
#if UNITY_3_4
Object prefab = (go != null) ? go : EditorUtility.CreateEmptyPrefab(prefabPath);
#else
Object prefab = (go != null) ? go : PrefabUtility.CreateEmptyPrefab(prefabPath);
#endif
// Create a new game object for the atlas
go = new GameObject(NGUISettings.atlasName);
go.AddComponent<UIAtlas>().spriteMaterial = mat;
// Update the prefab
#if UNITY_3_4
EditorUtility.ReplacePrefab(go, prefab);
#else
PrefabUtility.ReplacePrefab(go, prefab);
#endif
DestroyImmediate(go);
replacedetDatabase.Savereplacedets();
replacedetDatabase.Refresh();
// Select the atlas
go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
NGUISettings.atlas = go.GetComponent<UIAtlas>();
}
}
}
ComponentSelector.Draw<UIAtlas>("Select", NGUISettings.atlas, OnSelectAtlas);
List<Texture> textures = GetSelectedTextures();
if (NGUISettings.atlas != null && NGUISettings.atlas.name == NGUISettings.atlasName)
{
Material mat = NGUISettings.atlas.spriteMaterial;
Texture tex = NGUISettings.atlas.texture;
// Material information
GUILayout.BeginHorizontal();
{
if (mat != null)
{
if (GUILayout.Button("Material", GUILayout.Width(76f))) Selection.activeObject = mat;
GUILayout.Label(" " + mat.name);
}
else
{
GUI.color = Color.grey;
GUILayout.Button("Material", GUILayout.Width(76f));
GUI.color = Color.white;
GUILayout.Label(" N/A");
}
}
GUILayout.EndHorizontal();
// Texture atlas information
GUILayout.BeginHorizontal();
{
if (tex != null)
{
if (GUILayout.Button("Texture", GUILayout.Width(76f))) Selection.activeObject = tex;
GUILayout.Label(" " + tex.width + "x" + tex.height);
}
else
{
GUI.color = Color.grey;
GUILayout.Button("Texture", GUILayout.Width(76f));
GUI.color = Color.white;
GUILayout.Label(" N/A");
}
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
NGUISettings.atlasPadding = Mathf.Clamp(EditorGUILayout.IntField("Padding", NGUISettings.atlasPadding, GUILayout.Width(100f)), 0, 8);
GUILayout.Label((NGUISettings.atlasPadding == 1 ? "pixel" : "pixels") + " in-between of sprites");
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
NGUISettings.atlasTrimming = EditorGUILayout.Toggle("Trim Alpha", NGUISettings.atlasTrimming, GUILayout.Width(100f));
GUILayout.Label("Remove empty space");
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
NGUISettings.unityPacking = EditorGUILayout.Toggle("Unity Packer", NGUISettings.unityPacking, GUILayout.Width(100f));
GUILayout.Label("if off, use a custom packer");
GUILayout.EndHorizontal();
if (!NGUISettings.unityPacking)
{
GUILayout.BeginHorizontal();
NGUISettings.forceSquareAtlas = EditorGUILayout.Toggle("Force Square", NGUISettings.forceSquareAtlas, GUILayout.Width(100f));
GUILayout.Label("if on, forces a square atlas texture");
GUILayout.EndHorizontal();
}
#if UNITY_IPHONE || UNITY_ANDROID
GUILayout.BeginHorizontal();
NGUISettings.allow4096 = EditorGUILayout.Toggle("4096x4096", NGUISettings.allow4096, GUILayout.Width(100f));
GUILayout.Label("if off, limit atlases to 2048x2048");
GUILayout.EndHorizontal();
#endif
if (textures.Count > 0)
{
GUI.backgroundColor = Color.green;
update = GUILayout.Button("Add/Update All");
GUI.backgroundColor = Color.white;
}
else
{
NGUIEditorTools.DrawSeparator();
GUILayout.Label("You can reveal more options by selecting\none or more textures in the Project View\nwindow.");
}
}
else
{
NGUIEditorTools.DrawSeparator();
GUILayout.Label("You can create a new atlas by selecting\none or more textures in the Project View\nwindow, then clicking \"Create\".");
}
Dictionary<string, int> spriteList = GetSpriteList(textures);
if (spriteList.Count > 0)
{
NGUIEditorTools.DrawHeader("Sprites");
GUILayout.Space(-7f);
mScroll = GUILayout.BeginScrollView(mScroll);
bool delete = false;
int index = 0;
foreach (KeyValuePair<string, int> iter in spriteList)
{
++index;
NGUIEditorTools.HighlightLine(new Color(0.6f, 0.6f, 0.6f));
GUILayout.BeginHorizontal();
GUILayout.Label(index.ToString(), GUILayout.Width(24f));
GUILayout.Label(iter.Key);
if (iter.Value == 2)
{
GUI.color = Color.green;
GUILayout.Label("Add", GUILayout.Width(27f));
GUI.color = Color.white;
}
else if (iter.Value == 1)
{
GUI.color = Color.cyan;
GUILayout.Label("Update", GUILayout.Width(45f));
GUI.color = Color.white;
}
else
{
if (mDelNames.Contains(iter.Key))
{
GUI.backgroundColor = Color.red;
if (GUILayout.Button("Delete", GUILayout.Width(60f)))
{
delete = true;
}
GUI.backgroundColor = Color.green;
if (GUILayout.Button("X", GUILayout.Width(22f)))
{
mDelNames.Remove(iter.Key);
delete = false;
}
GUI.backgroundColor = Color.white;
}
else
{
// If we have not yet selected a sprite for deletion, show a small "X" button
if (GUILayout.Button("X", GUILayout.Width(22f))) mDelNames.Add(iter.Key);
}
}
GUILayout.EndHorizontal();
}
GUILayout.EndScrollView();
// If this sprite was marked for deletion, remove it from the atlas
if (delete)
{
List<SpriteEntry> sprites = new List<SpriteEntry>();
ExtractSprites(NGUISettings.atlas, sprites);
for (int i = sprites.Count; i > 0; )
{
SpriteEntry ent = sprites[--i];
if (mDelNames.Contains(ent.tex.name))
{
sprites.RemoveAt(i);
}
}
UpdateAtlas(NGUISettings.atlas, sprites);
mDelNames.Clear();
}
else if (update) UpdateAtlas(textures, true);
else if (replace) UpdateAtlas(textures, false);
return;
}
}
19
Source : UICameraTool.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void OnGUI ()
{
EditorGUIUtility.LookLikeControls(80f);
List<Camera> list = NGUIEditorTools.FindInScene<Camera>();
if (list.Count > 0)
{
DrawRow(null);
NGUIEditorTools.DrawSeparator();
mScroll = GUILayout.BeginScrollView(mScroll);
foreach (Camera cam in list) DrawRow(cam);
GUILayout.EndScrollView();
}
else
{
GUILayout.Label("No cameras found in the scene");
}
}
19
Source : UICameraTool.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void DrawRow (Camera cam)
{
if (cam != null) NGUIEditorTools.HighlightLine(new Color(0.6f, 0.6f, 0.6f));
GUILayout.BeginHorizontal();
{
bool enabled = (cam == null || (NGUITools.GetActive(cam.gameObject) && cam.enabled));
GUI.color = Color.white;
if (cam != null)
{
if (enabled != EditorGUILayout.Toggle(enabled, GUILayout.Width(20f)))
{
cam.enabled = !enabled;
EditorUtility.SetDirty(cam.gameObject);
}
}
else
{
GUILayout.Space(30f);
}
bool highlight = (cam == null || Selection.activeGameObject == null) ? false :
(0 != (cam.cullingMask & (1 << Selection.activeGameObject.layer)));
if (enabled)
{
GUI.color = highlight ? new Color(0f, 0.8f, 1f) : Color.white;
}
else
{
GUI.color = highlight ? new Color(0f, 0.5f, 0.8f) : Color.grey;
}
string camName, camLayer;
if (cam == null)
{
camName = "Camera's Name";
camLayer = "Layer";
}
else
{
camName = cam.name + (cam.orthographic ? " (2D)" : " (3D)");
camLayer = LayerMask.LayerToName(cam.gameObject.layer);
}
#if UNITY_3_4
if (GUILayout.Button(camName, EditorStyles.structHeadingLabel, GUILayout.MinWidth(100f)) && cam != null)
#else
if (GUILayout.Button(camName, EditorStyles.label, GUILayout.MinWidth(100f)) && cam != null)
#endif
{
Selection.activeGameObject = cam.gameObject;
EditorUtility.SetDirty(cam.gameObject);
}
GUILayout.Label(camLayer, GUILayout.Width(70f));
GUI.color = enabled ? Color.white : new Color(0.7f, 0.7f, 0.7f);
if (cam == null)
{
GUILayout.Label("EV", GUILayout.Width(26f));
}
else
{
UICamera uic = cam.GetComponent<UICamera>();
bool ev = (uic != null && uic.enabled);
if (ev != EditorGUILayout.Toggle(ev, GUILayout.Width(20f)))
{
if (uic == null) uic = cam.gameObject.AddComponent<UICamera>();
uic.enabled = !ev;
}
}
if (cam == null)
{
GUILayout.Label("Mask", GUILayout.Width(100f));
}
else
{
int mask = LayerMaskField(cam.cullingMask, GUILayout.Width(105f));
if (cam.cullingMask != mask)
{
NGUIEditorTools.RegisterUndo("Camera Mask Change", cam);
cam.cullingMask = mask;
}
}
}
GUILayout.EndHorizontal();
}
19
Source : UICreateNewUIWizard.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void OnGUI ()
{
EditorGUIUtility.LookLikeControls(80f);
GUILayout.Label("Create a new UI with the following parameters:");
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
NGUISettings.layer = EditorGUILayout.LayerField("Layer", NGUISettings.layer, GUILayout.Width(200f));
GUILayout.Space(20f);
GUILayout.Label("This is the layer your UI will reside on");
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
camType = (CameraType)EditorGUILayout.EnumPopup("Camera", camType, GUILayout.Width(200f));
GUILayout.Space(20f);
GUILayout.Label("Should this UI have a camera?");
GUILayout.EndHorizontal();
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("When ready,");
bool create = GUILayout.Button("Create Your UI", GUILayout.Width(120f));
GUILayout.EndHorizontal();
if (create) CreateNewUI();
}
19
Source : UICreateWidgetWizard.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void CreateScrollBar (GameObject go)
{
if (NGUISettings.atlas != null)
{
NGUIEditorTools.SpriteField("Background", "Sprite used for the background", NGUISettings.atlas, mScrollBG, OnScrollBG);
NGUIEditorTools.SpriteField("Foreground", "Sprite used for the foreground (thumb)", NGUISettings.atlas, mScrollFG, OnScrollFG);
GUILayout.BeginHorizontal();
UIScrollBar.Direction dir = (UIScrollBar.Direction)EditorGUILayout.EnumPopup("Direction", mScrollDir, GUILayout.Width(200f));
GUILayout.Space(20f);
GUILayout.Label("Add colliders?", GUILayout.Width(90f));
bool draggable = EditorGUILayout.Toggle(mScrollCL);
GUILayout.EndHorizontal();
if (mScrollCL != draggable || mScrollDir != dir)
{
mScrollCL = draggable;
mScrollDir = dir;
Save();
}
}
if (ShouldCreate(go, NGUISettings.atlas != null))
{
int depth = NGUITools.CalculateNextDepth(go);
go = NGUITools.AddChild(go);
go.name = "Scroll Bar";
UISprite bg = NGUITools.AddWidget<UISprite>(go);
bg.type = UISprite.Type.Sliced;
bg.name = "Background";
bg.depth = depth;
bg.atlas = NGUISettings.atlas;
bg.spriteName = mScrollBG;
bg.transform.localScale = new Vector3(400f + bg.border.x + bg.border.z, 14f + bg.border.y + bg.border.w, 1f);
bg.MakePixelPerfect();
UISprite fg = NGUITools.AddWidget<UISprite>(go);
fg.type = UISprite.Type.Sliced;
fg.name = "Foreground";
fg.atlas = NGUISettings.atlas;
fg.spriteName = mScrollFG;
UIScrollBar sb = go.AddComponent<UIScrollBar>();
sb.background = bg;
sb.foreground = fg;
sb.direction = mScrollDir;
sb.barSize = 0.3f;
sb.scrollValue = 0.3f;
sb.ForceUpdate();
if (mScrollCL)
{
NGUITools.AddWidgetCollider(bg.gameObject);
NGUITools.AddWidgetCollider(fg.gameObject);
}
Selection.activeGameObject = go;
}
}
19
Source : UICreateWidgetWizard.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void OnGUI ()
{
// Load the saved preferences
if (!mLoaded) { mLoaded = true; Load(); }
EditorGUIUtility.LookLikeControls(80f);
GameObject go = NGUIEditorTools.SelectedRoot();
if (go == null)
{
GUILayout.Label("You must create a UI first.");
if (GUILayout.Button("Open the New UI Wizard"))
{
EditorWindow.GetWindow<UICreateNewUIWizard>(false, "New UI", true);
}
}
else
{
GUILayout.Space(4f);
GUILayout.BeginHorizontal();
ComponentSelector.Draw<UIAtlas>(NGUISettings.atlas, OnSelectAtlas, GUILayout.Width(140f));
GUILayout.Label("Texture atlas used by widgets", GUILayout.MinWidth(10000f));
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
ComponentSelector.Draw<UIFont>(NGUISettings.font, OnSelectFont, GUILayout.Width(140f));
GUILayout.Label("Font used by labels", GUILayout.MinWidth(10000f));
GUILayout.EndHorizontal();
GUILayout.Space(-2f);
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
WidgetType wt = (WidgetType)EditorGUILayout.EnumPopup("Template", mType, GUILayout.Width(200f));
GUILayout.Space(20f);
GUILayout.Label("Select a widget template to use");
GUILayout.EndHorizontal();
if (mType != wt) { mType = wt; Save(); }
switch (mType)
{
case WidgetType.Label: CreateLabel(go); break;
case WidgetType.Sprite: CreateSprite(go, mSprite); break;
case WidgetType.Texture: CreateSimpleTexture(go); break;
case WidgetType.Button: CreateButton(go); break;
case WidgetType.ImageButton: CreateImageButton(go); break;
case WidgetType.Checkbox: CreateCheckbox(go); break;
case WidgetType.ProgressBar: CreateSlider(go, false); break;
case WidgetType.Slider: CreateSlider(go, true); break;
case WidgetType.Input: CreateInput(go); break;
case WidgetType.PopupList: CreatePopup(go, true); break;
case WidgetType.PopupMenu: CreatePopup(go, false); break;
case WidgetType.ScrollBar: CreateScrollBar(go); break;
}
}
}
19
Source : UIFontInspector.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
override public void OnInspectorGUI ()
{
mFont = target as UIFont;
EditorGUIUtility.LookLikeControls(80f);
NGUIEditorTools.DrawSeparator();
//Lindean
if (mFont.dynamicFont != null)
{
mType = FontType.Dynamic;
}
if (mFont.replacement != null)
{
mType = FontType.Reference;
mReplacement = mFont.replacement;
}
else if (mFont.dynamicFont_1 != null)
{
mType = FontType.Dynamic;
}
GUILayout.BeginHorizontal();
FontType fontType = (FontType)EditorGUILayout.EnumPopup("Font Type", mType);
GUILayout.Space(18f);
GUILayout.EndHorizontal();
if (mType != fontType)
{
if (fontType == FontType.Normal)
{
OnSelectFont(null);
}
else
{
mType = fontType;
}
//Lindean
if (mType != FontType.Dynamic && mFont.dynamicFont_1 != null)
mFont.dynamicFont_1 = null;
}
//Lindean
if (mType == FontType.Dynamic)
{
//Lindean - Draw settings for dynamic font
bool changed = false;
Font f = EditorGUILayout.ObjectField("Font", mFont.dynamicFont, typeof(Font), false) as Font;
if (f != mFont.dynamicFont)
{
mFont.dynamicFont = f;
changed = true;
}
Material mat = EditorGUILayout.ObjectField("Material", mFont.dynamicFontMaterial_1, typeof(Material), false) as Material;
if (mat != mFont.dynamicFontMaterial_1)
{
mFont.dynamicFontMaterial_1 = mat;
changed = true;
}
if (mFont.dynamicFontMaterial_1 == null)
GUILayout.Label("Warning: no coloring or clipping when using default font material");
int i = EditorGUILayout.IntField("Size", mFont.dynamicFontSize);
if (i != mFont.dynamicFontSize)
{
mFont.dynamicFontSize = i;
changed = true;
}
FontStyle style = (FontStyle)EditorGUILayout.EnumPopup("Style", mFont.dynamicFontStyle);
if (style != mFont.dynamicFontStyle)
{
mFont.dynamicFontStyle = style;
changed = true;
}
if (changed)
{
//force access to material property as it refreshes the texture replacedignment
Debug.Log("font changed...");
Material fontMat = mFont.material;
if (fontMat.mainTexture == null)
Debug.Log("font material texture issue...");
UIFont.OnFontRebuilt(mFont);
}
NGUIEditorTools.DrawSeparator();
// Font spacing
GUILayout.BeginHorizontal();
{
EditorGUIUtility.LookLikeControls(0f);
GUILayout.Label("Spacing", GUILayout.Width(60f));
GUILayout.Label("X", GUILayout.Width(12f));
int x = EditorGUILayout.IntField(mFont.horizontalSpacing);
GUILayout.Label("Y", GUILayout.Width(12f));
int y = EditorGUILayout.IntField(mFont.verticalSpacing);
EditorGUIUtility.LookLikeControls(80f);
if (mFont.horizontalSpacing != x || mFont.verticalSpacing != y)
{
NGUIEditorTools.RegisterUndo("Font Spacing", mFont);
mFont.horizontalSpacing = x;
mFont.verticalSpacing = y;
}
}
GUILayout.EndHorizontal();
}
//Lindean
if (mType == FontType.Reference)
{
ComponentSelector.Draw<UIFont>(mFont.replacement, OnSelectFont);
NGUIEditorTools.DrawSeparator();
GUILayout.Label("You can have one font simply point to\n" +
"another one. This is useful if you want to be\n" +
"able to quickly replace the contents of one\n" +
"font with another one, for example for\n" +
"swapping an SD font with an HD one, or\n" +
"replacing an English font with a Chinese\n" +
"one. All the labels referencing this font\n" +
"will update their references to the new one.");
if (mReplacement != mFont && mFont.replacement != mReplacement)
{
NGUIEditorTools.RegisterUndo("Font Change", mFont);
mFont.replacement = mReplacement;
UnityEditor.EditorUtility.SetDirty(mFont);
}
return;
}
else if (mType == FontType.Dynamic)
{
#if UNITY_3_5
EditorGUILayout.HelpBox("Dynamic fonts require Unity 4.0 or higher.", MessageType.Error);
#else
NGUIEditorTools.DrawSeparator();
Font fnt = EditorGUILayout.ObjectField("TTF Font", mFont.dynamicFont_1, typeof(Font), false) as Font;
if (fnt != mFont.dynamicFont_1)
{
NGUIEditorTools.RegisterUndo("Font change", mFont);
mFont.dynamicFont_1 = fnt;
}
GUILayout.BeginHorizontal();
int size = EditorGUILayout.IntField("Size", mFont.dynamicFontSize_1, GUILayout.Width(120f));
FontStyle style = (FontStyle)EditorGUILayout.EnumPopup(mFont.dynamicFontStyle_1);
GUILayout.Space(18f);
GUILayout.EndHorizontal();
if (size != mFont.dynamicFontSize_1)
{
NGUIEditorTools.RegisterUndo("Font change", mFont);
mFont.dynamicFontSize_1 = size;
}
if (style != mFont.dynamicFontStyle_1)
{
NGUIEditorTools.RegisterUndo("Font change", mFont);
mFont.dynamicFontStyle_1 = style;
}
Material mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material;
if (mFont.material != mat)
{
NGUIEditorTools.RegisterUndo("Font Material", mFont);
mFont.material = mat;
}
#endif
}
else
{
NGUIEditorTools.DrawSeparator();
ComponentSelector.Draw<UIAtlas>(mFont.atlas, OnSelectAtlas);
if (mFont.atlas != null)
{
if (mFont.bmFont.isValid)
{
NGUIEditorTools.AdvancedSpriteField(mFont.atlas, mFont.spriteName, SelectSprite, false);
}
EditorGUILayout.Space();
}
else
{
// No atlas specified -- set the material and texture rectangle directly
Material mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material;
if (mFont.material != mat)
{
NGUIEditorTools.RegisterUndo("Font Material", mFont);
mFont.material = mat;
}
}
// For updating the font's data when importing from an external source, such as the texture packer
bool resetWidthHeight = false;
if (mFont.atlas != null || mFont.material != null)
{
Textreplacedet data = EditorGUILayout.ObjectField("Import Data", null, typeof(Textreplacedet), false) as Textreplacedet;
if (data != null)
{
NGUIEditorTools.RegisterUndo("Import Font Data", mFont);
BMFontReader.Load(mFont.bmFont, NGUITools.GetHierarchy(mFont.gameObject), data.bytes);
mFont.MarkAsDirty();
resetWidthHeight = true;
Debug.Log("Imported " + mFont.bmFont.glyphCount + " characters");
}
}
if (mFont.bmFont.isValid)
{
Color green = new Color(0.4f, 1f, 0f, 1f);
Texture2D tex = mFont.texture;
if (tex != null)
{
if (mFont.atlas == null)
{
// Pixels are easier to work with than UVs
Rect pixels = NGUIMath.ConvertToPixels(mFont.uvRect, tex.width, tex.height, false);
// Automatically set the width and height of the rectangle to be the original font texture's dimensions
if (resetWidthHeight)
{
pixels.width = mFont.texWidth;
pixels.height = mFont.texHeight;
}
// Font sprite rectangle
GUI.backgroundColor = green;
pixels = EditorGUILayout.RectField("Pixel Rect", pixels);
GUI.backgroundColor = Color.white;
// Create a button that can make the coordinates pixel-perfect on click
GUILayout.BeginHorizontal();
{
Rect corrected = NGUIMath.MakePixelPerfect(pixels);
if (corrected == pixels)
{
GUI.color = Color.grey;
GUILayout.Button("Make Pixel-Perfect");
GUI.color = Color.white;
}
else if (GUILayout.Button("Make Pixel-Perfect"))
{
pixels = corrected;
GUI.changed = true;
}
}
GUILayout.EndHorizontal();
// Convert the pixel coordinates back to UV coordinates
Rect uvRect = NGUIMath.ConvertToTexCoords(pixels, tex.width, tex.height);
if (mFont.uvRect != uvRect)
{
NGUIEditorTools.RegisterUndo("Font Pixel Rect", mFont);
mFont.uvRect = uvRect;
}
//NGUIEditorTools.DrawSeparator();
EditorGUILayout.Space();
}
}
}
}
// The font must be valid at this point for the rest of the options to show up
if (mFont.isDynamic || mFont.bmFont.isValid)
{
// Font spacing
GUILayout.BeginHorizontal();
{
EditorGUIUtility.LookLikeControls(0f);
GUILayout.Label("Spacing", GUILayout.Width(60f));
GUILayout.Label("X", GUILayout.Width(12f));
int x = EditorGUILayout.IntField(mFont.horizontalSpacing);
GUILayout.Label("Y", GUILayout.Width(12f));
int y = EditorGUILayout.IntField(mFont.verticalSpacing);
GUILayout.Space(18f);
EditorGUIUtility.LookLikeControls(80f);
if (mFont.horizontalSpacing != x || mFont.verticalSpacing != y)
{
NGUIEditorTools.RegisterUndo("Font Spacing", mFont);
mFont.horizontalSpacing = x;
mFont.verticalSpacing = y;
}
}
GUILayout.EndHorizontal();
if (mFont.atlas == null)
{
mView = View.Font;
mUseShader = false;
float pixelSize = EditorGUILayout.FloatField("Pixel Size", mFont.pixelSize, GUILayout.Width(120f));
if (pixelSize != mFont.pixelSize)
{
NGUIEditorTools.RegisterUndo("Font Change", mFont);
mFont.pixelSize = pixelSize;
}
}
EditorGUILayout.Space();
}
// Preview option
if (!mFont.isDynamic && mFont.atlas != null)
{
GUILayout.BeginHorizontal();
{
mView = (View)EditorGUILayout.EnumPopup("Preview", mView);
GUILayout.Label("Shader", GUILayout.Width(45f));
mUseShader = EditorGUILayout.Toggle(mUseShader, GUILayout.Width(20f));
}
GUILayout.EndHorizontal();
}
// Dynamic fonts don't support emoticons
if (!mFont.isDynamic && mFont.bmFont.isValid)
{
if (mFont.atlas != null)
{
NGUIEditorTools.DrawHeader("Symbols and Emoticons");
List<BMSymbol> symbols = mFont.symbols;
for (int i = 0; i < symbols.Count; )
{
BMSymbol sym = symbols[i];
GUILayout.BeginHorizontal();
GUILayout.Label(sym.sequence, GUILayout.Width(40f));
if (NGUIEditorTools.SimpleSpriteField(mFont.atlas, sym.spriteName, ChangeSymbolSprite))
mSelectedSymbol = sym;
if (GUILayout.Button("Edit", GUILayout.Width(40f)))
{
if (mFont.atlas != null)
{
EditorPrefs.SetString("NGUI Selected Sprite", sym.spriteName);
NGUIEditorTools.Select(mFont.atlas.gameObject);
}
}
GUI.backgroundColor = Color.red;
if (GUILayout.Button("X", GUILayout.Width(22f)))
{
NGUIEditorTools.RegisterUndo("Remove symbol", mFont);
mSymbolSequence = sym.sequence;
mSymbolSprite = sym.spriteName;
symbols.Remove(sym);
mFont.MarkAsDirty();
}
GUI.backgroundColor = Color.white;
GUILayout.EndHorizontal();
GUILayout.Space(4f);
++i;
}
if (symbols.Count > 0)
{
NGUIEditorTools.DrawSeparator();
}
GUILayout.BeginHorizontal();
mSymbolSequence = EditorGUILayout.TextField(mSymbolSequence, GUILayout.Width(40f));
NGUIEditorTools.SimpleSpriteField(mFont.atlas, mSymbolSprite, SelectSymbolSprite);
bool isValid = !string.IsNullOrEmpty(mSymbolSequence) && !string.IsNullOrEmpty(mSymbolSprite);
GUI.backgroundColor = isValid ? Color.green : Color.grey;
if (GUILayout.Button("Add", GUILayout.Width(40f)) && isValid)
{
NGUIEditorTools.RegisterUndo("Add symbol", mFont);
mFont.AddSymbol(mSymbolSequence, mSymbolSprite);
mFont.MarkAsDirty();
mSymbolSequence = "";
mSymbolSprite = "";
}
GUI.backgroundColor = Color.white;
GUILayout.EndHorizontal();
if (symbols.Count == 0)
{
EditorGUILayout.HelpBox("Want to add an emoticon to your font? In the field above type ':)', choose a sprite, then hit the Add button.", MessageType.Info);
}
else GUILayout.Space(4f);
}
}
}
19
Source : UIFontMaker.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void OnGUI ()
{
string prefabPath = "";
string matPath = "";
if (NGUISettings.font != null && NGUISettings.font.name == NGUISettings.fontName)
{
prefabPath = replacedetDatabase.GetreplacedetPath(NGUISettings.font.gameObject.GetInstanceID());
if (NGUISettings.font.material != null) matPath = replacedetDatabase.GetreplacedetPath(NGUISettings.font.material.GetInstanceID());
}
// replacedume default values if needed
if (string.IsNullOrEmpty(NGUISettings.fontName)) NGUISettings.fontName = "New Font";
if (string.IsNullOrEmpty(prefabPath)) prefabPath = NGUIEditorTools.GetSelectionFolder() + NGUISettings.fontName + ".prefab";
if (string.IsNullOrEmpty(matPath)) matPath = NGUIEditorTools.GetSelectionFolder() + NGUISettings.fontName + ".mat";
EditorGUIUtility.LookLikeControls(80f);
NGUIEditorTools.DrawHeader("Input");
GUILayout.BeginHorizontal();
mType = (FontType)EditorGUILayout.EnumPopup("Type", mType);
GUILayout.Space(18f);
GUILayout.EndHorizontal();
int create = 0;
if (mType == FontType.Dynamic)
{
NGUISettings.dynamicFont = EditorGUILayout.ObjectField("Font TTF", NGUISettings.dynamicFont, typeof(Font), false) as Font;
GUILayout.BeginHorizontal();
NGUISettings.dynamicFontSize = EditorGUILayout.IntField("Font Size", NGUISettings.dynamicFontSize, GUILayout.Width(120f));
NGUISettings.dynamicFontStyle = (FontStyle)EditorGUILayout.EnumPopup(NGUISettings.dynamicFontStyle);
GUILayout.Space(18f);
GUILayout.EndHorizontal();
if (NGUISettings.dynamicFont != null)
{
NGUIEditorTools.DrawHeader("Output");
GUILayout.BeginHorizontal();
GUILayout.Label("Font Name", GUILayout.Width(76f));
GUI.backgroundColor = Color.white;
NGUISettings.fontName = GUILayout.TextField(NGUISettings.fontName);
GUILayout.EndHorizontal();
}
NGUIEditorTools.DrawSeparator();
#if UNITY_3_5
EditorGUILayout.HelpBox("Dynamic fonts require Unity 4.0 or higher.", MessageType.Error);
#else
// Helpful info
if (NGUISettings.dynamicFont == null)
{
EditorGUILayout.HelpBox("Dynamic font creation happens right in Unity. Simply specify the TrueType font to be used as source.", MessageType.Info);
}
EditorGUILayout.HelpBox("Please note that dynamic fonts can't be made a part of an atlas, and they will always be drawn in a separate draw call. You WILL need to adjust transform position's Z rather than depth!", MessageType.Warning);
if (NGUISettings.dynamicFont != null)
{
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.backgroundColor = Color.green;
GameObject go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
if (go != null)
{
if (go.GetComponent<UIFont>() != null)
{
GUI.backgroundColor = Color.red;
if (GUILayout.Button("Replace the Font", GUILayout.Width(140f))) create = 1;
}
else
{
GUI.backgroundColor = Color.grey;
GUILayout.Button("Rename Your Font", GUILayout.Width(140f));
}
}
else
{
GUI.backgroundColor = Color.green;
if (GUILayout.Button("Create the Font", GUILayout.Width(140f))) create = 1;
}
GUI.backgroundColor = Color.white;
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
#endif
}
else
{
NGUISettings.fontData = EditorGUILayout.ObjectField("Font Data", NGUISettings.fontData, typeof(Textreplacedet), false) as Textreplacedet;
NGUISettings.fontTexture = EditorGUILayout.ObjectField("Texture", NGUISettings.fontTexture, typeof(Texture2D), false) as Texture2D;
// Draw the atlas selection only if we have the font data and texture specified, just to make it easier
if (NGUISettings.fontData != null && NGUISettings.fontTexture != null)
{
NGUIEditorTools.DrawHeader("Output");
GUILayout.BeginHorizontal();
GUILayout.Label("Font Name", GUILayout.Width(76f));
GUI.backgroundColor = Color.white;
NGUISettings.fontName = GUILayout.TextField(NGUISettings.fontName);
GUILayout.EndHorizontal();
ComponentSelector.Draw<UIFont>("Select", NGUISettings.font, OnSelectFont);
ComponentSelector.Draw<UIAtlas>(NGUISettings.atlas, OnSelectAtlas);
}
NGUIEditorTools.DrawSeparator();
// Helpful info
if (NGUISettings.fontData == null)
{
EditorGUILayout.HelpBox("The bitmap font creation mostly takes place outside of Unity. You can use BMFont on" +
"Windows or your choice of Glyph Designer or the less expensive bmGlyph on the Mac.\n\n" +
"Either of these tools will create a FNT file for you that you will drag & drop into the field above.", MessageType.Info);
}
else if (NGUISettings.fontTexture == null)
{
EditorGUILayout.HelpBox("When exporting your font, you should get two files: the TXT, and the texture. Only one texture can be used per font.", MessageType.Info);
}
else if (NGUISettings.atlas == null)
{
EditorGUILayout.HelpBox("You can create a font that doesn't use a texture atlas. This will mean that the text " +
"labels using this font will generate an extra draw call, and will need to be sorted by " +
"adjusting the Z instead of the Depth.\n\nIf you do specify an atlas, the font's texture will be added to it automatically.", MessageType.Info);
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.backgroundColor = Color.red;
if (GUILayout.Button("Create a Font without an Atlas", GUILayout.Width(200f))) create = 2;
GUI.backgroundColor = Color.white;
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
else
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GameObject go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
if (go != null)
{
if (go.GetComponent<UIFont>() != null)
{
GUI.backgroundColor = Color.red;
if (GUILayout.Button("Replace the Font", GUILayout.Width(140f))) create = 3;
}
else
{
GUI.backgroundColor = Color.grey;
GUILayout.Button("Rename Your Font", GUILayout.Width(140f));
}
}
else
{
GUI.backgroundColor = Color.green;
if (GUILayout.Button("Create the Font", GUILayout.Width(140f))) create = 3;
}
GUI.backgroundColor = Color.white;
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
}
if (create != 0)
{
GameObject go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
if (go == null || EditorUtility.DisplayDialog("Are you sure?", "Are you sure you want to replace the contents of the " +
NGUISettings.fontName + " font with the currently selected values? This action can't be undone.", "Yes", "No"))
{
// Try to load the material
Material mat = null;
// Non-atlased font
if (create == 2)
{
mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;
// If the material doesn't exist, create it
if (mat == null)
{
Shader shader = Shader.Find("Unlit/Transparent Colored");
mat = new Material(shader);
// Save the material
replacedetDatabase.Createreplacedet(mat, matPath);
replacedetDatabase.Refresh();
// Load the material so it's usable
mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;
}
mat.mainTexture = NGUISettings.fontTexture;
}
// Font doesn't exist yet
if (go == null || go.GetComponent<UIFont>() == null)
{
// Create a new prefab for the atlas
Object prefab = CreateEmptyPrefab(prefabPath);
// Create a new game object for the font
go = new GameObject(NGUISettings.fontName);
NGUISettings.font = go.AddComponent<UIFont>();
CreateFont(NGUISettings.font, create, mat);
// Update the prefab
ReplacePrefab(go, prefab);
DestroyImmediate(go);
replacedetDatabase.Refresh();
// Select the atlas
go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
NGUISettings.font = go.GetComponent<UIFont>();
}
else
{
NGUISettings.font = go.GetComponent<UIFont>();
CreateFont(NGUISettings.font, create, mat);
}
MarkAsChanged();
}
}
}
19
Source : UIPanelInspector.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
public override void OnInspectorGUI ()
{
UIPanel panel = target as UIPanel;
BetterList<UIDrawCall> drawcalls = panel.drawCalls;
EditorGUIUtility.LookLikeControls(80f);
//NGUIEditorTools.DrawSeparator();
EditorGUILayout.Space();
float alpha = EditorGUILayout.Slider("Alpha", panel.alpha, 0f, 1f);
if (alpha != panel.alpha)
{
NGUIEditorTools.RegisterUndo("Panel Alpha", panel);
panel.alpha = alpha;
}
if (panel.showInPanelTool != EditorGUILayout.Toggle("Panel Tool", panel.showInPanelTool))
{
panel.showInPanelTool = !panel.showInPanelTool;
EditorUtility.SetDirty(panel);
EditorWindow.FocusWindowIfItsOpen<UIPanelTool>();
}
panel.isTop = EditorGUILayout.Toggle("IsTop",panel.isTop);
panel.isLeft = EditorGUILayout.Toggle("IsLeft",panel.isLeft);
GUILayout.BeginHorizontal();
bool norms = EditorGUILayout.Toggle("Normals", panel.generateNormals, GUILayout.Width(100f));
GUILayout.Label("Needed for lit shaders");
GUILayout.EndHorizontal();
if (panel.generateNormals != norms)
{
panel.generateNormals = norms;
panel.UpdateDrawcalls();
EditorUtility.SetDirty(panel);
}
GUILayout.BeginHorizontal();
bool depth = EditorGUILayout.Toggle("Depth Preplaced", panel.depthPreplaced, GUILayout.Width(100f));
GUILayout.Label("Doubles draw calls, saves fillrate");
GUILayout.EndHorizontal();
if (panel.depthPreplaced != depth)
{
panel.depthPreplaced = depth;
panel.UpdateDrawcalls();
EditorUtility.SetDirty(panel);
}
if (depth)
{
UICamera cam = UICamera.FindCameraForLayer(panel.gameObject.layer);
if (cam == null || cam.GetComponent<Camera>().orthographic)
{
EditorGUILayout.HelpBox("Please note that depth preplaced will only save fillrate when used with 3D UIs, and only UIs drawn by the game camera. If you are using a separate camera for the UI, you will not see any benefit!", MessageType.Warning);
}
}
GUILayout.BeginHorizontal();
bool stat = EditorGUILayout.Toggle("Static", panel.widgetsAreStatic, GUILayout.Width(100f));
GUILayout.Label("Check if widgets won't move");
GUILayout.EndHorizontal();
if (panel.widgetsAreStatic != stat)
{
panel.widgetsAreStatic = stat;
panel.UpdateDrawcalls();
EditorUtility.SetDirty(panel);
}
EditorGUILayout.LabelField("Widgets", panel.widgets.size.ToString());
EditorGUILayout.LabelField("Draw Calls", drawcalls.size.ToString());
UIPanel.DebugInfo di = (UIPanel.DebugInfo)EditorGUILayout.EnumPopup("Debug Info", panel.debugInfo);
if (panel.debugInfo != di)
{
panel.debugInfo = di;
EditorUtility.SetDirty(panel);
}
UIDrawCall.Clipping clipping = (UIDrawCall.Clipping)EditorGUILayout.EnumPopup("Clipping", panel.clipping);
if (panel.clipping != clipping)
{
panel.clipping = clipping;
EditorUtility.SetDirty(panel);
}
if (panel.clipping != UIDrawCall.Clipping.None)
{
Vector4 range = panel.clipRange;
GUILayout.BeginHorizontal();
GUILayout.Space(80f);
Vector2 pos = EditorGUILayout.Vector2Field("Center", new Vector2(range.x, range.y));
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Space(80f);
Vector2 size = EditorGUILayout.Vector2Field("Size", new Vector2(range.z, range.w));
GUILayout.EndHorizontal();
if (size.x < 0f) size.x = 0f;
if (size.y < 0f) size.y = 0f;
range.x = pos.x;
range.y = pos.y;
range.z = size.x;
range.w = size.y;
if (panel.clipRange != range)
{
NGUIEditorTools.RegisterUndo("Clipping Change", panel);
panel.clipRange = range;
EditorUtility.SetDirty(panel);
}
if (panel.clipping == UIDrawCall.Clipping.SoftClip)
{
GUILayout.BeginHorizontal();
GUILayout.Space(80f);
Vector2 soft = EditorGUILayout.Vector2Field("Softness", panel.clipSoftness);
GUILayout.EndHorizontal();
if (soft.x < 1f) soft.x = 1f;
if (soft.y < 1f) soft.y = 1f;
if (panel.clipSoftness != soft)
{
NGUIEditorTools.RegisterUndo("Clipping Change", panel);
panel.clipSoftness = soft;
EditorUtility.SetDirty(panel);
}
}
#if UNITY_ANDROID || UNITY_IPHONE
if (PlayerSettings.targetGlesGraphics == TargetGlesGraphics.OpenGLES_1_x)
{
EditorGUILayout.HelpBox("Clipping requires shader support!\n\nOpen File -> Build Settings -> Player Settings -> Other Settings, then set:\n\n- Graphics Level: OpenGL ES 2.0.", MessageType.Error);
}
#endif
}
if (clipping == UIDrawCall.Clipping.HardClip)
{
EditorGUILayout.HelpBox("Hard clipping has been removed due to major performance issues on certain Android devices. Alpha clipping will be used instead.", MessageType.Warning);
}
if (clipping != UIDrawCall.Clipping.None && !NGUIEditorTools.IsUniform(panel.transform.lossyScale))
{
EditorGUILayout.HelpBox("Clipped panels must have a uniform scale, or clipping won't work properly!", MessageType.Error);
if (GUILayout.Button("Auto-fix"))
{
NGUIEditorTools.FixUniform(panel.gameObject);
}
}
foreach (UIDrawCall dc in drawcalls)
{
NGUIEditorTools.DrawSeparator();
EditorGUILayout.ObjectField("Material", dc.material, typeof(Material), false);
EditorGUILayout.LabelField("Triangles", dc.triangles.ToString());
if (clipping != UIDrawCall.Clipping.None && !dc.isClipped)
{
EditorGUILayout.HelpBox("You must switch this material's shader to Unlit/Transparent Colored or Unlit/Premultiplied Colored in order for clipping to work.",
MessageType.Warning);
}
}
}
19
Source : UIPopupListInspector.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
public override void OnInspectorGUI ()
{
EditorGUIUtility.LookLikeControls(80f);
mList = target as UIPopupList;
ComponentSelector.Draw<UIAtlas>(mList.atlas, OnSelectAtlas);
ComponentSelector.Draw<UIFont>(mList.font, OnSelectFont);
GUILayout.BeginHorizontal();
UILabel lbl = EditorGUILayout.ObjectField("Text Label", mList.textLabel, typeof(UILabel), true) as UILabel;
if (mList.textLabel != lbl)
{
RegisterUndo();
mList.textLabel = lbl;
if (lbl != null) lbl.text = mList.selection;
}
GUILayout.Space(44f);
GUILayout.EndHorizontal();
if (mList.atlas != null)
{
NGUIEditorTools.SpriteField("Background", mList.atlas, mList.backgroundSprite, OnBackground);
NGUIEditorTools.SpriteField("Highlight", mList.atlas, mList.highlightSprite, OnHighlight);
GUILayout.BeginHorizontal();
GUILayout.Space(6f);
GUILayout.Label("Options");
GUILayout.EndHorizontal();
string text = "";
foreach (string s in mList.items) text += s + "\n";
GUILayout.Space(-14f);
GUILayout.BeginHorizontal();
GUILayout.Space(84f);
string modified = EditorGUILayout.TextArea(text, GUILayout.Height(100f));
GUILayout.EndHorizontal();
if (modified != text)
{
RegisterUndo();
string[] split = modified.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries);
mList.items.Clear();
foreach (string s in split) mList.items.Add(s);
if (string.IsNullOrEmpty(mList.selection) || !mList.items.Contains(mList.selection))
{
mList.selection = mList.items.Count > 0 ? mList.items[0] : "";
}
}
string sel = NGUIEditorTools.DrawList("Selection", mList.items.ToArray(), mList.selection);
if (mList.selection != sel)
{
RegisterUndo();
mList.selection = sel;
}
UIPopupList.Position pos = (UIPopupList.Position)EditorGUILayout.EnumPopup("Position", mList.position);
if (mList.position != pos)
{
RegisterUndo();
mList.position = pos;
}
float ts = EditorGUILayout.FloatField("Text Scale", mList.textScale);
Color tc = EditorGUILayout.ColorField("Text Color", mList.textColor);
Color bc = EditorGUILayout.ColorField("Background", mList.backgroundColor);
Color hc = EditorGUILayout.ColorField("Highlight", mList.highlightColor);
GUILayout.BeginHorizontal();
bool isLocalized = EditorGUILayout.Toggle("Localized", mList.isLocalized, GUILayout.Width(100f));
bool isAnimated = EditorGUILayout.Toggle("Animated", mList.isAnimated);
GUILayout.EndHorizontal();
if (mList.textScale != ts ||
mList.textColor != tc ||
mList.highlightColor != hc ||
mList.backgroundColor != bc ||
mList.isLocalized != isLocalized ||
mList.isAnimated != isAnimated)
{
RegisterUndo();
mList.textScale = ts;
mList.textColor = tc;
mList.backgroundColor = bc;
mList.highlightColor = hc;
mList.isLocalized = isLocalized;
mList.isAnimated = isAnimated;
}
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
GUILayout.Space(6f);
GUILayout.Label("Padding", GUILayout.Width(76f));
GUILayout.BeginVertical();
GUILayout.Space(-12f);
Vector2 padding = EditorGUILayout.Vector2Field("", mList.padding);
GUILayout.EndVertical();
GUILayout.EndHorizontal();
if (mList.padding != padding)
{
RegisterUndo();
mList.padding = padding;
}
EditorGUIUtility.LookLikeControls(100f);
GameObject go = EditorGUILayout.ObjectField("Event Receiver", mList.eventReceiver,
typeof(GameObject), true) as GameObject;
string fn = EditorGUILayout.TextField("Function Name", mList.functionName);
if (mList.eventReceiver != go || mList.functionName != fn)
{
RegisterUndo();
mList.eventReceiver = go;
mList.functionName = fn;
}
}
}
19
Source : UISliderInspector.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void ValidatePivot (Transform fg, string name, UISlider.Direction dir)
{
if (fg != null)
{
UISprite sprite = fg.GetComponent<UISprite>();
if (sprite != null && sprite.type != UISprite.Type.Filled)
{
if (dir == UISlider.Direction.Horizontal)
{
if (sprite.pivot != UIWidget.Pivot.Left &&
sprite.pivot != UIWidget.Pivot.TopLeft &&
sprite.pivot != UIWidget.Pivot.BottomLeft)
{
GUI.color = new Color(1f, 0.7f, 0f);
GUILayout.Label(name + " should use a Left pivot");
GUI.color = Color.white;
}
}
else if (sprite.pivot != UIWidget.Pivot.BottomLeft &&
sprite.pivot != UIWidget.Pivot.Bottom &&
sprite.pivot != UIWidget.Pivot.BottomRight)
{
GUI.color = new Color(1f, 0.7f, 0f);
GUILayout.Label(name + " should use a Bottom pivot");
GUI.color = Color.white;
}
}
}
}
19
Source : AntialiasingEditor.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
public override void OnInspectorGUI()
{
serObj.Update();
GUILayout.Label("Luminance based fullscreen antialiasing", EditorStyles.miniBoldLabel);
EditorGUILayout.PropertyField(mode, new GUIContent("Technique"));
Material mat = (target as Antialiasing).CurrentAAMaterial();
if (null == mat && (target as Antialiasing).enabled)
{
EditorGUILayout.HelpBox("This AA technique is currently not supported. Choose a different technique or disable the effect and use MSAA instead.", MessageType.Warning);
}
if (mode.enumValueIndex == (int) AAMode.NFAA)
{
EditorGUILayout.PropertyField(offsetScale, new GUIContent("Edge Detect Ofs"));
EditorGUILayout.PropertyField(blurRadius, new GUIContent("Blur Radius"));
EditorGUILayout.PropertyField(showGeneratedNormals, new GUIContent("Show Normals"));
}
else if (mode.enumValueIndex == (int) AAMode.DLAA)
{
EditorGUILayout.PropertyField(dlaaSharp, new GUIContent("Sharp"));
}
else if (mode.enumValueIndex == (int) AAMode.FXAA3Console)
{
EditorGUILayout.PropertyField(edgeThresholdMin, new GUIContent("Edge Min Threshhold"));
EditorGUILayout.PropertyField(edgeThreshold, new GUIContent("Edge Threshhold"));
EditorGUILayout.PropertyField(edgeSharpness, new GUIContent("Edge Sharpness"));
}
serObj.ApplyModifiedProperties();
}
19
Source : BloomAndFlaresEditor.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
public override void OnInspectorGUI () {
serObj.Update();
GUILayout.Label("HDR " + (hdr.enumValueIndex == 0 ? "auto detected, " : (hdr.enumValueIndex == 1 ? "forced on, " : "disabled, ")) + (useSrcAlphaAsMask.floatValue < 0.1f ? " ignoring alpha channel glow information" : " using alpha channel glow information"), EditorStyles.miniBoldLabel);
EditorGUILayout.PropertyField (tweakMode, new GUIContent("Tweak mode"));
EditorGUILayout.PropertyField (screenBlendMode, new GUIContent("Blend mode"));
EditorGUILayout.PropertyField (hdr, new GUIContent("HDR"));
// display info text when screen blend mode cannot be used
Camera cam = (target as BloomAndFlares).GetComponent<Camera>();
if (cam != null) {
if (screenBlendMode.enumValueIndex==0 && ((cam.allowHDR && hdr.enumValueIndex==0) || (hdr.enumValueIndex==1))) {
EditorGUILayout.HelpBox("Screen blend is not supported in HDR. Using 'Add' instead.", MessageType.Info);
}
}
if (1 == tweakMode.intValue)
EditorGUILayout.PropertyField (lensflares, new GUIContent("Cast lens flares"));
EditorGUILayout.Separator ();
EditorGUILayout.PropertyField (bloomIntensity, new GUIContent("Intensity"));
bloomthreshold.floatValue = EditorGUILayout.Slider ("threshold", bloomthreshold.floatValue, -0.05f, 4.0f);
bloomBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", bloomBlurIterations.intValue, 1, 4);
sepBlurSpread.floatValue = EditorGUILayout.Slider ("Blur spread", sepBlurSpread.floatValue, 0.1f, 10.0f);
if (1 == tweakMode.intValue)
useSrcAlphaAsMask.floatValue = EditorGUILayout.Slider (new GUIContent("Use alpha mask", "Make alpha channel define glowiness"), useSrcAlphaAsMask.floatValue, 0.0f, 1.0f);
else
useSrcAlphaAsMask.floatValue = 0.0f;
if (1 == tweakMode.intValue) {
EditorGUILayout.Separator ();
if (lensflares.boolValue) {
// further lens flare tweakings
if (0 != tweakMode.intValue)
EditorGUILayout.PropertyField (lensflareMode, new GUIContent("Lens flare mode"));
else
lensflareMode.enumValueIndex = 0;
EditorGUILayout.PropertyField(lensFlareVignetteMask, new GUIContent("Lens flare mask", "This mask is needed to prevent lens flare artifacts"));
EditorGUILayout.PropertyField (lensflareIntensity, new GUIContent("Local intensity"));
lensflarethreshold.floatValue = EditorGUILayout.Slider ("Local threshold", lensflarethreshold.floatValue, 0.0f, 1.0f);
if (lensflareMode.intValue == 0) {
// ghosting
EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorA, new GUIContent("1st Color"));
EditorGUILayout.PropertyField (flareColorB, new GUIContent("2nd Color"));
EditorGUILayout.EndHorizontal ();
EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorC, new GUIContent("3rd Color"));
EditorGUILayout.PropertyField (flareColorD, new GUIContent("4th Color"));
EditorGUILayout.EndHorizontal ();
}
else if (lensflareMode.intValue == 1) {
// hollywood
EditorGUILayout.PropertyField (hollyStretchWidth, new GUIContent("Stretch width"));
hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", hollywoodFlareBlurIterations.intValue, 1, 4);
EditorGUILayout.PropertyField (flareColorA, new GUIContent("Tint Color"));
}
else if (lensflareMode.intValue == 2) {
// both
EditorGUILayout.PropertyField (hollyStretchWidth, new GUIContent("Stretch width"));
hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", hollywoodFlareBlurIterations.intValue, 1, 4);
EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorA, new GUIContent("1st Color"));
EditorGUILayout.PropertyField (flareColorB, new GUIContent("2nd Color"));
EditorGUILayout.EndHorizontal ();
EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorC, new GUIContent("3rd Color"));
EditorGUILayout.PropertyField (flareColorD, new GUIContent("4th Color"));
EditorGUILayout.EndHorizontal ();
}
}
} else
lensflares.boolValue = false; // disable lens flares in simple tweak mode
serObj.ApplyModifiedProperties();
}
19
Source : EdgeDetectionEditor.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
public override void OnInspectorGUI () {
serObj.Update ();
GUILayout.Label("Detects spatial differences and converts into black outlines", EditorStyles.miniBoldLabel);
EditorGUILayout.PropertyField (mode, new GUIContent("Mode"));
if (mode.intValue < 2) {
EditorGUILayout.PropertyField (sensitivityDepth, new GUIContent(" Depth Sensitivity"));
EditorGUILayout.PropertyField (sensitivityNormals, new GUIContent(" Normals Sensitivity"));
}
else if (mode.intValue < 4) {
EditorGUILayout.PropertyField (edgeExp, new GUIContent(" Edge Exponent"));
}
else {
// lum based mode
EditorGUILayout.PropertyField (lumThreshold, new GUIContent(" Luminance Threshold"));
}
EditorGUILayout.PropertyField (sampleDist, new GUIContent(" Sample Distance"));
EditorGUILayout.Separator ();
GUILayout.Label ("Background Options");
edgesOnly.floatValue = EditorGUILayout.Slider (" Edges only", edgesOnly.floatValue, 0.0f, 1.0f);
EditorGUILayout.PropertyField (edgesOnlyBgColor, new GUIContent (" Color"));
serObj.ApplyModifiedProperties();
}
19
Source : SunShaftsEditor.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
public override void OnInspectorGUI () {
serObj.Update ();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField (useDepthTexture, new GUIContent ("Rely on Z Buffer?"));
if ((target as SunShafts).GetComponent<Camera>())
GUILayout.Label("Current camera mode: "+ (target as SunShafts).GetComponent<Camera>().depthTextureMode, EditorStyles.miniBoldLabel);
EditorGUILayout.EndHorizontal();
// depth buffer need
/*
bool newVal = useDepthTexture.boolValue;
if (newVal != oldVal) {
if (newVal)
(target as SunShafts).camera.depthTextureMode |= DepthTextureMode.Depth;
else
(target as SunShafts).camera.depthTextureMode &= ~DepthTextureMode.Depth;
}
*/
EditorGUILayout.PropertyField (resolution, new GUIContent("Resolution"));
EditorGUILayout.PropertyField (screenBlendMode, new GUIContent("Blend mode"));
EditorGUILayout.Separator ();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField (sunTransform, new GUIContent("Shafts caster", "Chose a transform that acts as a root point for the produced sun shafts"));
if ((target as SunShafts).sunTransform && (target as SunShafts).GetComponent<Camera>()) {
if (GUILayout.Button("Center on " + (target as SunShafts).GetComponent<Camera>().name)) {
if (EditorUtility.DisplayDialog ("Move sun shafts source?", "The SunShafts caster named "+ (target as SunShafts).sunTransform.name +"\n will be centered along "+(target as SunShafts).GetComponent<Camera>().name+". Are you sure? ", "Please do", "Don't")) {
Ray ray = (target as SunShafts).GetComponent<Camera>().ViewportPointToRay(new Vector3(0.5f,0.5f,0));
(target as SunShafts).sunTransform.position = ray.origin + ray.direction * 500.0f;
(target as SunShafts).sunTransform.LookAt ((target as SunShafts).transform);
}
}
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.Separator ();
EditorGUILayout.PropertyField (sunThreshold, new GUIContent ("Threshold color"));
EditorGUILayout.PropertyField (sunColor, new GUIContent ("Shafts color"));
maxRadius.floatValue = 1.0f - EditorGUILayout.Slider ("Distance falloff", 1.0f - maxRadius.floatValue, 0.1f, 1.0f);
EditorGUILayout.Separator ();
sunShaftBlurRadius.floatValue = EditorGUILayout.Slider ("Blur size", sunShaftBlurRadius.floatValue, 1.0f, 10.0f);
radialBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", radialBlurIterations.intValue, 1, 3);
EditorGUILayout.Separator ();
EditorGUILayout.PropertyField (sunShaftIntensity, new GUIContent("Intensity"));
serObj.ApplyModifiedProperties();
}
19
Source : TonemappingEditor.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
public override void OnInspectorGUI () {
serObj.Update ();
GUILayout.Label("Mapping HDR to LDR ranges since 1982", EditorStyles.miniLabel);
Camera cam = (target as Tonemapping).GetComponent<Camera>();
if (cam != null) {
if (!cam.allowHDR) {
EditorGUILayout.HelpBox("The camera is not HDR enabled. This will likely break the Tonemapper.", MessageType.Warning);
}
else if (!(target as Tonemapping).validRenderTextureFormat) {
EditorGUILayout.HelpBox("The input to Tonemapper is not in HDR. Make sure that all effects prior to this are executed in HDR.", MessageType.Warning);
}
}
EditorGUILayout.PropertyField (type, new GUIContent ("Technique"));
if (type.enumValueIndex == (int) Tonemapping.TonemapperType.UserCurve) {
EditorGUILayout.PropertyField (remapCurve, new GUIContent ("Remap curve", "Specify the mapping of luminances yourself"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.SimpleReinhard) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.Hable) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.Photographic) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.OptimizedHejiDawson) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.AdaptiveReinhard) {
EditorGUILayout.PropertyField (middleGrey, new GUIContent ("Middle grey", "Middle grey defines the average luminance thus brightening or darkening the entire image."));
EditorGUILayout.PropertyField (white, new GUIContent ("White", "Smallest luminance value that will be mapped to white"));
EditorGUILayout.PropertyField (adaptionSpeed, new GUIContent ("Adaption Speed", "Speed modifier for the automatic adaption"));
EditorGUILayout.PropertyField (adaptiveTextureSize, new GUIContent ("Texture size", "Defines the amount of downsamples needed."));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.AdaptiveReinhardAutoWhite) {
EditorGUILayout.PropertyField (middleGrey, new GUIContent ("Middle grey", "Middle grey defines the average luminance thus brightening or darkening the entire image."));
EditorGUILayout.PropertyField (adaptionSpeed, new GUIContent ("Adaption Speed", "Speed modifier for the automatic adaption"));
EditorGUILayout.PropertyField (adaptiveTextureSize, new GUIContent ("Texture size", "Defines the amount of downsamples needed."));
}
GUILayout.Label("All following effects will use LDR color buffers", EditorStyles.miniBoldLabel);
serObj.ApplyModifiedProperties();
}
19
Source : CheckResources.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void ListTextures ()
{
textureListScrollPos = EditorGUILayout.BeginScrollView (textureListScrollPos);
foreach (TextureDetails tDetails in ActiveTextures) {
GUILayout.BeginHorizontal ();
GUILayout.Box (tDetails.texture, GUILayout.Width (ThumbnailWidth), GUILayout.Height (ThumbnailHeight));
if (GUILayout.Button (tDetails.texture.name, GUILayout.Width (150))) {
SelectObject (tDetails.texture, ctrlPressed);
}
string sizeLabel = "" + tDetails.texture.width + "x" + tDetails.texture.height;
if (tDetails.isCubeMap)
sizeLabel += "x6";
sizeLabel += " - " + tDetails.mipMapCount + "mip";
sizeLabel += "\n" + FormatSizeString (tDetails.memSizeKB) + " - " + tDetails.format + "";
GUILayout.Label (sizeLabel, GUILayout.Width (120));
if (GUILayout.Button (tDetails.FoundInMaterials.Count + " Mat", GUILayout.Width (50))) {
SelectObjects (tDetails.FoundInMaterials, ctrlPressed);
}
if (GUILayout.Button (tDetails.FoundInRenderers.Count + " GO", GUILayout.Width (50))) {
List<Object> FoundObjects = new List<Object> ();
foreach (Renderer renderer in tDetails.FoundInRenderers)
FoundObjects.Add (renderer.gameObject);
SelectObjects (FoundObjects, ctrlPressed);
}
GUILayout.EndHorizontal ();
}
if (ActiveTextures.Count > 0) {
GUILayout.BeginHorizontal ();
GUILayout.Box (" ", GUILayout.Width (ThumbnailWidth), GUILayout.Height (ThumbnailHeight));
if (GUILayout.Button ("Select All", GUILayout.Width (150))) {
List<Object> AllTextures = new List<Object> ();
foreach (TextureDetails tDetails in ActiveTextures)
AllTextures.Add (tDetails.texture);
SelectObjects (AllTextures, ctrlPressed);
}
EditorGUILayout.EndHorizontal ();
}
EditorGUILayout.EndScrollView ();
}
19
Source : CheckResources.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void ListMaterials ()
{
materialListScrollPos = EditorGUILayout.BeginScrollView (materialListScrollPos);
foreach (MaterialDetails tDetails in ActiveMaterials) {
if (tDetails.material != null) {
GUILayout.BeginHorizontal ();
if (tDetails.material.mainTexture != null)
GUILayout.Box (tDetails.material.mainTexture, GUILayout.Width (ThumbnailWidth), GUILayout.Height (ThumbnailHeight));
else {
GUILayout.Box ("n/a", GUILayout.Width (ThumbnailWidth), GUILayout.Height (ThumbnailHeight));
}
if (GUILayout.Button (tDetails.material.name, GUILayout.Width (150))) {
SelectObject (tDetails.material, ctrlPressed);
}
string shaderLabel = tDetails.material.shader != null ? tDetails.material.shader.name : "no shader";
GUILayout.Label (shaderLabel, GUILayout.Width (200));
if (GUILayout.Button (tDetails.FoundInRenderers.Count + " GO", GUILayout.Width (50))) {
List<Object> FoundObjects = new List<Object> ();
foreach (Renderer renderer in tDetails.FoundInRenderers)
FoundObjects.Add (renderer.gameObject);
SelectObjects (FoundObjects, ctrlPressed);
}
GUILayout.EndHorizontal ();
}
}
EditorGUILayout.EndScrollView ();
}
19
Source : CheckResources.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void ListMeshes ()
{
meshListScrollPos = EditorGUILayout.BeginScrollView (meshListScrollPos);
foreach (MeshDetails tDetails in ActiveMeshDetails) {
if (tDetails.mesh != null) {
GUILayout.BeginHorizontal ();
/*
if (tDetails.material.mainTexture!=null) GUILayout.Box(tDetails.material.mainTexture, GUILayout.Width(ThumbnailWidth), GUILayout.Height(ThumbnailHeight));
else
{
GUILayout.Box("n/a",GUILayout.Width(ThumbnailWidth),GUILayout.Height(ThumbnailHeight));
}
*/
if (GUILayout.Button (tDetails.mesh.name, GUILayout.Width (150))) {
SelectObject (tDetails.mesh, ctrlPressed);
}
string sizeLabel = "" + tDetails.mesh.vertexCount + " vert";
GUILayout.Label (sizeLabel, GUILayout.Width (100));
if (GUILayout.Button (tDetails.FoundInMeshFilters.Count + " GO", GUILayout.Width (50))) {
List<Object> FoundObjects = new List<Object> ();
foreach (MeshFilter meshFilter in tDetails.FoundInMeshFilters)
FoundObjects.Add (meshFilter.gameObject);
SelectObjects (FoundObjects, ctrlPressed);
}
if (GUILayout.Button (tDetails.FoundInSkinnedMeshRenderer.Count + " GO", GUILayout.Width (50))) {
List<Object> FoundObjects = new List<Object> ();
foreach (SkinnedMeshRenderer skinnedMeshRenderer in tDetails.FoundInSkinnedMeshRenderer)
FoundObjects.Add (skinnedMeshRenderer.gameObject);
SelectObjects (FoundObjects, ctrlPressed);
}
GUILayout.EndHorizontal ();
}
}
EditorGUILayout.EndScrollView ();
}
19
Source : UICreateWidgetWizard.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
static public bool ShouldCreate (GameObject go, bool isValid)
{
GUI.color = isValid ? Color.green : Color.grey;
GUILayout.BeginHorizontal();
bool retVal = GUILayout.Button("Add To", GUILayout.Width(76f));
GUI.color = Color.white;
GameObject sel = EditorGUILayout.ObjectField(go, typeof(GameObject), true, GUILayout.Width(140f)) as GameObject;
GUILayout.Label("Select the parent in the Hierarchy View", GUILayout.MinWidth(10000f));
GUILayout.EndHorizontal();
if (sel != go) Selection.activeGameObject = sel;
if (retVal && isValid)
{
NGUIEditorTools.RegisterUndo("Add a Widget");
return true;
}
return false;
}
19
Source : UICreateWidgetWizard.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void CreateLabel (GameObject go)
{
GUILayout.BeginHorizontal();
Color c = EditorGUILayout.ColorField("Color", mColor, GUILayout.Width(220f));
GUILayout.Label("Color tint the label will start with");
GUILayout.EndHorizontal();
if (mColor != c)
{
mColor = c;
Save();
}
if (ShouldCreate(go, NGUISettings.font != null))
{
UILabel lbl = NGUITools.AddWidget<UILabel>(go);
lbl.font = NGUISettings.font;
lbl.text = "New Label";
lbl.color = mColor;
lbl.MakePixelPerfect();
Selection.activeGameObject = lbl.gameObject;
}
}
19
Source : UICreateWidgetWizard.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void CreateSprite (GameObject go, string field)
{
if (NGUISettings.atlas != null)
{
NGUIEditorTools.SpriteField("Sprite", "Sprite that will be created", NGUISettings.atlas, field, OnSprite);
if (!string.IsNullOrEmpty(field))
{
GUILayout.BeginHorizontal();
NGUISettings.pivot = (UIWidget.Pivot)EditorGUILayout.EnumPopup("Pivot", NGUISettings.pivot, GUILayout.Width(200f));
GUILayout.Space(20f);
GUILayout.Label("Initial pivot point used by the sprite");
GUILayout.EndHorizontal();
}
}
if (ShouldCreate(go, NGUISettings.atlas != null))
{
UISprite sprite = NGUITools.AddWidget<UISprite>(go);
sprite.name = sprite.name + " (" + field + ")";
sprite.atlas = NGUISettings.atlas;
sprite.spriteName = field;
sprite.pivot = NGUISettings.pivot;
sprite.MakePixelPerfect();
Selection.activeGameObject = sprite.gameObject;
}
}
19
Source : UIPanelTool.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
bool DrawRow (Entry ent, UIPanel selected, bool isChecked)
{
bool retVal = false;
string panelName, layer, widgetCount, drawCalls, clipping;
if (ent != null)
{
panelName = ent.panel.name;
layer = LayerMask.LayerToName(ent.panel.gameObject.layer);
widgetCount = ent.widgets.Count.ToString();
drawCalls = ent.panel.drawCalls.size.ToString();
clipping = (ent.panel.clipping != UIDrawCall.Clipping.None) ? "Yes" : "";
}
else
{
panelName = "Panel's Name";
layer = "Layer";
widgetCount = "WG";
drawCalls = "DC";
clipping = "Clip";
}
if (ent != null) NGUIEditorTools.HighlightLine(ent.isEnabled ? new Color(0.6f, 0.6f, 0.6f) : Color.black);
GUILayout.BeginHorizontal();
{
GUI.color = Color.white;
if (isChecked != EditorGUILayout.Toggle(isChecked, GUILayout.Width(20f))) retVal = true;
if (ent == null)
{
GUI.contentColor = Color.white;
}
else if (ent.isEnabled)
{
GUI.contentColor = (ent.panel == selected) ? new Color(0f, 0.8f, 1f) : Color.white;
}
else
{
GUI.contentColor = (ent.panel == selected) ? new Color(0f, 0.5f, 0.8f) : Color.grey;
}
#if UNITY_3_4
if (GUILayout.Button(panelName, EditorStyles.structHeadingLabel, GUILayout.MinWidth(100f)))
#else
if (GUILayout.Button(panelName, EditorStyles.label, GUILayout.MinWidth(100f)))
#endif
{
if (ent != null)
{
Selection.activeGameObject = ent.panel.gameObject;
EditorUtility.SetDirty(ent.panel.gameObject);
}
}
GUILayout.Label(layer, GUILayout.Width(ent == null ? 65f : 70f));
GUILayout.Label(widgetCount, GUILayout.Width(30f));
GUILayout.Label(drawCalls, GUILayout.Width(30f));
GUILayout.Label(clipping, GUILayout.Width(30f));
if (ent == null)
{
GUILayout.Label("Giz", GUILayout.Width(24f));
}
else
{
GUI.contentColor = ent.isEnabled ? Color.white : new Color(0.7f, 0.7f, 0.7f);
bool debug = (ent.panel.debugInfo == UIPanel.DebugInfo.Gizmos);
if (debug != EditorGUILayout.Toggle(debug, GUILayout.Width(20f)))
{
// debug != value, so it's currently inverse
ent.panel.debugInfo = debug ? UIPanel.DebugInfo.None : UIPanel.DebugInfo.Gizmos;
EditorUtility.SetDirty(ent.panel.gameObject);
}
}
}
GUILayout.EndHorizontal();
return retVal;
}
19
Source : UIPanelTool.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void OnGUI ()
{
List<UIPanel> panels = GetListOfPanels();
if (panels != null && panels.Count > 0)
{
UIPanel selectedPanel = NGUITools.FindInParents<UIPanel>(Selection.activeGameObject);
// First, collect a list of panels with their replacedociated widgets
List<Entry> entries = new List<Entry>();
Entry selectedEntry = null;
bool allEnabled = true;
foreach (UIPanel panel in panels)
{
Entry ent = new Entry();
ent.panel = panel;
ent.widgets = GetWidgets(panel);
ent.isEnabled = panel.enabled && NGUITools.GetActive(panel.gameObject);
ent.widgetsEnabled = ent.isEnabled;
if (ent.widgetsEnabled)
{
foreach (UIWidget w in ent.widgets)
{
if (!NGUITools.GetActive(w.gameObject))
{
allEnabled = false;
ent.widgetsEnabled = false;
break;
}
}
}
else allEnabled = false;
entries.Add(ent);
}
// Sort the list alphabetically
entries.Sort(Compare);
EditorGUIUtility.LookLikeControls(80f);
bool showAll = DrawRow(null, null, allEnabled);
NGUIEditorTools.DrawSeparator();
mScroll = GUILayout.BeginScrollView(mScroll);
foreach (Entry ent in entries)
{
if (DrawRow(ent, selectedPanel, ent.widgetsEnabled))
{
selectedEntry = ent;
}
}
GUILayout.EndScrollView();
if (showAll)
{
foreach (Entry ent in entries)
{
SetActiveState(ent.panel, !allEnabled);
}
}
else if (selectedEntry != null)
{
SetActiveState(selectedEntry.panel, !selectedEntry.widgetsEnabled);
}
}
else
{
GUILayout.Label("No UI Panels found in the scene");
}
}
19
Source : NGUIDebug.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
void OnGUI()
{
for (int i = 0, imax = mLines.Count; i < imax; ++i)
{
GUILayout.Label(mLines[i]);
}
}
19
Source : ScreenshotTaker.cs
with Apache License 2.0
from activey
with Apache License 2.0
from activey
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 replacedets",GUILayout.MaxWidth(100),GUILayout.MinHeight(40)))
{
Application.OpenURL("https://www.replacedetstore.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);
}
19
Source : BloomAndFlaresEditor.cs
with Apache License 2.0
from activey
with Apache License 2.0
from activey
public override void OnInspectorGUI () {
serObj.Update();
GUILayout.Label("HDR " + (hdr.enumValueIndex == 0 ? "auto detected, " : (hdr.enumValueIndex == 1 ? "forced on, " : "disabled, ")) + (useSrcAlphaAsMask.floatValue < 0.1f ? " ignoring alpha channel glow information" : " using alpha channel glow information"), EditorStyles.miniBoldLabel);
EditorGUILayout.PropertyField (tweakMode, new GUIContent("Tweak mode"));
EditorGUILayout.PropertyField (screenBlendMode, new GUIContent("Blend mode"));
EditorGUILayout.PropertyField (hdr, new GUIContent("HDR"));
// display info text when screen blend mode cannot be used
Camera cam = (target as BloomAndFlares).GetComponent<Camera>();
if (cam != null) {
if (screenBlendMode.enumValueIndex==0 && ((cam.hdr && hdr.enumValueIndex==0) || (hdr.enumValueIndex==1))) {
EditorGUILayout.HelpBox("Screen blend is not supported in HDR. Using 'Add' instead.", MessageType.Info);
}
}
if (1 == tweakMode.intValue)
EditorGUILayout.PropertyField (lensflares, new GUIContent("Cast lens flares"));
EditorGUILayout.Separator ();
EditorGUILayout.PropertyField (bloomIntensity, new GUIContent("Intensity"));
bloomthreshold.floatValue = EditorGUILayout.Slider ("threshold", bloomthreshold.floatValue, -0.05f, 4.0f);
bloomBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", bloomBlurIterations.intValue, 1, 4);
sepBlurSpread.floatValue = EditorGUILayout.Slider ("Blur spread", sepBlurSpread.floatValue, 0.1f, 10.0f);
if (1 == tweakMode.intValue)
useSrcAlphaAsMask.floatValue = EditorGUILayout.Slider (new GUIContent("Use alpha mask", "Make alpha channel define glowiness"), useSrcAlphaAsMask.floatValue, 0.0f, 1.0f);
else
useSrcAlphaAsMask.floatValue = 0.0f;
if (1 == tweakMode.intValue) {
EditorGUILayout.Separator ();
if (lensflares.boolValue) {
// further lens flare tweakings
if (0 != tweakMode.intValue)
EditorGUILayout.PropertyField (lensflareMode, new GUIContent("Lens flare mode"));
else
lensflareMode.enumValueIndex = 0;
EditorGUILayout.PropertyField(lensFlareVignetteMask, new GUIContent("Lens flare mask", "This mask is needed to prevent lens flare artifacts"));
EditorGUILayout.PropertyField (lensflareIntensity, new GUIContent("Local intensity"));
lensflarethreshold.floatValue = EditorGUILayout.Slider ("Local threshold", lensflarethreshold.floatValue, 0.0f, 1.0f);
if (lensflareMode.intValue == 0) {
// ghosting
EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorA, new GUIContent("1st Color"));
EditorGUILayout.PropertyField (flareColorB, new GUIContent("2nd Color"));
EditorGUILayout.EndHorizontal ();
EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorC, new GUIContent("3rd Color"));
EditorGUILayout.PropertyField (flareColorD, new GUIContent("4th Color"));
EditorGUILayout.EndHorizontal ();
}
else if (lensflareMode.intValue == 1) {
// hollywood
EditorGUILayout.PropertyField (hollyStretchWidth, new GUIContent("Stretch width"));
hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", hollywoodFlareBlurIterations.intValue, 1, 4);
EditorGUILayout.PropertyField (flareColorA, new GUIContent("Tint Color"));
}
else if (lensflareMode.intValue == 2) {
// both
EditorGUILayout.PropertyField (hollyStretchWidth, new GUIContent("Stretch width"));
hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", hollywoodFlareBlurIterations.intValue, 1, 4);
EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorA, new GUIContent("1st Color"));
EditorGUILayout.PropertyField (flareColorB, new GUIContent("2nd Color"));
EditorGUILayout.EndHorizontal ();
EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorC, new GUIContent("3rd Color"));
EditorGUILayout.PropertyField (flareColorD, new GUIContent("4th Color"));
EditorGUILayout.EndHorizontal ();
}
}
} else
lensflares.boolValue = false; // disable lens flares in simple tweak mode
serObj.ApplyModifiedProperties();
}
19
Source : TonemappingEditor.cs
with Apache License 2.0
from activey
with Apache License 2.0
from activey
public override void OnInspectorGUI () {
serObj.Update ();
GUILayout.Label("Mapping HDR to LDR ranges since 1982", EditorStyles.miniLabel);
Camera cam = (target as Tonemapping).GetComponent<Camera>();
if (cam != null) {
if (!cam.hdr) {
EditorGUILayout.HelpBox("The camera is not HDR enabled. This will likely break the Tonemapper.", MessageType.Warning);
}
else if (!(target as Tonemapping).validRenderTextureFormat) {
EditorGUILayout.HelpBox("The input to Tonemapper is not in HDR. Make sure that all effects prior to this are executed in HDR.", MessageType.Warning);
}
}
EditorGUILayout.PropertyField (type, new GUIContent ("Technique"));
if (type.enumValueIndex == (int) Tonemapping.TonemapperType.UserCurve) {
EditorGUILayout.PropertyField (remapCurve, new GUIContent ("Remap curve", "Specify the mapping of luminances yourself"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.SimpleReinhard) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.Hable) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.Photographic) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.OptimizedHejiDawson) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.AdaptiveReinhard) {
EditorGUILayout.PropertyField (middleGrey, new GUIContent ("Middle grey", "Middle grey defines the average luminance thus brightening or darkening the entire image."));
EditorGUILayout.PropertyField (white, new GUIContent ("White", "Smallest luminance value that will be mapped to white"));
EditorGUILayout.PropertyField (adaptionSpeed, new GUIContent ("Adaption Speed", "Speed modifier for the automatic adaption"));
EditorGUILayout.PropertyField (adaptiveTextureSize, new GUIContent ("Texture size", "Defines the amount of downsamples needed."));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.AdaptiveReinhardAutoWhite) {
EditorGUILayout.PropertyField (middleGrey, new GUIContent ("Middle grey", "Middle grey defines the average luminance thus brightening or darkening the entire image."));
EditorGUILayout.PropertyField (adaptionSpeed, new GUIContent ("Adaption Speed", "Speed modifier for the automatic adaption"));
EditorGUILayout.PropertyField (adaptiveTextureSize, new GUIContent ("Texture size", "Defines the amount of downsamples needed."));
}
GUILayout.Label("All following effects will use LDR color buffers", EditorStyles.miniBoldLabel);
serObj.ApplyModifiedProperties();
}
19
Source : NoiseEditor.cs
with MIT License
from adrianpolimeni
with MIT License
from adrianpolimeni
void DrawChannelMenu(int type, int channel) {
EditorGUILayout.Separator();
EditorGUILayout.LabelField("Noise Settings", EditorStyles.boldLabel);
noise.OnSettingsChange();
NoiseSettings noiseSettings = noise.activeSettings;
EditorGUILayout.BeginHorizontal();
GUILayout.Label("Seed");
if (GUILayout.Button("Generate New Seed")) {
rand = new System.Random(noiseSettings.seed);
noiseSettings.seed = rand.Next();
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.BeginVertical();
GUILayout.Label("Cell Divisions of Layers");
noiseSettings.frequencyA = EditorGUILayout.IntSlider( noiseSettings.frequencyA, 1, 64);
EditorGUILayout.Separator();
noiseSettings.frequencyB = EditorGUILayout.IntSlider( noiseSettings.frequencyB, 1, 64);
EditorGUILayout.Separator();
noiseSettings.frequencyC = EditorGUILayout.IntSlider( noiseSettings.frequencyC, 1, 64);
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical();
GUILayout.Label("Mix");
noiseSettings.mix = GUILayout.VerticalSlider( noiseSettings.mix, 0, 1);
EditorGUILayout.EndVertical();
EditorGUILayout.EndHorizontal();
if (textureFoldout = EditorGUILayout.Foldout(textureFoldout, "View Cross Section"))
{
Texture2D display = GetCrossSection(type, channel, sliceIndex);
if (display != null)
{
EditorGUILayout.BeginHorizontal();
if (sliceIndex > display.width - 1)
sliceIndex = 0;
sliceIndex = (int)GUILayout.VerticalSlider(sliceIndex, 0, display.width - 1);
GUILayout.Label(display);
EditorGUILayout.EndHorizontal();
}
else
EditorGUILayout.HelpBox("Texture not found!", MessageType.Warning);
}
}
19
Source : GerstnerDisplaceEditor.cs
with MIT License
from adrianpolimeni
with MIT License
from adrianpolimeni
public override void OnInspectorGUI()
{
serObj.Update();
GameObject go = ((GerstnerDisplace)serObj.targetObject).gameObject;
WaterBase wb = (WaterBase)go.GetComponent(typeof(WaterBase));
Material sharedWaterMaterial = wb.sharedMaterial;
GUILayout.Label("Animates vertices using up 4 generated waves", EditorStyles.miniBoldLabel);
if (sharedWaterMaterial)
{
Vector4 amplitude = WaterEditorUtility.GetMaterialVector("_GAmplitude", sharedWaterMaterial);
Vector4 frequency = WaterEditorUtility.GetMaterialVector("_GFrequency", sharedWaterMaterial);
Vector4 steepness = WaterEditorUtility.GetMaterialVector("_GSteepness", sharedWaterMaterial);
Vector4 speed = WaterEditorUtility.GetMaterialVector("_GSpeed", sharedWaterMaterial);
Vector4 directionAB = WaterEditorUtility.GetMaterialVector("_GDirectionAB", sharedWaterMaterial);
Vector4 directionCD = WaterEditorUtility.GetMaterialVector("_GDirectionCD", sharedWaterMaterial);
amplitude = EditorGUILayout.Vector4Field("Amplitude (Height offset)", amplitude);
frequency = EditorGUILayout.Vector4Field("Frequency (Tiling)", frequency);
steepness = EditorGUILayout.Vector4Field("Steepness", steepness);
speed = EditorGUILayout.Vector4Field("Speed", speed);
directionAB = EditorGUILayout.Vector4Field("Direction scale (Wave 1 (X,Y) and 2 (Z,W))", directionAB);
directionCD = EditorGUILayout.Vector4Field("Direction scale (Wave 3 (X,Y) and 4 (Z,W))", directionCD);
if (GUI.changed)
{
WaterEditorUtility.SetMaterialVector("_GAmplitude", amplitude, sharedWaterMaterial);
WaterEditorUtility.SetMaterialVector("_GFrequency", frequency, sharedWaterMaterial);
WaterEditorUtility.SetMaterialVector("_GSteepness", steepness, sharedWaterMaterial);
WaterEditorUtility.SetMaterialVector("_GSpeed", speed, sharedWaterMaterial);
WaterEditorUtility.SetMaterialVector("_GDirectionAB", directionAB, sharedWaterMaterial);
WaterEditorUtility.SetMaterialVector("_GDirectionCD", directionCD, sharedWaterMaterial);
}
/*
Vector4 animationTiling = WaterEditorUtility.GetMaterialVector("_AnimationTiling", sharedWaterMaterial);
Vector4 animationDirection = WaterEditorUtility.GetMaterialVector("_AnimationDirection", sharedWaterMaterial);
float firstTilingU = animationTiling.x*100.0F;
float firstTilingV = animationTiling.y*100.0F;
float firstDirectionU = animationDirection.x;
float firstDirectionV = animationDirection.y;
float secondTilingU = animationTiling.z*100.0F;
float secondTilingV = animationTiling.w*100.0F;
float secondDirectionU = animationDirection.z;
float secondDirectionV = animationDirection.w;
EditorGUILayout.BeginHorizontal ();
firstTilingU = EditorGUILayout.FloatField("First Tiling U", firstTilingU);
firstTilingV = EditorGUILayout.FloatField("First Tiling V", firstTilingV);
EditorGUILayout.EndHorizontal ();
EditorGUILayout.BeginHorizontal ();
secondTilingU = EditorGUILayout.FloatField("Second Tiling U", secondTilingU);
secondTilingV = EditorGUILayout.FloatField("Second Tiling V", secondTilingV);
EditorGUILayout.EndHorizontal ();
EditorGUILayout.BeginHorizontal ();
firstDirectionU = EditorGUILayout.FloatField("1st Animation U", firstDirectionU);
firstDirectionV = EditorGUILayout.FloatField("1st Animation V", firstDirectionV);
EditorGUILayout.EndHorizontal ();
EditorGUILayout.BeginHorizontal ();
secondDirectionU = EditorGUILayout.FloatField("2nd Animation U", secondDirectionU);
secondDirectionV = EditorGUILayout.FloatField("2nd Animation V", secondDirectionV);
EditorGUILayout.EndHorizontal ();
animationDirection = new Vector4(firstDirectionU,firstDirectionV, secondDirectionU,secondDirectionV);
animationTiling = new Vector4(firstTilingU/100.0F,firstTilingV/100.0F, secondTilingU/100.0F,secondTilingV/100.0F);
WaterEditorUtility.SetMaterialVector("_AnimationTiling", animationTiling, sharedWaterMaterial);
WaterEditorUtility.SetMaterialVector("_AnimationDirection", animationDirection, sharedWaterMaterial);
EditorGUILayout.Separator ();
GUILayout.Label ("Displacement Strength", EditorStyles.boldLabel);
float heightDisplacement = WaterEditorUtility.GetMaterialFloat("_HeightDisplacement", sharedWaterMaterial);
heightDisplacement = EditorGUILayout.Slider("Height", heightDisplacement, 0.0F, 5.0F);
WaterEditorUtility.SetMaterialFloat("_HeightDisplacement", heightDisplacement, sharedWaterMaterial);
*/
}
serObj.ApplyModifiedProperties();
}
19
Source : WaterBaseEditor.cs
with MIT License
from adrianpolimeni
with MIT License
from adrianpolimeni
public override void OnInspectorGUI()
{
serObj.Update();
waterBase = (WaterBase)serObj.targetObject;
oceanBase = ((WaterBase)serObj.targetObject).gameObject;
if (!oceanBase)
return;
GUILayout.Label("This script helps adjusting water material properties", EditorStyles.miniBoldLabel);
EditorGUILayout.PropertyField(sharedMaterial, new GUIContent("Material"));
oceanMaterial = (Material)sharedMaterial.objectReferenceValue;
if (!oceanMaterial)
{
sharedMaterial.objectReferenceValue = (Object)WaterEditorUtility.LocateValidWaterMaterial(oceanBase.transform);
serObj.ApplyModifiedProperties();
oceanMaterial = (Material)sharedMaterial.objectReferenceValue;
if (!oceanMaterial)
return;
}
EditorGUILayout.Separator();
GUILayout.Label("Overall Quality", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(waterQuality, new GUIContent("Quality"));
EditorGUILayout.PropertyField(edgeBlend, new GUIContent("Edge blend?"));
if (waterQuality.intValue > (int)WaterQuality.Low)
EditorGUILayout.HelpBox("Water features not supported", MessageType.Warning);
if (edgeBlend.boolValue && !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth))
EditorGUILayout.HelpBox("Edge blend not supported", MessageType.Warning);
EditorGUILayout.Separator();
bool hreplacedreplaced = oceanMaterial.HasProperty("_SreplacedTex");
GUILayout.Label("Main Colors", EditorStyles.boldLabel);
GUILayout.Label("Alpha values define blending with realtime textures", EditorStyles.miniBoldLabel);
WaterEditorUtility.SetMaterialColor("_BaseColor", EditorGUILayout.ColorField("Refraction", WaterEditorUtility.GetMaterialColor("_BaseColor", oceanMaterial)), oceanMaterial);
WaterEditorUtility.SetMaterialColor("_ReflectionColor", EditorGUILayout.ColorField("Reflection", WaterEditorUtility.GetMaterialColor("_ReflectionColor", oceanMaterial)), oceanMaterial);
EditorGUILayout.Separator();
GUILayout.Label("Main Textures", EditorStyles.boldLabel);
GUILayout.Label("Used for small waves (bumps), foam and white caps", EditorStyles.miniBoldLabel);
WaterEditorUtility.SetMaterialTexture("_BumpMap", (Texture)EditorGUILayout.ObjectField("Normals", WaterEditorUtility.GetMaterialTexture("_BumpMap", waterBase.sharedMaterial), typeof(Texture), false), waterBase.sharedMaterial);
if (hreplacedreplaced)
WaterEditorUtility.SetMaterialTexture("_SreplacedTex", (Texture)EditorGUILayout.ObjectField("Sreplaced & Foam", WaterEditorUtility.GetMaterialTexture("_SreplacedTex", waterBase.sharedMaterial), typeof(Texture), false), waterBase.sharedMaterial);
Vector4 animationTiling;
Vector4 animationDirection;
Vector2 firstTiling;
Vector2 secondTiling;
Vector2 firstDirection;
Vector2 secondDirection;
animationTiling = WaterEditorUtility.GetMaterialVector("_BumpTiling", oceanMaterial);
animationDirection = WaterEditorUtility.GetMaterialVector("_BumpDirection", oceanMaterial);
firstTiling = new Vector2(animationTiling.x * 100.0F, animationTiling.y * 100.0F);
secondTiling = new Vector2(animationTiling.z * 100.0F, animationTiling.w * 100.0F);
firstTiling = EditorGUILayout.Vector2Field("Tiling 1", firstTiling);
secondTiling = EditorGUILayout.Vector2Field("Tiling 2", secondTiling);
//firstTiling.x = EditorGUILayout.FloatField("1st Tiling U", firstTiling.x);
//firstTiling.y = EditorGUILayout.FloatField("1st Tiling V", firstTiling.y);
//secondTiling.x = EditorGUILayout.FloatField("2nd Tiling U", secondTiling.x);
//secondTiling.y = EditorGUILayout.FloatField("2nd Tiling V", secondTiling.y);
firstDirection = new Vector2(animationDirection.x, animationDirection.y);
secondDirection = new Vector2(animationDirection.z, animationDirection.w);
//firstDirection.x = EditorGUILayout.FloatField("1st Animation U", firstDirection.x);
//firstDirection.y = EditorGUILayout.FloatField("1st Animation V", firstDirection.y);
//secondDirection.x = EditorGUILayout.FloatField("2nd Animation U", secondDirection.x);
//secondDirection.y = EditorGUILayout.FloatField("2nd Animation V", secondDirection.y);
firstDirection = EditorGUILayout.Vector2Field("Direction 1", firstDirection);
secondDirection = EditorGUILayout.Vector2Field("Direction 2", secondDirection);
animationTiling = new Vector4(firstTiling.x / 100.0F, firstTiling.y / 100.0F, secondTiling.x / 100.0F, secondTiling.y / 100.0F);
animationDirection = new Vector4(firstDirection.x, firstDirection.y, secondDirection.x, secondDirection.y);
WaterEditorUtility.SetMaterialVector("_BumpTiling", animationTiling, oceanMaterial);
WaterEditorUtility.SetMaterialVector("_BumpDirection", animationDirection, oceanMaterial);
Vector4 displacementParameter = WaterEditorUtility.GetMaterialVector("_DistortParams", oceanMaterial);
Vector4 fade = WaterEditorUtility.GetMaterialVector("_InvFadeParemeter", oceanMaterial);
EditorGUILayout.Separator();
GUILayout.Label("Normals", EditorStyles.boldLabel);
GUILayout.Label("Displacement for fresnel, specular and reflection/refraction", EditorStyles.miniBoldLabel);
float gerstnerNormalIntensity = WaterEditorUtility.GetMaterialFloat("_GerstnerIntensity", oceanMaterial);
gerstnerNormalIntensity = EditorGUILayout.Slider("Per Vertex", gerstnerNormalIntensity, -2.5F, 2.5F);
WaterEditorUtility.SetMaterialFloat("_GerstnerIntensity", gerstnerNormalIntensity, oceanMaterial);
displacementParameter.x = EditorGUILayout.Slider("Per Pixel", displacementParameter.x, -4.0F, 4.0F);
displacementParameter.y = EditorGUILayout.Slider("Distortion", displacementParameter.y, -0.5F, 0.5F);
// fade.z = EditorGUILayout.Slider("Distance fade", fade.z, 0.0f, 0.5f);
EditorGUILayout.Separator();
GUILayout.Label("Fresnel", EditorStyles.boldLabel);
GUILayout.Label("Defines reflection to refraction relation", EditorStyles.miniBoldLabel);
if (!oceanMaterial.HasProperty("_Fresnel"))
{
if (oceanMaterial.HasProperty("_FresnelScale"))
{
float fresnelScale = EditorGUILayout.Slider("Intensity", WaterEditorUtility.GetMaterialFloat("_FresnelScale", oceanMaterial), 0.1F, 4.0F);
WaterEditorUtility.SetMaterialFloat("_FresnelScale", fresnelScale, oceanMaterial);
}
displacementParameter.z = EditorGUILayout.Slider("Power", displacementParameter.z, 0.1F, 10.0F);
displacementParameter.w = EditorGUILayout.Slider("Bias", displacementParameter.w, -3.0F, 3.0F);
}
else
{
Texture fresnelTex = (Texture)EditorGUILayout.ObjectField(
"Ramp",
(Texture)WaterEditorUtility.GetMaterialTexture("_Fresnel",
oceanMaterial),
typeof(Texture),
false);
WaterEditorUtility.SetMaterialTexture("_Fresnel", fresnelTex, oceanMaterial);
}
EditorGUILayout.Separator();
WaterEditorUtility.SetMaterialVector("_DistortParams", displacementParameter, oceanMaterial);
if (edgeBlend.boolValue)
{
GUILayout.Label("Fading", EditorStyles.boldLabel);
fade.x = EditorGUILayout.Slider("Edge fade", fade.x, 0.001f, 3.0f);
if (hreplacedreplaced)
fade.y = EditorGUILayout.Slider("Sreplaced fade", fade.y, 0.001f, 3.0f);
fade.w = EditorGUILayout.Slider("Extinction fade", fade.w, 0.0f, 2.5f);
WaterEditorUtility.SetMaterialVector("_InvFadeParemeter", fade, oceanMaterial);
}
EditorGUILayout.Separator();
if (oceanMaterial.HasProperty("_Foam"))
{
GUILayout.Label("Foam", EditorStyles.boldLabel);
Vector4 foam = WaterEditorUtility.GetMaterialVector("_Foam", oceanMaterial);
foam.x = EditorGUILayout.Slider("Intensity", foam.x, 0.0F, 1.0F);
foam.y = EditorGUILayout.Slider("Cutoff", foam.y, 0.0F, 1.0F);
WaterEditorUtility.SetMaterialVector("_Foam", foam, oceanMaterial);
}
serObj.ApplyModifiedProperties();
}
19
Source : CloudSettingsEditor.cs
with MIT License
from adrianpolimeni
with MIT License
from adrianpolimeni
private static Texture2D TextureField(string name, Texture2D texture)
{
GUILayout.BeginVertical();
var style = new GUIStyle(GUI.skin.label);
style.alignment = TextAnchor.UpperCenter;
style.fixedWidth = 64;
GUILayout.Label(name, style);
var result = (Texture2D)EditorGUILayout.ObjectField(texture, typeof(Texture2D), false, GUILayout.Width(64), GUILayout.Height(64));
GUILayout.EndVertical();
return result;
}
19
Source : PlanarReflectionEditor.cs
with MIT License
from adrianpolimeni
with MIT License
from adrianpolimeni
public override void OnInspectorGUI()
{
GUILayout.Label("Render planar reflections and use GrabPreplaced for refractions", EditorStyles.miniBoldLabel);
serObj.Update();
EditorGUILayout.PropertyField(reflectionMask, new GUIContent("Reflection layers"));
EditorGUILayout.PropertyField(reflectSkybox, new GUIContent("Use skybox"));
EditorGUILayout.PropertyField(clearColor, new GUIContent("Clear color"));
showKidsWithReflectionHint = EditorGUILayout.BeginToggleGroup("Show all tiles", showKidsWithReflectionHint);
if (showKidsWithReflectionHint)
{
int i = 0;
foreach (Transform t in ((PlanarReflection)target).transform)
{
if (t.GetComponent<WaterTile>())
{
if (i % 2 == 0)
EditorGUILayout.BeginHorizontal();
EditorGUILayout.ObjectField(t, typeof(Transform), true);
if (i % 2 == 1)
EditorGUILayout.EndHorizontal();
i = (i + 1) % 2;
}
}
if (i > 0)
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndToggleGroup();
serObj.ApplyModifiedProperties();
}
19
Source : SpecularLightingEditor.cs
with MIT License
from adrianpolimeni
with MIT License
from adrianpolimeni
public override void OnInspectorGUI()
{
serObj.Update();
GameObject go = ((SpecularLighting)serObj.targetObject).gameObject;
WaterBase wb = (WaterBase)go.GetComponent(typeof(WaterBase));
if (!wb.sharedMaterial)
return;
if (wb.sharedMaterial.HasProperty("_WorldLightDir"))
{
GUILayout.Label("Transform casting specular highlights", EditorStyles.miniBoldLabel);
EditorGUILayout.PropertyField(specularLight, new GUIContent("Specular light"));
if (wb.sharedMaterial.HasProperty("_SpecularColor"))
WaterEditorUtility.SetMaterialColor(
"_SpecularColor",
EditorGUILayout.ColorField("Specular",
WaterEditorUtility.GetMaterialColor("_SpecularColor", wb.sharedMaterial)),
wb.sharedMaterial);
if (wb.sharedMaterial.HasProperty("_Shininess"))
WaterEditorUtility.SetMaterialFloat("_Shininess", EditorGUILayout.Slider(
"Specular power",
WaterEditorUtility.GetMaterialFloat("_Shininess", wb.sharedMaterial),
0.0F, 500.0F), wb.sharedMaterial);
}
else
GUILayout.Label("The shader doesn't have the needed _WorldLightDir property.", EditorStyles.miniBoldLabel);
serObj.ApplyModifiedProperties();
}
19
Source : Log.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
protected internal override void Draw()
{
if (messages.Count > 0)
{
lock (messages)
{
//List<string> message = messages.Keys.ToList();
//List<int> count = messages.Values.ToList();
GUILayout.BeginArea(position);
UnityEngine.GUILayout.FlexibleSpace();
foreach (var pair in messages)
{
UnityEngine.GUILayout.Label(pair.Key + (pair.Value > 1 ? $" <color=red>[x{pair.Value}]</color>" : string.Empty), LogStyle, labelOptions);
}
//for (int i = 0; i < messages.Count; i++)
//{
// string currentMessage = message[i];
// int currentCount = count[i];
// if (!currentMessage.IsNullOrEmpty())
// {
// UnityEngine.GUILayout.Label(currentMessage + (currentCount > 1 ? $" <color=red>[x{currentCount}]</color>" : string.Empty), LogStyle, labelOptions);
// }
//}
GUILayout.EndArea();
}
}
}
19
Source : GUILayout.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static float HorizontalSlider(float val, string label, GUILayoutOption[] lblOpts, GUILayoutOption[] sliderOpts)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, lblOpts);
UGUI.Space(5f);
val = UGUI.HorizontalSlider(val, 0f, 1f, Style.Slider, Style.SliderBody, sliderOpts);
UGUI.EndHorizontal();
return val;
}
See More Examples