Here are the examples of the csharp api UnityEngine.GUILayout.BeginArea(UnityEngine.Rect, UnityEngine.GUIContent, UnityEngine.GUIStyle) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
92 Examples
19
View Source File : GUIHelper.cs
License : MIT License
Project Creator : huanzi-qch
License : MIT License
Project Creator : huanzi-qch
public static void DrawArea(Rect area, bool drawHeader, Action action)
{
Setup();
// Draw background
GUI.Box(area, string.Empty);
GUILayout.BeginArea(area);
if (drawHeader)
{
GUIHelper.DrawCenteredText(SampleSelector.SelectedSample.DisplayName);
GUILayout.Space(5);
}
if (action != null)
action();
GUILayout.EndArea();
}
19
View Source File : RotationQuaternionNodeEditor.cs
License : MIT License
Project Creator : Interactml
License : MIT License
Project Creator : Interactml
protected override void ShowBodyFields()
{
GUILayout.Space(60);
// set body space based on node editors rects
GUILayout.BeginArea(m_BodyRect);
GUILayout.Space(20);
//draws node data fields
MovementFeatureEditorMethods.DrawFeatureValueToggleAndLabel(this, m_ExtractRotationQuaternion);
GUILayout.Space(10);
//draw toggle to select whether to use localspace
m_ExtractRotationQuaternion.LocalSpace = MovementFeatureEditorMethods.DrawLocalSpaceToggle(this, m_ExtractRotationQuaternion.LocalSpace);
GUILayout.EndArea();
}
19
View Source File : SteamVR_LoadLevel.cs
License : GNU General Public License v3.0
Project Creator : brandonmousseau
License : GNU General Public License v3.0
Project Creator : brandonmousseau
void OnGUI()
{
if (_active != this)
return;
// Optionally create an overlay for our progress bar to use, separate from the loading screen.
if (progressBarEmpty != null && progressBarFull != null)
{
if (progressBarOverlayHandle == OpenVR.k_ulOverlayHandleInvalid)
progressBarOverlayHandle = GetOverlayHandle("progressBar", progressBarTransform != null ? progressBarTransform : transform, progressBarWidthInMeters);
if (progressBarOverlayHandle != OpenVR.k_ulOverlayHandleInvalid)
{
var progress = (async != null) ? async.progress : 0.0f;
// Use the full bar size for everything.
var w = progressBarFull.width;
var h = progressBarFull.height;
// Create a separate render texture so we can composite the full image on top of the empty one.
if (renderTexture == null)
{
renderTexture = new RenderTexture(w, h, 0);
renderTexture.Create();
}
var prevActive = RenderTexture.active;
RenderTexture.active = renderTexture;
if (Event.current.type == EventType.Repaint)
GL.Clear(false, true, Color.clear);
GUILayout.BeginArea(new Rect(0, 0, w, h));
GUI.DrawTexture(new Rect(0, 0, w, h), progressBarEmpty);
// Reveal the full bar texture based on progress.
GUI.DrawTextureWithTexCoords(new Rect(0, 0, progress * w, h), progressBarFull, new Rect(0.0f, 0.0f, progress, 1.0f));
GUILayout.EndArea();
RenderTexture.active = prevActive;
// Texture needs to be set every frame after it is updated since SteamVR makes a copy internally to a shared texture.
var overlay = OpenVR.Overlay;
if (overlay != null)
{
var texture = new Texture_t();
texture.handle = renderTexture.GetNativeTexturePtr();
texture.eType = SteamVR.instance.textureType;
texture.eColorSpace = EColorSpace.Auto;
overlay.SetOverlayTexture(progressBarOverlayHandle, ref texture);
}
}
}
#if false
// Draw loading screen and progress bar to 2d companion window as well.
if (loadingScreen != null)
{
var screenAspect = (float)Screen.width / Screen.height;
var textureAspect = (float)loadingScreen.width / loadingScreen.height;
float w, h;
if (screenAspect < textureAspect)
{
// Clamp horizontally
w = Screen.width * 0.9f;
h = w / textureAspect;
}
else
{
// Clamp vertically
h = Screen.height * 0.9f;
w = h * textureAspect;
}
GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));
var x = Screen.width / 2 - w / 2;
var y = Screen.height / 2 - h / 2;
GUI.DrawTexture(new Rect(x, y, w, h), loadingScreen);
GUILayout.EndArea();
}
if (renderTexture != null)
{
var x = Screen.width / 2 - renderTexture.width / 2;
var y = Screen.height * 0.9f - renderTexture.height;
GUI.DrawTexture(new Rect(x, y, renderTexture.width, renderTexture.height), renderTexture);
}
#endif
}
19
View Source File : OSCPanelControlCreator.cs
License : MIT License
Project Creator : hizzlehoff
License : MIT License
Project Creator : hizzlehoff
protected override void DrawContent(ref Rect contentRect)
{
if (!_controlCreator.IsValid)
{
EditorGUILayout.LabelField(_errorCreateContent, OSCEditorStyles.CenterLabel, GUILayout.Height(contentRect.height));
return;
}
contentRect.x += 2;
contentRect.y += 2;
contentRect.width -= 4;
contentRect.height -= 4;
GUILayout.BeginArea(contentRect);
OSCEditorInterface.LogoLayout();
GUILayout.Label(_controlSettingsContent, EditorStyles.boldLabel);
EditorGUILayout.BeginVertical(OSCEditorStyles.Box);
_controlColor = EditorGUILayout.ColorField(_controlColorContent, _controlColor);
EditorGUILayout.EndVertical();
GUI.color = _addInformer ? Color.green : Color.red;
if (GUILayout.Button(_addInformerContent))
{
_addInformer = !_addInformer;
}
GUI.color = Color.white;
if (_addInformer)
{
GUILayout.Label(_informerSettingsContent, EditorStyles.boldLabel);
EditorGUILayout.BeginVertical(OSCEditorStyles.Box);
var content = (GUIContent[])null;
var objects = (OSCTransmitter[])null;
OSCEditorUtils.FindObjects(TransmitterCallback, true, out content, out objects);
_informerAddress = EditorGUILayout.TextField(_oscAddressContent, _informerAddress);
_informerTransmitter = OSCEditorInterface.PopupLayout(_oscTransmitterContent,
_informerTransmitter,
content,
objects);
GUI.color = _informOnChanged ? Color.green : Color.red;
if (GUILayout.Button(_informOnChangedContent))
{
_informOnChanged = !_informOnChanged;
}
GUI.color = Color.white;
if (!_informOnChanged)
{
_informerInterval = EditorGUILayout.FloatField(_informerIntervalContent, _informerInterval);
if (_informerInterval < 0) _informerInterval = 0;
EditorGUILayout.HelpBox("Set to 0 for send message with each frame.", MessageType.Info);
}
EditorGUILayout.EndVertical();
}
GUI.color = Color.green;
if (GUILayout.Button(_createContent))
{
var data = new OSCWindowControlCreator.ControlData();
data.ControlColor = _controlColor;
data.UseInformer = _addInformer;
data.InformAddress = _informerAddress;
data.InformInterval = _informerInterval;
data.InformOnChanged = _informOnChanged;
data.InformerTransmitter = _informerTransmitter;
OSCWindowControlCreator.CreateControl(data);
}
GUI.color = Color.white;
GUILayout.EndArea();
}
19
View Source File : CFX2_Demo.cs
License : MIT License
Project Creator : Crazy-Marvin
License : MIT License
Project Creator : Crazy-Marvin
void OnGUI()
{
GUILayout.BeginArea(new Rect(5,20,Screen.width-10,60));
GUILayout.BeginHorizontal();
GUILayout.Label("Effect");
if(GUILayout.Button("<"))
{
prevParticle();
}
GUILayout.Label(ParticleExamples[exampleIndex].name, GUILayout.Width(210));
if(GUILayout.Button(">"))
{
nextParticle();
}
GUILayout.Label("Click on the ground to spawn selected particles", GUILayout.Width(150));
if(GUILayout.Button(CFX_Demo_RotateCamera.rotating ? "Pause Camera" : "Rotate Camera"))
{
CFX_Demo_RotateCamera.rotating = !CFX_Demo_RotateCamera.rotating;
}
if(GUILayout.Button(randomSpawns ? "Stop Random Spawns" : "Start Random Spawns", GUILayout.Width(140)))
{
randomSpawns = !randomSpawns;
if(randomSpawns) StartCoroutine("RandomSpawnsCoroutine");
else StopCoroutine("RandomSpawnsCoroutine");
}
randomSpawnsDelay = GUILayout.TextField(randomSpawnsDelay, 10, GUILayout.Width(42));
randomSpawnsDelay = Regex.Replace(randomSpawnsDelay, @"[^0-9.]", "");
if(GUILayout.Button(this.GetComponent<Renderer>().enabled ? "Hide Ground" : "Show Ground", GUILayout.Width(90)))
{
this.GetComponent<Renderer>().enabled = !this.GetComponent<Renderer>().enabled;
}
if(GUILayout.Button(slowMo ? "Normal Speed" : "Slow Motion", GUILayout.Width(100)))
{
slowMo = !slowMo;
if(slowMo) Time.timeScale = 0.33f;
else Time.timeScale = 1.0f;
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
19
View Source File : RotationLimitPolygonalInspector.cs
License : GNU General Public License v3.0
Project Creator : brandonmousseau
License : GNU General Public License v3.0
Project Creator : brandonmousseau
public void OnSceneGUI()
{
GUI.changed = false;
// Set defaultLocalRotation so that the initial local rotation will be the zero point for the rotation limit
if (!Application.isPlaying && !script.defaultLocalRotationOverride) script.defaultLocalRotation = script.transform.localRotation;
if (script.axis == Vector3.zero) return;
// Quick Editing Tools
Handles.BeginGUI();
GUILayout.BeginArea(new Rect(10, 10, 550, 140), "Rotation Limit Polygonal", "Window");
// Cloning values from another RotationLimitPolygonal
EditorGUILayout.BeginHorizontal();
if (Inspector.Button("Clone From", "Make this rotation limit identical to another", script, GUILayout.Width(220))) CloneLimit();
clone = (RotationLimitPolygonal)EditorGUILayout.ObjectField("", clone, typeof(RotationLimitPolygonal), true);
EditorGUILayout.EndHorizontal();
// Symmetry
symmetry = (Symmetry)EditorGUILayout.EnumPopup("Symmetry", symmetry, GUILayout.Width(220));
// Flipping
EditorGUILayout.BeginHorizontal();
if (Inspector.Button("Flip X", "Flip points along local X axis", script, GUILayout.Width(100))) FlipLimit(0);
if (Inspector.Button("Flip Y", "Flip points along local Y axis", script, GUILayout.Width(100))) FlipLimit(1);
if (Inspector.Button("Flip Z", "Flip points along local Z axis", script, GUILayout.Width(100))) FlipLimit(2);
GUILayout.Label("Flip everything along axis");
EditorGUILayout.EndHorizontal();
// Rotating
EditorGUILayout.BeginHorizontal();
if (Inspector.Button("Rotate X", "Rotate points along X axis by Degrees", script, GUILayout.Width(100))) RotatePoints(degrees, Vector3.right);
if (Inspector.Button("Rotate Y", "Rotate points along Y axis by Degrees", script, GUILayout.Width(100))) RotatePoints(degrees, Vector3.up);
if (Inspector.Button("Rotate Z", "Rotate points along Z axis by Degrees", script, GUILayout.Width(100))) RotatePoints(degrees, Vector3.forward);
degrees = EditorGUILayout.FloatField("Degrees", degrees, GUILayout.Width(200));
EditorGUILayout.EndHorizontal();
// Smooth/Optimize
EditorGUILayout.BeginHorizontal();
if (Inspector.Button("Smooth", "Double the points", script)) Smooth();
if (Inspector.Button("Optimize", "Delete every second point", script)) Optimize();
EditorGUILayout.EndHorizontal();
GUILayout.EndArea();
Handles.EndGUI();
// Rebuild reach cones
script.BuildReachCones();
// Draw a white transparent sphere
DrawRotationSphere(script.transform.position);
// Draw Axis
DrawArrow(script.transform.position, Direction(script.axis), colorDefault, "Axis", 0.02f);
// Display limit points
for (int i = 0; i < script.points.Length; i++)
{
Color color = GetColor(i); // Paint the point in green or red if it belongs to an invalid reach cone
Handles.color = color;
GUI.color = color;
// Line from the center to the point and the label
Handles.DrawLine(script.transform.position, script.transform.position + Direction(script.points[i].point));
Handles.Label(script.transform.position + Direction(script.points[i].point + new Vector3(-0.02f, 0, 0)), " " + i.ToString());
// Selecting points
Handles.color = colorHandles;
if (Inspector.DotButton(script.transform.position + Direction(script.points[i].point), script.transform.rotation, 0.02f, 0.02f))
{
selectedPoint = i;
}
Handles.color = Color.white;
GUI.color = Color.white;
// Limit point GUI
if (i == selectedPoint)
{
Handles.BeginGUI();
GUILayout.BeginArea(new Rect(Screen.width - 240, Screen.height - 180, 230, 130), "Limit Point " + i.ToString(), "Window");
if (Inspector.Button("Delete", "Delete this point", script))
{
if (script.points.Length > 3)
{
// Using the deletePoint index here because we dont want to delete points from the array that we are iterating
deletePoint = i;
}
else if (!Warning.logged) script.LogWarning("Polygonal Rotation Limit should have at least 3 limit points");
}
if (Inspector.Button("Add Point", "Add a new point next to this one", script))
{
addPoint = i;
}
// Store point for undo
Vector3 oldPoint = script.points[i].point;
// Manual input for the point position
Inspector.AddVector3(ref script.points[i].point, "Point", script, GUILayout.Width(210));
EditorGUILayout.Space();
// Tangent weight
Inspector.AddFloat(ref script.points[i].tangentWeight, "Tangent Weight", "Weight of this point's tangent. Used in smoothing.", script, -Mathf.Infinity, Mathf.Infinity, GUILayout.Width(150));
GUILayout.EndArea();
Handles.EndGUI();
// Moving Points
Vector3 pointWorld = Handles.PositionHandle(script.transform.position + Direction(script.points[i].point), Quaternion.idenreplacedy);
Vector3 newPoint = InverseDirection(pointWorld - script.transform.position);
if (newPoint != script.points[i].point)
{
if (!Application.isPlaying) Undo.RecordObject(script, "Move Limit Point");
script.points[i].point = newPoint;
}
// Symmetry
if (symmetry != Symmetry.Off && script.points.Length > 3 && oldPoint != script.points[i].point)
{
RotationLimitPolygonal.LimitPoint symmetryPoint = GetClosestPoint(Symmetrize(oldPoint, symmetry));
if (symmetryPoint != script.points[i])
{
symmetryPoint.point = Symmetrize(script.points[i].point, symmetry);
}
}
}
// Normalize the point
script.points[i].point = script.points[i].point.normalized;
}
// Display smoothed polygon
for (int i = 0; i < script.P.Length; i++)
{
Color color = GetColor(i);
// Smoothed triangles are transparent
Handles.color = new Color(color.r, color.g, color.b, 0.25f);
Handles.DrawLine(script.transform.position, script.transform.position + Direction(script.P[i]));
Handles.color = color;
if (i < script.P.Length - 1) Handles.DrawLine(script.transform.position + Direction(script.P[i]), script.transform.position + Direction(script.P[i + 1]));
else Handles.DrawLine(script.transform.position + Direction(script.P[i]), script.transform.position + Direction(script.P[0]));
Handles.color = Color.white;
}
// Deleting points
if (deletePoint != -1)
{
DeletePoint(deletePoint);
selectedPoint = -1;
deletePoint = -1;
}
// Adding points
if (addPoint != -1)
{
AddPoint(addPoint);
addPoint = -1;
}
if (GUI.changed) EditorUtility.SetDirty(script);
}
19
View Source File : ArrayNodeEditor.cs
License : MIT License
Project Creator : Interactml
License : MIT License
Project Creator : Interactml
protected override void ShowBodyFields()
{
m_InnerBodyRect.x = m_BodyRect.x + 20;
m_InnerBodyRect.y = m_BodyRect.y + 20;
m_InnerBodyRect.width = m_BodyRect.width - 20;
m_InnerBodyRect.height = m_BodyRect.height - 20;
GUILayout.BeginArea(m_InnerBodyRect);
UpdateFeatureLabelArray();
// check if there is a connection
if (!m_ArrayNode.IsInputConnected())
{
// set node length
nodeSpace = 120;
m_BodyRect.height = 60;
// alert to connect an array to input
EditorGUILayout.LabelField("Connect an array", m_NodeSkin.GetStyle("Node Body Label"));
}
// check if there are any features connected
else
{
// check there are features to show
if (m_ArrayNode.FeatureValues.Values != null && m_ArrayNode.FeatureValues.Values.Length != 0)
{
// show toggles and values for number of elements up to 6
if (m_ArrayNode.FeatureValues.Values.Length < 7)
{
// dynamically adjust node length based on amount of velocity features
nodeSpace = 120 + (m_ArrayNode.FeatureValues.Values.Length * 24);
m_BodyRect.height = 60 + (m_ArrayNode.FeatureValues.Values.Length * 24);
// draws each feature in the node
DataTypeNodeEditorMethods.DrawFeatureValueToggleAndLabel(this, m_ArrayNode);
}
else if (m_ArrayNode.FeatureValues.Values.Length > m_ArrayNode.m_MaximumArraySize)
{
// set node length
nodeSpace = 160;
m_BodyRect.height = 100;
// alert that array length is too long
ShowWarning(m_ArrayNode.tooltips.BottomError[0]);
}
else
{
// set node length
nodeSpace = 120;
m_BodyRect.height = 60;
// show dropdown scroll view of elements
SetDropdownStyle();
ShowArrayDataDropdown();
}
}
else
{
// set node length
nodeSpace = 120;
m_BodyRect.height = 60;
// if input is detect without features alert user there is connection
if (m_ArrayNode.GetInputNodesConnected("m_In")[0].GetType() == typeof(InteractML.ScriptNode))
EditorGUILayout.LabelField("Script connection detected", m_NodeSkin.GetStyle("Node Body Label"));
else
EditorGUILayout.LabelField("Connection detected", m_NodeSkin.GetStyle("Node Body Label"));
}
}
GUILayout.EndArea();
}
19
View Source File : RepetableActionExample.cs
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
private void OnGUI()
{
GUILayout.BeginArea(new Rect(5f, 50f, 400f, 250f), GUI.skin.window);
GUILayout.Label("Repeatable Action Example\n\n");
GUILayout.Label("Press the number key, to see the corresponding action (in the console):");
GUILayout.Label("1. Fixed repereplacedions (5 times), default interval.");
GUILayout.Label("2. Conditional repereplacedions, 2 sec interval, 3 sec initial delay.");
GUILayout.Label("3. Indefinite, 2 sec interval.");
GUILayout.Label("4. Stop indefinite.");
GUILayout.EndArea();
}
19
View Source File : RotationEulerNodeEditor.cs
License : MIT License
Project Creator : Interactml
License : MIT License
Project Creator : Interactml
protected override void ShowBodyFields()
{
GUILayout.Space(60);
// set body space based on node editors rects
GUILayout.BeginArea(m_BodyRect);
GUILayout.Space(20);
//draws node data fields
MovementFeatureEditorMethods.DrawFeatureValueToggleAndLabel(this, m_ExtractRotationEuler);
GUILayout.Space(10);
//draw toggle to select whether to use localspace
m_ExtractRotationEuler.LocalSpace = MovementFeatureEditorMethods.DrawLocalSpaceToggle(this, m_ExtractRotationEuler.LocalSpace);
GUILayout.EndArea();
}
19
View Source File : BehaviorEditor.cs
License : GNU General Public License v3.0
Project Creator : Aroueterra
License : GNU General Public License v3.0
Project Creator : Aroueterra
void DrawWindows()
{
GUILayout.BeginArea(all, style);
BeginWindows();
EditorGUILayout.LabelField(" ", GUILayout.Width(100));
EditorGUILayout.LabelField("replacedign Graph:", GUILayout.Width(100));
settings.currentGraph = (BehaviorGraph)EditorGUILayout.ObjectField(settings.currentGraph, typeof(BehaviorGraph), false, GUILayout.Width(200));
if (settings.currentGraph != null)
{
foreach (BaseNode n in settings.currentGraph.windows)
{
n.DrawCurve();
}
for (int i = 0; i < settings.currentGraph.windows.Count; i++)
{
BaseNode b = settings.currentGraph.windows[i];
if (b.drawNode is StateNode)
{
if (currentStateManager != null && b.stateRef.currentState == currentStateManager.currentState)
{
b.windowRect = GUI.Window(i, b.windowRect,
DrawNodeWindow, b.windowreplacedle,activeStyle);
}
else
{
b.windowRect = GUI.Window(i, b.windowRect,
DrawNodeWindow, b.windowreplacedle);
}
}
else
{
b.windowRect = GUI.Window(i, b.windowRect,
DrawNodeWindow, b.windowreplacedle);
}
}
}
EndWindows();
GUILayout.EndArea();
}
19
View Source File : VectorShapeEditor.cs
License : MIT License
Project Creator : ecurtz
License : MIT License
Project Creator : ecurtz
protected void OnInfoAreaView(Event guiEvent, Rect guiRect)
{
GUILayout.BeginArea(guiRect);
if (selection.Count == 0)
{
EditorGUILayout.BeginVertical();
GUILayout.FlexibleSpace();
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
Vector2 shapePosition = MouseToShapePoint(mousePosition);
GUILayout.Label("Mouse");
GUILayout.Label("X", GUILayout.Width(10f));
GUILayout.Label(shapePosition.x.ToString("F2"), EditorStyles.textField, GUILayout.Width(50f));
GUILayout.Label("Y", GUILayout.Width(10f));
GUILayout.Label(shapePosition.y.ToString("F2"), EditorStyles.textField, GUILayout.Width(50f));
EditorGUILayout.Space();
EditorGUILayout.LabelField("Background", GUILayout.MaxWidth(70f));
backgroundColor = EditorGUILayout.ColorField(backgroundColor, GUILayout.MaxWidth(colorFieldWidth));
EditorGUILayout.Space();
EditorGUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
EditorGUILayout.EndVertical();
}
GUILayout.EndArea();
}
19
View Source File : CFX_Demo.cs
License : MIT License
Project Creator : Crazy-Marvin
License : MIT License
Project Creator : Crazy-Marvin
void OnGUI()
{
GUILayout.BeginArea(new Rect(5,20,Screen.width-10,30));
GUILayout.BeginHorizontal();
GUILayout.Label("Effect", GUILayout.Width(50));
if(GUILayout.Button("<",GUILayout.Width(20)))
{
prevParticle();
}
GUILayout.Label(ParticleExamples[exampleIndex].name, GUILayout.Width(190));
if(GUILayout.Button(">",GUILayout.Width(20)))
{
nextParticle();
}
GUILayout.Label("Click on the ground to spawn selected particles");
if(GUILayout.Button(CFX_Demo_RotateCamera.rotating ? "Pause Camera" : "Rotate Camera", GUILayout.Width(140)))
{
CFX_Demo_RotateCamera.rotating = !CFX_Demo_RotateCamera.rotating;
}
if(GUILayout.Button(randomSpawns ? "Stop Random Spawns" : "Start Random Spawns", GUILayout.Width(140)))
{
randomSpawns = !randomSpawns;
if(randomSpawns) StartCoroutine("RandomSpawnsCoroutine");
else StopCoroutine("RandomSpawnsCoroutine");
}
randomSpawnsDelay = GUILayout.TextField(randomSpawnsDelay, 10, GUILayout.Width(42));
randomSpawnsDelay = Regex.Replace(randomSpawnsDelay, @"[^0-9.]", "");
if(GUILayout.Button(this.GetComponent<Renderer>().enabled ? "Hide Ground" : "Show Ground", GUILayout.Width(90)))
{
this.GetComponent<Renderer>().enabled = !this.GetComponent<Renderer>().enabled;
}
if(GUILayout.Button(slowMo ? "Normal Speed" : "Slow Motion", GUILayout.Width(100)))
{
slowMo = !slowMo;
if(slowMo) Time.timeScale = 0.33f;
else Time.timeScale = 1.0f;
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
19
View Source File : ClipCurveEditor.cs
License : MIT License
Project Creator : BattleDawnNZ
License : MIT License
Project Creator : BattleDawnNZ
public void DrawHeader(Rect headerRect)
{
m_BindingHierarchy.InitIfNeeded(headerRect, m_DataSource, isNewSelection);
try
{
GUILayout.BeginArea(headerRect);
m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition, GUIStyle.none, GUI.skin.verticalScrollbar);
m_BindingHierarchy.OnGUI(new Rect(0, 0, headerRect.width, headerRect.height));
GUILayout.EndScrollView();
GUILayout.EndArea();
}
catch (Exception e)
{
Debug.LogException(e);
}
}
19
View Source File : DefaultGraphRenderer.cs
License : MIT License
Project Creator : huailiang
License : MIT License
Project Creator : huailiang
private void DrawLegend(GraphSettings graphSettings, Rect legendArea)
{
EditorGUI.DrawRect(legendArea, s_LegendBackground);
// Add a border around legend area
legendArea.x += s_BorderSize;
legendArea.width -= s_BorderSize * 2;
legendArea.y += s_BorderSize;
legendArea.height -= s_BorderSize * 2;
GUILayout.BeginArea(legendArea);
GUILayout.BeginVertical();
if (graphSettings.showInspector)
{
GUILayout.Label("Inspector", m_SubreplacedleStyle);
if (m_SelectedNode != null)
{
using (var scrollView = new EditorGUILayout.ScrollViewScope(m_ScrollPos))
{
m_ScrollPos = scrollView.scrollPosition;
GUILayout.Label(m_SelectedNode.ToString(), m_InspectorStyle);
}
}
else
{
GUILayout.Label("Click on a node\nto display its details.");
}
}
GUILayout.FlexibleSpace();
if (graphSettings.showLegend)
{
GUILayout.Label("Legend", m_SubreplacedleStyle);
foreach (var pair in m_LegendForType)
{
DrawLegendEntry(pair.Value.color, pair.Value.label, false);
}
DrawLegendEntry(Color.gray, "Playing", true);
GUILayout.Space(20);
GUILayout.Label("Edge weight", m_SubreplacedleStyle);
GUILayout.BeginHorizontal();
GUILayout.Label("0");
GUILayout.FlexibleSpace();
GUILayout.Label("1");
GUILayout.EndHorizontal();
DrawEdgeWeightColorBar(legendArea.width);
GUILayout.Space(20);
}
GUILayout.EndVertical();
GUILayout.EndArea();
}
19
View Source File : OneTimeActionExample.cs
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
private void OnGUI()
{
GUILayout.BeginArea(new Rect(5f, 50f, 400f, 200f), GUI.skin.window);
GUILayout.Label("One Time Action Example\n\n");
GUILayout.Label("Press the number key, to see the corresponding action (in the console):");
GUILayout.Label("1. Immediate Execution (next frame)");
GUILayout.Label("2. Delayed execution (2 seconds)");
GUILayout.EndArea();
}
19
View Source File : SampleSelector.cs
License : MIT License
Project Creator : huanzi-qch
License : MIT License
Project Creator : huanzi-qch
private void DrawSampleDetails(SampleDescriptor sample)
{
Rect area = new Rect(Screen.width / 3, statisticsHeight + 5, (Screen.width / 3) * 2, Screen.height - statisticsHeight - 5);
GUI.Box(area, string.Empty);
GUILayout.BeginArea(area);
GUILayout.BeginVertical();
GUIHelper.DrawCenteredText(sample.DisplayName);
GUILayout.Space(5);
GUILayout.Label(sample.Description);
GUILayout.FlexibleSpace();
if (GUILayout.Button("Start Sample"))
sample.CreateUnityObject();
GUILayout.EndVertical();
GUILayout.EndArea();
}
19
View Source File : RotationLimitSplineInspector.cs
License : GNU General Public License v3.0
Project Creator : brandonmousseau
License : GNU General Public License v3.0
Project Creator : brandonmousseau
void OnSceneGUI()
{
GUI.changed = false;
// Get the keyframes of the AnimationCurve to be manipulated
Keyframe[] keys = script.spline.keys;
// Set defaultLocalRotation so that the initial local rotation will be the zero point for the rotation limit
if (!Application.isPlaying && !script.defaultLocalRotationOverride) script.defaultLocalRotation = script.transform.localRotation;
if (script.axis == Vector3.zero) return;
// Make the curve loop
script.spline.postWrapMode = WrapMode.Loop;
script.spline.preWrapMode = WrapMode.Loop;
DrawRotationSphere(script.transform.position);
// Display the main axis
DrawArrow(script.transform.position, Direction(script.axis), colorDefault, "Axis", 0.02f);
Vector3 swing = script.axis.normalized;
// Editing tools GUI
Handles.BeginGUI();
GUILayout.BeginArea(new Rect(10, 10, 440, 100), "Rotation Limit Spline", "Window");
// Scale Mode and Tangent Mode
GUILayout.BeginHorizontal();
scaleMode = (ScaleMode)EditorGUILayout.EnumPopup("Drag Handle", scaleMode);
tangentMode = (TangentMode)EditorGUILayout.EnumPopup("Drag Tangents", tangentMode);
GUILayout.EndHorizontal();
EditorGUILayout.Space();
if (Inspector.Button("Rotate 90 degrees", "Rotate rotation limit around axis.", script, GUILayout.Width(220)))
{
if (!Application.isPlaying) Undo.RecordObject(script, "Handle Value");
for (int i = 0; i < keys.Length; i++) keys[i].time += 90;
}
// Cloning values from another RotationLimitSpline
EditorGUILayout.BeginHorizontal();
if (Inspector.Button("Clone From", "Make this rotation limit identical to another", script, GUILayout.Width(220)))
{
CloneLimit();
keys = script.spline.keys;
}
clone = (RotationLimitSpline)EditorGUILayout.ObjectField("", clone, typeof(RotationLimitSpline), true);
EditorGUILayout.EndHorizontal();
GUILayout.EndArea();
Handles.EndGUI();
// Draw keyframes
for (int i = 0; i < keys.Length - 1; i++)
{
float angle = keys[i].time;
// Start drawing handles
Quaternion offset = Quaternion.AngleAxis(angle, swing);
Quaternion rotation = Quaternion.AngleAxis(keys[i].value, offset * script.crossAxis);
Vector3 position = script.transform.position + Direction(rotation * swing);
Handles.Label(position, " " + i.ToString());
// Dragging Values
if (selectedHandle == i)
{
Handles.color = colorHandles;
switch (scaleMode)
{
case ScaleMode.Limit:
float inputValue = keys[i].value;
inputValue = Mathf.Clamp(Inspector.ScaleValueHandleSphere(inputValue, position, Quaternion.idenreplacedy, 0.5f, 0), 0.01f, 180);
if (keys[i].value != inputValue)
{
if (!Application.isPlaying) Undo.RecordObject(script, "Handle Value");
keys[i].value = inputValue;
}
break;
case ScaleMode.Angle:
float inputTime = keys[i].time;
inputTime = Inspector.ScaleValueHandleSphere(inputTime, position, Quaternion.idenreplacedy, 0.5f, 0);
if (keys[i].time != inputTime)
{
if (!Application.isPlaying) Undo.RecordObject(script, "Handle Angle");
keys[i].time = inputTime;
}
break;
}
}
// Handle select button
if (selectedHandle != i)
{
Handles.color = Color.blue;
if (Inspector.SphereButton(position, script.transform.rotation, 0.05f, 0.05f))
{
selectedHandle = i;
}
}
// Tangents
if (selectedHandle == i)
{
// Evaluate positions before and after the key to get the tangent positions
Vector3 prevPosition = GetAnglePosition(keys[i].time - 1);
Vector3 nextPosition = GetAnglePosition(keys[i].time + 1);
// Draw handles for the tangents
Handles.color = Color.white;
Vector3 toNext = (nextPosition - position).normalized * 0.3f;
float outTangent = keys[i].outTangent;
outTangent = Inspector.ScaleValueHandleSphere(outTangent, position + toNext, Quaternion.idenreplacedy, 0.2f, 0);
Vector3 toPrev = (prevPosition - position).normalized * 0.3f;
float inTangent = keys[i].inTangent;
inTangent = Inspector.ScaleValueHandleSphere(inTangent, position + toPrev, Quaternion.idenreplacedy, 0.2f, 0);
if (outTangent != keys[i].outTangent || inTangent != keys[i].inTangent) selectedHandle = i;
// Make the other tangent match the dragged tangent (if in "Smooth" TangentMode)
switch (tangentMode)
{
case TangentMode.Smooth:
if (outTangent != keys[i].outTangent)
{
if (!Application.isPlaying) Undo.RecordObject(script, "Tangents");
keys[i].outTangent = outTangent;
keys[i].inTangent = outTangent;
}
else if (inTangent != keys[i].inTangent)
{
if (!Application.isPlaying) Undo.RecordObject(script, "Tangents");
keys[i].outTangent = inTangent;
keys[i].inTangent = inTangent;
}
break;
case TangentMode.Independent:
if (outTangent != keys[i].outTangent)
{
if (!Application.isPlaying) Undo.RecordObject(script, "Tangents");
keys[i].outTangent = outTangent;
}
else if (inTangent != keys[i].inTangent)
{
if (!Application.isPlaying) Undo.RecordObject(script, "Tangents");
keys[i].inTangent = inTangent;
}
break;
}
// Draw lines and labels to tangent handles
Handles.color = Color.white;
GUI.color = Color.white;
Handles.DrawLine(position, position + toNext);
Handles.Label(position + toNext, " Out");
Handles.DrawLine(position, position + toPrev);
Handles.Label(position + toPrev, " In");
}
}
// Selected Point GUI
if (selectedHandle != -1)
{
Handles.BeginGUI();
GUILayout.BeginArea(new Rect(Screen.width - 240, Screen.height - 200, 230, 150), "Handle " + selectedHandle.ToString(), "Window");
if (Inspector.Button("Delete", "Delete this handle", script))
{
if (keys.Length > 4)
{
deleteHandle = selectedHandle;
}
else if (!Warning.logged) script.LogWarning("Spline Rotation Limit should have at least 3 handles");
}
if (Inspector.Button("Add Handle", "Add a new handle next to this one", script))
{
addHandle = selectedHandle;
}
// Clamp the key angles to previous and next handle angles
float prevTime = 0, nextTime = 0;
if (selectedHandle < keys.Length - 2) nextTime = keys[selectedHandle + 1].time;
else nextTime = keys[0].time + 360;
if (selectedHandle == 0) prevTime = keys[keys.Length - 2].time - 360;
else prevTime = keys[selectedHandle - 1].time;
// Angles
float inputTime = keys[selectedHandle].time;
inputTime = Mathf.Clamp(EditorGUILayout.FloatField(new GUIContent("Angle", "Angle of the point (0-360)."), inputTime), prevTime, nextTime);
if (keys[selectedHandle].time != inputTime)
{
if (!Application.isPlaying) Undo.RecordObject(script, "Handle Angle");
keys[selectedHandle].time = inputTime;
}
// Limits
float inputValue = keys[selectedHandle].value;
inputValue = Mathf.Clamp(EditorGUILayout.FloatField(new GUIContent("Limit", "Max angular limit from Axis at this angle"), inputValue), 0, 180);
if (keys[selectedHandle].value != inputValue)
{
if (!Application.isPlaying) Undo.RecordObject(script, "Handle Limit");
keys[selectedHandle].value = inputValue;
}
// In Tangents
float inputInTangent = keys[selectedHandle].inTangent;
inputInTangent = EditorGUILayout.FloatField(new GUIContent("In Tangent", "In tangent of the handle point on the spline"), inputInTangent);
if (keys[selectedHandle].inTangent != inputInTangent)
{
if (!Application.isPlaying) Undo.RecordObject(script, "Handle In Tangent");
keys[selectedHandle].inTangent = inputInTangent;
}
// Out tangents
float inputOutTangent = keys[selectedHandle].outTangent;
inputOutTangent = EditorGUILayout.FloatField(new GUIContent("Out Tangent", "Out tangent of the handle point on the spline"), inputOutTangent);
if (keys[selectedHandle].outTangent != inputOutTangent)
{
if (!Application.isPlaying) Undo.RecordObject(script, "Handle Out Tangent");
keys[selectedHandle].outTangent = inputOutTangent;
}
GUILayout.EndArea();
Handles.EndGUI();
}
// Make sure the keyframes are valid;
ValidateKeyframes(keys);
// Replace the AnimationCurve keyframes with the manipulated keyframes
script.spline.keys = keys;
// Display limits
for (int i = 0; i < 360; i += 2)
{
float evaluatedLimit = script.spline.Evaluate((float)i);
Quaternion offset = Quaternion.AngleAxis(i, swing);
Quaternion evaluatedRotation = Quaternion.AngleAxis(evaluatedLimit, offset * script.crossAxis);
Quaternion testRotation = Quaternion.AngleAxis(179.9f, offset * script.crossAxis);
Quaternion limitedRotation = script.LimitSwing(testRotation);
Vector3 evaluatedDirection = evaluatedRotation * swing;
Vector3 limitedDirection = limitedRotation * swing;
// Display the limit points in red if they are out of range
bool isValid = Vector3.Distance(evaluatedDirection, limitedDirection) < 0.01f && evaluatedLimit >= 0;
Color color = isValid ? colorDefaultTransparent : colorInvalid;
Vector3 limitPoint = script.transform.position + Direction(evaluatedDirection);
Handles.color = color;
if (i == 0) zeroPoint = limitPoint;
Handles.DrawLine(script.transform.position, limitPoint);
if (i > 0)
{
Handles.color = isValid ? colorDefault : colorInvalid;
Handles.DrawLine(limitPoint, lastPoint);
if (i == 358) Handles.DrawLine(limitPoint, zeroPoint);
}
lastPoint = limitPoint;
}
// Deleting points
if (deleteHandle != -1)
{
DeleteHandle(deleteHandle);
selectedHandle = -1;
deleteHandle = -1;
}
// Adding points
if (addHandle != -1)
{
AddHandle(addHandle);
addHandle = -1;
}
Handles.color = Color.white;
if (GUI.changed) EditorUtility.SetDirty(script);
}
19
View Source File : MLSystemEditor.cs
License : MIT License
Project Creator : Interactml
License : MIT License
Project Creator : Interactml
protected void ShowButtons(MLSystem node)
{
m_ButtonsRect.x = m_BodyRect.x -5 ;
m_ButtonsRect.y = m_IconCenter.y + m_IconCenter.height;
m_ButtonsRect.width = m_BodyRect.width -10;
m_ButtonsRect.height = 150;
GUILayout.Space(230);
// DRAW BUTTONS AND PORTS OUTSIDE OF BEGIN AREA TO MAKE THEM WORK
GUILayout.BeginHorizontal();
// Draw port
IMLNodeEditor.PortField(m_ButtonPortLabel, m_ButtonPortToggleTrainInput, m_NodeSkin.GetStyle("Port Label"), GUILayout.MaxWidth(10));
// if button contains mouse position
TrainModelButton();
GUILayout.EndHorizontal();
GUILayout.Space(15);
GUILayout.BeginHorizontal();
// Draw port
IMLNodeEditor.PortField(m_ButtonPortLabel, m_ButtonPortToggleRunInput, m_NodeSkin.GetStyle("Port Label"), GUILayout.MaxWidth(10));
RunModelButton();
GUILayout.EndHorizontal();
GUILayout.BeginArea(m_ButtonsRect);
//GUILayout.Space(20);
GUILayout.BeginHorizontal();
GUILayout.Space(NodeWidth / 2 - 20);
if (GUILayout.Button("", m_NodeSkin.GetStyle("Reset")))
{
node.ResetModel();
numberOfExamplesTrained = 0;
}
GUILayout.EndHorizontal();
GUILayout.Space(5);
GUILayout.BeginHorizontal();
GUILayout.Space(20);
GUILayout.Label("reset model", m_NodeSkin.GetStyle("Reset Pink Label"));
GUILayout.EndHorizontal();
//ShowRunOnAwakeToggle(node);
GUILayout.EndArea();
}
19
View Source File : LoadBalancerAdvancedDemoControl.cs
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
private void OnGUI()
{
GUILayout.BeginArea(new Rect(5f, 0f, Screen.width - 5f, 40f));
GUILayout.BeginHorizontal();
if (GUILayout.Button("One Time Action", GUILayout.Height(30f)))
{
Toggle<OneTimeActionExample>();
}
GUILayout.Space(6f);
if (GUILayout.Button("Repeatable Action", GUILayout.Height(30f)))
{
Toggle<RepetableActionExample>();
}
GUILayout.Space(6f);
if (GUILayout.Button("Long Running Action", GUILayout.Height(30f)))
{
Toggle<LongRunningActionExample>();
}
GUILayout.Space(6f);
if (GUILayout.Button("Pooled Actions", GUILayout.Height(30f)))
{
Toggle<PooledActionsExample>();
}
GUILayout.Space(6f);
if (GUILayout.Button("Marshaller", GUILayout.Height(30f)))
{
Toggle<MarshallerExample>();
}
GUILayout.Space(6f);
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
19
View Source File : DistanceToFirstInputNodeEditor.cs
License : MIT License
Project Creator : Interactml
License : MIT License
Project Creator : Interactml
protected override void ShowBodyFields()
{
m_InnerBodyRect.x = m_BodyRect.x + 20;
m_InnerBodyRect.y = m_BodyRect.y + 20;
m_InnerBodyRect.width = m_BodyRect.width - 20;
m_InnerBodyRect.height = m_BodyRect.height - 20;
GUILayout.BeginArea(m_InnerBodyRect);
// check if there are any feature connected
if (m_ExtractDistanceToFirstInput.FeatureValues.Values != null && m_ExtractDistanceToFirstInput.FeatureValues.Values.Length != 0)
{
// dynamically adjust node length based on amount of velocity features
nodeSpace = 120 + (m_ExtractDistanceToFirstInput.FeatureValues.Values.Length * 20);
m_BodyRect.height = 60 + (m_ExtractDistanceToFirstInput.FeatureValues.Values.Length * 20);
//draws node data fields
MovementFeatureEditorMethods.DrawFeatureValueToggleAndLabelDynamic(this, m_ExtractDistanceToFirstInput);
}
else
{
// set node length
nodeSpace = 120;
m_BodyRect.height = 60;
// print alert on node
EditorGUILayout.LabelField("Connect 2 inputs", m_NodeSkin.GetStyle("Node Body Label"));
}
GUILayout.EndArea();
}
19
View Source File : AttackDefinitionEditorWindow.cs
License : MIT License
Project Creator : christides11
License : MIT License
Project Creator : christides11
protected virtual void OnGUI()
{
if(attack == null)
{
Close();
return;
}
var pos = position;
pos.x = 0;
pos.y = 0;
pos.height /= 2.75f;
pos.height = Mathf.Min(250, pos.height);
Event e = Event.current;
switch (e.type)
{
case EventType.MouseDown:
if (pos.Contains(Event.current.mousePosition))
{
if (Event.current.button == 0)
{
mousePos = Event.current.mousePosition;
moveMode = true;
} else if (Event.current.button == 1)
{
mousePos = Event.current.mousePosition;
rotationMode = true;
}
}
break;
case EventType.MouseUp:
if(Event.current.button == 0)
{
moveMode = false;
}
if (Event.current.button == 1)
{
rotationMode = false;
}
break;
case EventType.MouseDrag:
if (rotationMode || moveMode)
{
diff = Event.current.mousePosition - mousePos;
mousePos = Event.current.mousePosition;
}
break;
case EventType.ScrollWheel:
if (rotationMode)
{
scrollWheel = Event.current.delta.y;
}
break;
}
renderUtils.BeginPreview(pos, EditorStyles.helpBox);
DrawGround();
DrawHurtboxes();
DrawHitboxes();
renderUtils.Render(false, false);
renderUtils.EndAndDrawPreview(pos);
if (scrollWheel != 0)
{
renderUtils.camera.transform.position += renderUtils.camera.transform.forward * scrollWheel * scrollSpeed;
scrollWheel = 0;
}
if (diff.magnitude > 0)
{
if (moveMode)
{
renderUtils.camera.transform.position += new Vector3(0, diff.y * moveSpeed * Time.deltaTime, 0);
}
if (rotationMode)
{
renderUtils.camera.transform.RotateAround(new Vector3(0, renderUtils.camera.transform.position.y, 0), Vector3.up, diff.x * rotSpeed);
}
diff = Vector2.zero;
}
EditorGUILayout.BeginHorizontal();
GUILayout.Label("fr:", GUILayout.Width(15));
GUILayout.Label(timelineFrame.ToString(), GUILayout.Width(20));
GUILayout.Label("/", GUILayout.Width(10));
GUILayout.Label(attack.length.ToString(), GUILayout.Width(55));
EditorGUILayout.EndHorizontal();
if (visualFighterSceneReference)
{
EditorGUILayout.BeginHorizontal();
GUILayout.Label("x:", GUILayout.Width(13));
GUILayout.Label(visualFighterSceneReference.transform.position.x.ToString("F1"), GUILayout.Width(25));
GUILayout.Label("y:", GUILayout.Width(13));
GUILayout.Label(visualFighterSceneReference.transform.position.y.ToString("F1"), GUILayout.Width(25));
GUILayout.Label("z:", GUILayout.Width(13));
GUILayout.Label(visualFighterSceneReference.transform.position.z.ToString("F1"), GUILayout.Width(25));
EditorGUILayout.EndHorizontal();
}
if (attack == null)
{
return;
}
SerializedObject serializedObject = new SerializedObject(attack);
serializedObject.Update();
GUILayout.BeginArea(new Rect(pos.x, pos.y + pos.height, pos.width, position.height - pos.height));
DrawGeneralOptions(serializedObject);
if (attack.useState)
{
//GUILayout.EndArea();
serializedObject.ApplyModifiedProperties();
}
GUILayout.BeginHorizontal();
MenuBar(serializedObject);
GUILayout.EndHorizontal();
GUILayout.Space(10);
if (visualFighterSceneReference)
{
if(GUILayout.Button("Open Fighter Inspector"))
{
Selection.activeObject = visualFighterSceneReference.gameObject;
}
}
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button(EditorGUIUtility.IconContent("d_Profiler.PrevFrame"), GUILayout.Width(30)))
{
timelineFrame = Mathf.Max(0, timelineFrame - 1);
FastForward();
}
if (GUILayout.Button(EditorGUIUtility.IconContent("d_Profiler.NextFrame"), GUILayout.Width(30)))
{
IncrementForward();
}
if (GUILayout.Button(EditorGUIUtility.IconContent("d_preAudioAutoPlayOff"), GUILayout.Width(30), GUILayout.Height(18)))
{
FastForward();
}
if (GUILayout.Button(EditorGUIUtility.IconContent("d_Profiler.LastFrame"), GUILayout.Width(30)))
{
autoplay = !autoplay;
if (autoplay)
{
nextPlayTime = EditorApplication.timeSinceStartup + playInterval;
}
}
if (autoplay && visualFighterSceneReference != null && EditorApplication.timeSinceStartup >= nextPlayTime)
{
if (timelineFrame + 1 > attack.length)
{
timelineFrame = 0;
FastForward();
}
else
{
IncrementForward();
}
nextPlayTime = EditorApplication.timeSinceStartup + playInterval;
}
timelineFrame = (int)EditorGUILayout.Slider(timelineFrame, 0, attack.length);
EditorGUILayout.EndHorizontal();
GUILayout.Space(10);
scroll = EditorGUILayout.BeginScrollView(scroll);
if (showHitboxGroups)
{
DrawHitboxGroupBars(serializedObject);
}
GUILayout.Space(10);
if (showEvents)
{
DrawEventBars(serializedObject);
}
GUILayout.Space(10);
if (showCharges)
{
DrawChargeBars(serializedObject);
}
GUILayout.Space(10);
if (showCancels)
{
DrawCancelBars(serializedObject);
}
EditorGUILayout.EndScrollView();
GUILayout.EndArea();
serializedObject.ApplyModifiedProperties();
}
19
View Source File : ZoomableArea.cs
License : MIT License
Project Creator : Crazy-Marvin
License : MIT License
Project Creator : Crazy-Marvin
public void HandleZoomAndPanEvents(Rect area)
{
GUILayout.BeginArea(area);
area.x = 0f;
area.y = 0f;
int controlID = GUIUtility.GetControlID(ZoomableArea.zoomableAreaHash, FocusType.Preplacedive, area);
switch (Event.current.GetTypeForControl(controlID))
{
case EventType.MouseDown:
if (area.Contains(Event.current.mousePosition))
{
GUIUtility.keyboardControl = controlID;
if (this.IsZoomEvent() || this.IsPanEvent())
{
GUIUtility.hotControl = controlID;
ZoomableArea.m_MouseDownPosition = this.mousePositionInDrawing;
Event.current.Use();
}
}
break;
case EventType.MouseUp:
if (GUIUtility.hotControl == controlID)
{
GUIUtility.hotControl = 0;
ZoomableArea.m_MouseDownPosition = new Vector2(-1000000f, -1000000f);
}
break;
case EventType.MouseDrag:
if (GUIUtility.hotControl == controlID)
{
if (this.IsZoomEvent())
{
this.Zoom(ZoomableArea.m_MouseDownPosition, false);
Event.current.Use();
}
else
{
if (this.IsPanEvent())
{
this.Pan();
Event.current.Use();
}
}
}
break;
case EventType.ScrollWheel:
if (area.Contains(Event.current.mousePosition))
{
if (!this.m_IgnoreScrollWheelUntilClicked || GUIUtility.keyboardControl == controlID)
{
this.Zoom(this.mousePositionInDrawing, true);
Event.current.Use();
}
}
break;
}
GUILayout.EndArea();
}
19
View Source File : LoadBalancerBasicDemoControl.cs
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
private void OnGUI()
{
GUILayout.BeginArea(new Rect(5f, 0f, Screen.width - 5f, 40f));
GUILayout.BeginHorizontal();
if (GUILayout.Button("Update", GUILayout.Height(30f)))
{
Toggle<PillarToggle>();
}
GUILayout.Space(6f);
if (GUILayout.Button("Coroutine", GUILayout.Height(30f)))
{
Toggle<PillarToggleCoroutine>();
}
GUILayout.Space(6f);
if (GUILayout.Button("Load Balancer", GUILayout.Height(30f)))
{
Toggle<PillarToggleBalanced>();
}
GUILayout.Space(6f);
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
19
View Source File : CFX3_Demo.cs
License : MIT License
Project Creator : Crazy-Marvin
License : MIT License
Project Creator : Crazy-Marvin
void OnGUI()
{
GUILayout.BeginArea(new Rect(5,20,Screen.width-10,60));
GUILayout.BeginHorizontal();
GUILayout.Label("Effect", GUILayout.Width(50));
if(GUILayout.Button("<", GUILayout.Width(25)))
{
prevParticle();
}
GUILayout.Label(ParticleExamples[exampleIndex].name, GUILayout.Width(265));
if(GUILayout.Button(">", GUILayout.Width(25)))
{
nextParticle();
}
GUILayout.Space(80);
if(GUILayout.Button(CFX_Demo_RotateCamera.rotating ? "Pause Camera" : "Rotate Camera"))
{
CFX_Demo_RotateCamera.rotating = !CFX_Demo_RotateCamera.rotating;
}
if(GUILayout.Button(randomSpawns ? "Stop Random Spawns" : "Start Random Spawns", GUILayout.Width(140)))
{
randomSpawns = !randomSpawns;
if(randomSpawns) StartCoroutine("RandomSpawnsCoroutine");
else StopCoroutine("RandomSpawnsCoroutine");
}
randomSpawnsDelay = GUILayout.TextField(randomSpawnsDelay, 10, GUILayout.Width(42));
randomSpawnsDelay = Regex.Replace(randomSpawnsDelay, @"[^0-9.]", "");
if(GUILayout.Button(groundRenderer.enabled ? "Hide Ground" : "Show Ground", GUILayout.Width(90)))
{
groundRenderer.enabled = !groundRenderer.enabled;
}
if(GUILayout.Button(slowMo ? "Normal Speed" : "Slow Motion", GUILayout.Width(100)))
{
slowMo = !slowMo;
if(slowMo) Time.timeScale = 0.33f;
else Time.timeScale = 1.0f;
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
//TEXT
GUILayout.BeginArea(new Rect(5,50,Screen.width-10,60));
GUILayout.BeginHorizontal();
GUILayout.Label("Click on the ground to spawn selected particles");
GUILayout.FlexibleSpace();
GUILayout.Label("Use the LEFT and RIGHT keys to switch effects; Press DEL to delete all effects on screen");
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
19
View Source File : CinemachinePathEditor.cs
License : MIT License
Project Creator : BattleDawnNZ
License : MIT License
Project Creator : BattleDawnNZ
void DrawSelectionHandle(int i, Matrix4x4 localToWorld)
{
if (Event.current.button != 1)
{
Vector3 pos = localToWorld.MultiplyPoint(Target.m_Waypoints[i].position);
float size = HandleUtility.GetHandleSize(pos) * 0.2f;
Handles.color = Color.white;
if (Handles.Button(pos, Quaternion.idenreplacedy, size, size, Handles.SphereHandleCap)
&& mWaypointList.index != i)
{
mWaypointList.index = i;
InspectorUtility.RepaintGameView(Target);
}
// Label it
Handles.BeginGUI();
Vector2 labelSize = new Vector2(
EditorGUIUtility.singleLineHeight * 2, EditorGUIUtility.singleLineHeight);
Vector2 labelPos = HandleUtility.WorldToGUIPoint(pos);
labelPos.y -= labelSize.y / 2;
labelPos.x -= labelSize.x / 2;
GUILayout.BeginArea(new Rect(labelPos, labelSize));
GUIStyle style = new GUIStyle();
style.normal.textColor = Color.black;
style.alignment = TextAnchor.MiddleCenter;
GUILayout.Label(new GUIContent(i.ToString(), "Waypoint " + i), style);
GUILayout.EndArea();
Handles.EndGUI();
}
}
19
View Source File : ClipCurveEditor.cs
License : GNU Lesser General Public License v3.0
Project Creator : disruptorbeam
License : GNU Lesser General Public License v3.0
Project Creator : disruptorbeam
public void DrawHeader(Rect headerRect)
{
m_BindingHierarchy.InitIfNeeded(headerRect, m_DataSource, isNewSelection);
try
{
GUILayout.BeginArea(headerRect);
m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition, GUIStyle.none, GUI.skin.verticalScrollbar);
m_BindingHierarchy.OnGUI(new Rect(0, 0, headerRect.width, headerRect.height));
if (m_BindingHierarchy.treeViewController != null)
m_BindingHierarchy.treeViewController.contextClickItemCallback = ContextClickItemCallback;
GUILayout.EndScrollView();
GUILayout.EndArea();
}
catch (Exception e)
{
Debug.LogException(e);
}
}
19
View Source File : SpriteMeshEditorWindow.cs
License : MIT License
Project Creator : Crazy-Marvin
License : MIT License
Project Creator : Crazy-Marvin
override protected void OnGUI()
{
Matrix4x4 matrix = Handles.matrix;
textureColor = Color.gray;
if (!m_SpriteMeshCache || !m_SpriteMeshCache.spriteMesh)
{
EditorGUI.BeginDisabledGroup(true);
GUILayout.Label("No sprite mesh selected");
EditorGUI.EndDisabledGroup();
}else{
/*
if(m_Style == null || m_DefaultWindowStyle == null)
{
m_DefaultWindowStyle = GUI.skin.window;
m_Style = new GUIStyle(m_DefaultWindowStyle);
m_Style.active.background = null;
m_Style.focused.background = null;
m_Style.hover.background = null;
m_Style.normal.background = null;
m_Style.onActive.background = null;
m_Style.onFocused.background = null;
m_Style.onHover.background = null;
m_Style.onNormal.background = null;
}
*/
autoRepaintOnSceneChange = true;
wantsMouseMove = true;
HotKeys();
if(Event.current.type == EventType.MouseUp && Event.current.button == 1)
{
meshToolEditor.tool = MeshToolEditor.MeshTool.None;
}
base.OnGUI();
GUI.color = Color.white;
GUILayout.BeginArea(m_TextureViewRect);
BeginWindows();
//GUI.skin.window = m_Style;
if(m_SpriteMeshCache.mode == Mode.Mesh)
{
meshToolEditor.spriteMeshCache = m_SpriteMeshCache;
meshToolEditor.OnWindowGUI(m_TextureViewRect);
}else if(m_SpriteMeshCache.mode == Mode.Blendshapes)
{
blendShapeEditor.spriteMeshCache = m_SpriteMeshCache;
blendShapeEditor.OnWindowGUI(m_TextureViewRect);
}
//GUI.skin.window = m_DefaultWindowStyle;
sliceEditor.spriteMeshCache = m_SpriteMeshCache;
sliceEditor.OnWindowGUI(m_TextureViewRect);
weightEditor.spriteMeshCache = m_SpriteMeshCache;
weightEditor.OnWindowGUI(m_TextureViewRect);
blendShapeFrameEditor.spriteMeshCache = m_SpriteMeshCache;
blendShapeFrameEditor.OnWindowGUI(m_TextureViewRect);
inspectorEditor.spriteMeshCache = m_SpriteMeshCache;
inspectorEditor.OnWindowGUI(m_TextureViewRect);
EndWindows();
if(m_SpriteMeshCache.mode == Mode.Mesh &&
!meshToolEditor.sliceToggle)
{
HandleDeleteVertex();
HandleDeleteHole();
HandleDeleteEdge();
HandleDeleteBone();
HandleDeleteBindPose();
}
GUILayout.EndArea();
}
Handles.matrix = matrix;
if(GUIUtility.hotControl == 0 && HandleUtility.nearestControl != m_LastNearestControl)
{
m_LastNearestControl = HandleUtility.nearestControl;
Repaint();
}
}
19
View Source File : AboutWindow.cs
License : MIT License
Project Creator : BattleDawnNZ
License : MIT License
Project Creator : BattleDawnNZ
private void OnGUI()
{
if (EditorApplication.isCompiling)
{
Close();
}
if (mButtonStyle == null)
{
mButtonStyle = new GUIStyle(GUI.skin.button);
mButtonStyle.richText = true;
}
if (mLabelStyle == null)
{
mLabelStyle = new GUIStyle(EditorStyles.label);
mLabelStyle.wordWrap = true;
mLabelStyle.richText = true;
}
if (mHeaderStyle == null)
{
mHeaderStyle = new GUIStyle(EditorStyles.boldLabel);
mHeaderStyle.wordWrap = true;
}
if (mNotesStyle == null)
{
mNotesStyle = new GUIStyle(EditorStyles.textArea);
mNotesStyle.richText = true;
mNotesStyle.wordWrap = true;
}
using (var vertScope = new EditorGUILayout.VerticalScope())
{
if (CinemachineSettings.CinemachineHeader != null)
{
float headerWidth = position.width;
float aspectRatio = (float)CinemachineSettings.CinemachineHeader.height / (float)CinemachineSettings.CinemachineHeader.width;
GUILayout.BeginScrollView(Vector2.zero, false, false, GUILayout.Width(headerWidth), GUILayout.Height(headerWidth * aspectRatio));
Rect texRect = new Rect(0f, 0f, headerWidth, headerWidth * aspectRatio);
GUILayout.FlexibleSpace();
GUILayout.BeginArea(texRect);
GUI.DrawTexture(texRect, CinemachineSettings.CinemachineHeader, ScaleMode.ScaleToFit);
GUILayout.EndArea();
GUILayout.FlexibleSpace();
GUILayout.EndScrollView();
}
EditorGUILayout.LabelField("Welcome to Cinemachine!", mLabelStyle);
EditorGUILayout.LabelField("Smart camera tools for preplacedionate creators.", mLabelStyle);
EditorGUILayout.LabelField("Below are links to the forums, please reach out if you have any questions or feedback", mLabelStyle);
if (GUILayout.Button("<b>Forum</b>\n<i>Discuss</i>", mButtonStyle))
{
Application.OpenURL("https://forum.unity3d.com/forums/cinemachine.136/");
}
if (GUILayout.Button("<b>Rate it!</b>\nUnity replacedet Store", mButtonStyle))
{
Application.OpenURL("https://www.replacedetstore.unity3d.com/en/#!/content/79898");
}
}
EditorGUILayout.LabelField("Release Notes", mHeaderStyle);
using (var scrollScope = new EditorGUILayout.ScrollViewScope(mReleaseNoteScrollPos, GUI.skin.box))
{
mReleaseNoteScrollPos = scrollScope.scrollPosition;
EditorGUILayout.LabelField(mReleaseNotes, mNotesStyle);
}
}
19
View Source File : LevelEditorResourcesWindow.cs
License : MIT License
Project Creator : Hertzole
License : MIT License
Project Creator : Hertzole
void BottomToolbar(Rect rect)
{
GUILayout.BeginArea(rect);
using (new EditorGUILayout.HorizontalScope())
{
if (GUILayout.Button("Expand All"))
{
treeView.ExpandAll();
}
if (GUILayout.Button("Collapse All"))
{
treeView.CollapseAll();
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Add Item to Root"))
{
treeView.AddItemToRoot();
}
}
GUILayout.EndArea();
}
19
View Source File : MarshallerExample.cs
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
private void OnGUI()
{
GUILayout.BeginArea(new Rect(5f, 50f, 400f, 200f), GUI.skin.window);
GUILayout.Label("Marshaller Example\n\n");
GUILayout.Label("Press the number key, to see the corresponding action (in the console):");
GUILayout.Label("1. Attempting to perform a Unity action on another thread.");
GUILayout.Label("2. Marshalling the same to the Main thread, thus succeeding.");
GUILayout.EndArea();
}
19
View Source File : OSCPanelConsole.cs
License : MIT License
Project Creator : hizzlehoff
License : MIT License
Project Creator : hizzlehoff
private void DrawToolbar(Rect contentRect)
{
GUILayout.BeginArea(new Rect(0, 0, contentRect.width, 18));
EditorGUILayout.BeginVertical();
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
var clearButton = GUILayout.Button(_clearContent, EditorStyles.toolbarButton, GUILayout.Height(45f));
GUILayout.Space(5f);
ShowReceived = GUILayout.Toggle(ShowReceived, _recevedContent, EditorStyles.toolbarButton);
ShowTransmitted = GUILayout.Toggle(ShowTransmitted, _transmittedContent, EditorStyles.toolbarButton);
GUILayout.FlexibleSpace();
GUILayout.Space(5f);
_filterDrawer.Draw();
GUILayout.Space(5f);
TrackLast = GUILayout.Toggle(TrackLast, _trackLastContent, EditorStyles.toolbarButton);
GUILayout.Space(5f);
EditorGUILayout.EndHorizontal();
EditorGUILayout.EndVertical();
GUILayout.EndArea();
if (clearButton)
{
OSCWindowConsole.Clear();
SelectedMessage = null;
}
}
19
View Source File : GUIDebug.cs
License : MIT License
Project Creator : blueinsert
License : MIT License
Project Creator : blueinsert
private void ShowMessage(Dictionary<string, string> msgDic, int areaIndex)
{
GUIStyle fontStyle = new GUIStyle();
fontStyle.normal.background = null; //设置背景填充
fontStyle.normal.textColor = new Color(0, 0, 1); //设置字体颜色
fontStyle.fontSize = 35; //字体大小
var areaStartPos = m_areaStartPos[areaIndex];
GUI.color = Color.blue;
GUILayout.BeginArea(new UnityEngine.Rect(areaStartPos.x, areaStartPos.y, m_areaSize.x, m_areaSize.y));
m_scrollPositions[areaIndex] = GUILayout.BeginScrollView(m_scrollPositions[areaIndex], GUILayout.Width(Screen.width / 2), GUILayout.Height(Screen.height));
GUILayout.BeginVertical();
foreach (var kv in msgDic)
{
GUILayout.Label(new GUIContent(kv.Key + ":" + kv.Value), fontStyle);
}
GUILayout.EndVertical();
GUILayout.EndScrollView();
GUILayout.EndArea();
}
19
View Source File : EditorTrack.cs
License : MIT License
Project Creator : huailiang
License : MIT License
Project Creator : huailiang
protected void GUIHeader()
{
var tmp = RenderHead;
tmp.y += tmp.height / 4;
GUILayout.BeginArea(tmp);
GUILayout.BeginHorizontal();
GUILayout.Space(5);
GUILayout.Label(trackHeader);
OnGUIHeader();
if (track.mute)
{
if (GUILayout.Button(SeqenceStyle.muteContent, SeqenceStyle.icoStyle)) track.SetFlag(TrackMode.Mute, false);
}
if (track.locked)
{
if (GUILayout.Button(SeqenceStyle.lockContent, SeqenceStyle.icoStyle)) track.SetFlag(TrackMode.Lock, false);
}
if (warn)
{
GUILayout.Label(SeqenceStyle.warn_ico, GUILayout.MaxWidth(20));
}
var tree = SeqenceWindow.inst.tree;
if (track.hasChilds)
{
GUILayout.Space(4);
if (GUILayout.Button(SeqenceStyle.sequenceSelectorIcon, SeqenceStyle.bottomShadow))
{
if (showChild)
tree.RmChildTrack(track);
else
tree.AddChildTracks(track);
showChild = !showChild;
}
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
19
View Source File : PathFinderVisualizer.cs
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
private void OnGUI()
{
if (_styles == null)
{
_styles = new Styles();
}
if (costInfo != CostDiplay.None)
{
if (Camera.main == null)
{
return;
}
var nodes = _engine.expandedSet;
for (int i = 0; i < nodes.Count; i++)
{
var n = nodes[i];
if ((n == null) || (n is PortalCell))
{
continue;
}
int cost;
switch (costInfo)
{
case CostDiplay.MoveCost:
{
cost = n.g;
break;
}
case CostDiplay.Heuristics:
{
cost = n.h;
break;
}
default:
{
cost = n.f;
break;
}
}
var pos = Camera.main.WorldToScreenPoint(n.position);
pos.y = Screen.height - pos.y;
GUI.color = Color.black;
GUI.Label(new Rect(pos.x - 10f, pos.y - 6f, 50f, 20f), cost.ToString());
}
}
if (showInstructions)
{
float width = 300f;
float height = Screen.height * 0.9f;
GUILayout.BeginArea(new Rect(5f, (Screen.height / 2f) - (height / 2f), width, height), GUI.skin.window);
GUILayout.BeginVertical();
GUILayout.Label("Path Finder Visualization", _styles.headerStyle);
GUILayout.Label("Blue Squares represent the node being processed.");
GUILayout.Label("Yellow Squares represent the nodes that have been processed (closed).");
GUILayout.Label("Green Squares represent expanded nodes yet to be processed.");
GUILayout.Label("Purple Squares represent nodes from which a portal is crossed.");
GUILayout.Label("\nLeft click to set the Starting Point.\n\nRight click to set the End Point.\n\nPress 'Space' to visualize.\n\nPress 'R' to reset.");
GUILayout.EndVertical();
GUILayout.EndArea();
}
}
19
View Source File : SampleSelector.cs
License : MIT License
Project Creator : huanzi-qch
License : MIT License
Project Creator : huanzi-qch
void OnGUI()
{
var stats = HTTPManager.GetGeneralStatistics(StatisticsQueryFlags.All);
// Connection statistics
GUIHelper.DrawArea(new Rect(0, 0, Screen.width / 3, statisticsHeight), false, () =>
{
// Header
GUIHelper.DrawCenteredText("Connections");
GUILayout.Space(5);
GUIHelper.DrawRow("Sum:", stats.Connections.ToString());
GUIHelper.DrawRow("Active:", stats.ActiveConnections.ToString());
GUIHelper.DrawRow("Free:", stats.FreeConnections.ToString());
GUIHelper.DrawRow("Recycled:", stats.RecycledConnections.ToString());
GUIHelper.DrawRow("Requests in queue:", stats.RequestsInQueue.ToString());
});
// Cache statistics
GUIHelper.DrawArea(new Rect(Screen.width / 3, 0, Screen.width / 3, statisticsHeight), false, () =>
{
GUIHelper.DrawCenteredText("Cache");
#if !BESTHTTP_DISABLE_CACHING
if (!BestHTTP.Caching.HTTPCacheService.IsSupported)
{
#endif
GUI.color = Color.yellow;
GUIHelper.DrawCenteredText("Disabled in WebPlayer, WebGL & Samsung Smart TV Builds!");
GUI.color = Color.white;
#if !BESTHTTP_DISABLE_CACHING
}
else
{
GUILayout.Space(5);
GUIHelper.DrawRow("Cached enreplacedies:", stats.CacheEnreplacedyCount.ToString());
GUIHelper.DrawRow("Sum Size (bytes): ", stats.CacheSize.ToString("N0"));
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Clear Cache"))
BestHTTP.Caching.HTTPCacheService.BeginClear();
GUILayout.EndVertical();
}
#endif
});
// Cookie statistics
GUIHelper.DrawArea(new Rect((Screen.width / 3) * 2, 0, Screen.width / 3, statisticsHeight), false, () =>
{
GUIHelper.DrawCenteredText("Cookies");
#if !BESTHTTP_DISABLE_COOKIES
if (!BestHTTP.Cookies.CookieJar.IsSavingSupported)
{
#endif
GUI.color = Color.yellow;
GUIHelper.DrawCenteredText("Saving and loading from disk is disabled in WebPlayer, WebGL & Samsung Smart TV Builds!");
GUI.color = Color.white;
#if !BESTHTTP_DISABLE_COOKIES
}
else
{
GUILayout.Space(5);
GUIHelper.DrawRow("Cookies:", stats.CookieCount.ToString());
GUIHelper.DrawRow("Estimated size (bytes):", stats.CookieJarSize.ToString("N0"));
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Clear Cookies"))
BestHTTP.Cookies.CookieJar.Clear();
GUILayout.EndVertical();
}
#endif
});
if (SelectedSample == null || (SelectedSample != null && !SelectedSample.IsRunning))
{
// Draw the list of samples
GUIHelper.DrawArea(new Rect(0, statisticsHeight + 5, SelectedSample == null ? Screen.width : Screen.width / 3, Screen.height - statisticsHeight - 5), false, () =>
{
scrollPos = GUILayout.BeginScrollView(scrollPos);
for (int i = 0; i < Samples.Count; ++i)
DrawSample(Samples[i]);
GUILayout.EndScrollView();
});
if (SelectedSample != null)
DrawSampleDetails(SelectedSample);
}
else if (SelectedSample != null && SelectedSample.IsRunning)
{
GUILayout.BeginArea(new Rect(0, Screen.height - 50, Screen.width, 50), string.Empty);
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Back", GUILayout.MinWidth(100)))
SelectedSample.DestroyUnityObject();
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
}
19
View Source File : InteractionTriggerInspector.cs
License : GNU General Public License v3.0
Project Creator : brandonmousseau
License : GNU General Public License v3.0
Project Creator : brandonmousseau
void OnSceneGUI() {
if (!script.enabled) return;
var collider = script.GetComponent<Collider>();
if (collider != null)
collider.isTrigger = true;
else {
Warning.Log ("InteractionTrigger requires a Collider component.", script.transform, true);
return;
}
if (script.ranges.Length == 0) return;
for (int i = 0; i < script.ranges.Length; i++) {
DrawRange (script.ranges[i], i);
}
Handles.BeginGUI();
int h = script.ranges.Length * 18;
GUILayout.BeginArea(new Rect(10, 10, 200, h + 25), "InteractionTrigger Visualization", "Window");
// Rotating display
for (int i = 0; i < script.ranges.Length; i++) {
script.ranges[i].show = GUILayout.Toggle(script.ranges[i].show, new GUIContent(" Show Range " + i.ToString() + ": " + script.ranges[i].name, string.Empty));
}
GUILayout.EndArea();
Handles.EndGUI();
}
19
View Source File : InspectSingleBundle.cs
License : MIT License
Project Creator : IllusionMods
License : MIT License
Project Creator : IllusionMods
private void DrawBundleData()
{
if (m_Editor != null)
{
GUILayout.BeginArea(m_Position);
m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
m_Editor.OnInspectorGUI();
EditorGUILayout.EndScrollView();
GUILayout.EndArea();
}
else if (!string.IsNullOrEmpty(currentPath))
{
var style = new GUIStyle(GUI.skin.label);
style.alignment = TextAnchor.MiddleCenter;
style.wordWrap = true;
GUI.Label(m_Position, new GUIContent("Invalid bundle selected"), style);
if (m_inspectTabData != null && GUI.Button(new Rect(new Vector2((m_Position.position.x + m_Position.width / 2f) - 37.5f, (m_Position.position.y + m_Position.height / 2f) + 15), new Vector2(75, 30)), "Ignore file"))
{
var possibleFolderData = m_inspectTabData.FolderDataContainingFilePath(currentPath);
if (possibleFolderData != null)
{
if (!possibleFolderData.ignoredFiles.Contains(currentPath))
possibleFolderData.ignoredFiles.Add(currentPath);
if (m_replacedetBundleInspectTab != null)
m_replacedetBundleInspectTab.RefreshBundles();
}
}
}
}
19
View Source File : PooledActionsExample.cs
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
private void OnGUI()
{
GUILayout.BeginArea(new Rect(5f, 50f, 400f, 300f), GUI.skin.window);
GUILayout.Label("Pooled Actions Example\n\n");
GUILayout.Label("Press the number key, to see the corresponding action (in the console):");
GUILayout.Label("1. Execute an action once (next frame)");
GUILayout.Label("2. Delayed execution (3 seconds)");
GUILayout.Label("3. Continuous work (repeats forever)");
GUILayout.Label("4. Repeats work for 10 seconds at a 3 second interval.");
GUILayout.Label("5. Runs a long running action which takes 20 seconds to complete, using only 4 ms per frame.");
GUILayout.Label("6. Stop one repeated/long running action.");
GUILayout.EndArea();
}
19
View Source File : MLSystemEditor.cs
License : MIT License
Project Creator : Interactml
License : MIT License
Project Creator : Interactml
protected void ShowTrainingIcon(string MLS)
{
m_IconCenter.x = m_BodyRect.x;
m_IconCenter.y = m_BodyRect.y;
m_IconCenter.width = m_BodyRect.width;
m_IconCenter.height = 150;
GUILayout.BeginArea(m_IconCenter);
GUILayout.Space(bodySpace);
GUILayout.BeginHorizontal();
GUILayout.Box("", m_NodeSkin.GetStyle(MLS + " MLS Image"));
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label(MLS, m_NodeSkin.GetStyle(MLS + " Label"));
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
19
View Source File : RotationLimitHingeInspector.cs
License : GNU General Public License v3.0
Project Creator : brandonmousseau
License : GNU General Public License v3.0
Project Creator : brandonmousseau
void OnSceneGUI()
{
// Set defaultLocalRotation so that the initial local rotation will be the zero point for the rotation limit
if (!Application.isPlaying && !script.defaultLocalRotationOverride) script.defaultLocalRotation = script.transform.localRotation;
if (script.axis == Vector3.zero) return;
// Quick Editing Tools
Handles.BeginGUI();
GUILayout.BeginArea(new Rect(10, 10, 200, 50), "Rotation Limit Hinge", "Window");
// Rotating display
if (GUILayout.Button("Rotate display 90 degrees"))
{
if (!Application.isPlaying) Undo.RecordObject(script, "Rotate Display");
script.zeroAxisDisplayOffset += 90;
if (script.zeroAxisDisplayOffset >= 360) script.zeroAxisDisplayOffset = 0;
}
GUILayout.EndArea();
Handles.EndGUI();
// Normalize the main axes
Vector3 axis = Direction(script.axis.normalized);
Vector3 cross = Direction(Quaternion.AngleAxis(script.zeroAxisDisplayOffset, script.axis) * script.crossAxis.normalized);
// Axis vector
DrawArrow(script.transform.position, axis, colorDefault, "Axis", 0.02f);
if (script.useLimits)
{
// Zero rotation vector
DrawArrow(script.transform.position, cross * 0.5f, colorDefault, " 0", 0.02f);
// Arcs for the rotation limit
Handles.color = colorDefaultTransparent;
Handles.DrawSolidArc(script.transform.position, axis, cross, script.min, 0.5f);
Handles.DrawSolidArc(script.transform.position, axis, cross, script.max, 0.5f);
}
Handles.color = colorDefault;
GUI.color = colorDefault;
Inspector.CircleCap(0, script.transform.position, Quaternion.LookRotation(axis, cross), 0.5f);
if (!script.useLimits) return;
// Handles for adjusting rotation limits in the scene
Quaternion minRotation = Quaternion.AngleAxis(script.min, axis);
Handles.DrawLine(script.transform.position, script.transform.position + minRotation * cross);
Quaternion maxRotation = Quaternion.AngleAxis(script.max, axis);
Handles.DrawLine(script.transform.position, script.transform.position + maxRotation * cross);
// Undoable scene handles
float min = script.min;
min = DrawLimitHandle(min, script.transform.position + minRotation * cross, Quaternion.idenreplacedy, 0.5f, "Min", -10);
if (min != script.min)
{
if (!Application.isPlaying) Undo.RecordObject(script, "Min Limit");
script.min = min;
}
float max = script.max;
max = DrawLimitHandle(max, script.transform.position + maxRotation * cross, Quaternion.idenreplacedy, 0.5f, "Max", 10);
if (max != script.max)
{
if (!Application.isPlaying) Undo.RecordObject(script, "Max Limit");
script.max = max;
}
Handles.color = Color.white;
GUI.color = Color.white;
}
19
View Source File : PositionNodeEditor.cs
License : MIT License
Project Creator : Interactml
License : MIT License
Project Creator : Interactml
protected override void ShowBodyFields()
{
GUILayout.Space(60);
// set body space based on node editors rects
GUILayout.BeginArea(m_BodyRect);
GUILayout.Space(20);
//draws node data fields
MovementFeatureEditorMethods.DrawFeatureValueToggleAndLabel(this, m_ExtractPosition);
GUILayout.Space(10);
//draw toggle to select whether to use localspace
m_ExtractPosition.LocalSpace = MovementFeatureEditorMethods.DrawLocalSpaceToggle(this, m_ExtractPosition.LocalSpace);
GUILayout.EndArea();
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void BeginArea(SmartRect rect)
{
UGUI.BeginArea(rect.ToRect());
}
19
View Source File : TextNoteEditor.cs
License : MIT License
Project Creator : Interactml
License : MIT License
Project Creator : Interactml
public override void OnHeaderGUI()
{
// Get reference to the current node
m_TextNote = (target as TextNote);
// Initialise header background Rects
InitHeaderRects();
NodeColor = GetColorTextureFromHexString("#3A3B5B");
// Set node width
NodeWidth = 200;
if (Event.current.type == EventType.Layout)
{
// Draw header background Rect
GUI.DrawTexture(HeaderRect, NodeColor);
// Draw line below header
GUI.DrawTexture(LineBelowHeader, GetColorTextureFromHexString("#F6C46F"));
}
//Display Node name
GUILayout.BeginArea(HeaderRect);
GUILayout.Space(10);
GUILayout.Label("TEXT NOTE", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Header"), GUILayout.MinWidth(NodeWidth - 10));
GUILayout.EndArea();
GUILayout.Label("", GUILayout.MinHeight(60));
}
19
View Source File : SteamVR_Menu.cs
License : GNU General Public License v3.0
Project Creator : brandonmousseau
License : GNU General Public License v3.0
Project Creator : brandonmousseau
void OnGUI()
{
if (overlay == null)
return;
var texture = overlay.texture as RenderTexture;
var prevActive = RenderTexture.active;
RenderTexture.active = texture;
if (Event.current.type == EventType.Repaint)
GL.Clear(false, true, Color.clear);
var area = new Rect(0, 0, texture.width, texture.height);
// Account for screen smaller than texture (since mouse position gets clamped)
if (Screen.width < texture.width)
{
area.width = Screen.width;
overlay.uvOffset.x = -(float)(texture.width - Screen.width) / (2 * texture.width);
}
if (Screen.height < texture.height)
{
area.height = Screen.height;
overlay.uvOffset.y = (float)(texture.height - Screen.height) / (2 * texture.height);
}
GUILayout.BeginArea(area);
if (background != null)
{
GUI.DrawTexture(new Rect(
(area.width - background.width) / 2,
(area.height - background.height) / 2,
background.width, background.height), background);
}
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.BeginVertical();
if (logo != null)
{
GUILayout.Space(area.height / 2 - logoHeight);
GUILayout.Box(logo);
}
GUILayout.Space(menuOffset);
bool bHideMenu = GUILayout.Button("[Esc] - Close menu");
GUILayout.BeginHorizontal();
GUILayout.Label(string.Format("Scale: {0:N4}", scale));
{
var result = GUILayout.HorizontalSlider(scale, scaleLimits.x, scaleLimits.y);
if (result != scale)
{
SetScale(result);
}
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label(string.Format("Scale limits:"));
{
var result = GUILayout.TextField(scaleLimitX);
if (result != scaleLimitX)
{
if (float.TryParse(result, out scaleLimits.x))
scaleLimitX = result;
}
}
{
var result = GUILayout.TextField(scaleLimitY);
if (result != scaleLimitY)
{
if (float.TryParse(result, out scaleLimits.y))
scaleLimitY = result;
}
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label(string.Format("Scale rate:"));
{
var result = GUILayout.TextField(scaleRateText);
if (result != scaleRateText)
{
if (float.TryParse(result, out scaleRate))
scaleRateText = result;
}
}
GUILayout.EndHorizontal();
if (SteamVR.active)
{
var vr = SteamVR.instance;
GUILayout.BeginHorizontal();
{
var t = SteamVR_Camera.sceneResolutionScale;
int w = (int)(vr.sceneWidth * t);
int h = (int)(vr.sceneHeight * t);
int pct = (int)(100.0f * t);
GUILayout.Label(string.Format("Scene quality: {0}x{1} ({2}%)", w, h, pct));
var result = Mathf.RoundToInt(GUILayout.HorizontalSlider(pct, 50, 200));
if (result != pct)
{
SteamVR_Camera.sceneResolutionScale = (float)result / 100.0f;
}
}
GUILayout.EndHorizontal();
}
var tracker = SteamVR_Render.Top();
if (tracker != null)
{
tracker.wireframe = GUILayout.Toggle(tracker.wireframe, "Wireframe");
if (SteamVR.settings.trackingSpace == ETrackingUniverseOrigin.TrackingUniverseSeated)
{
if (GUILayout.Button("Switch to Standing"))
SteamVR.settings.trackingSpace = ETrackingUniverseOrigin.TrackingUniverseStanding;
if (GUILayout.Button("Center View"))
{
var chaperone = OpenVR.Chaperone;
if (chaperone != null)
chaperone.ResetZeroPose(SteamVR.settings.trackingSpace);
}
}
else
{
if (GUILayout.Button("Switch to Seated"))
SteamVR.settings.trackingSpace = ETrackingUniverseOrigin.TrackingUniverseSeated;
}
}
#if !UNITY_EDITOR
if (GUILayout.Button("Exit"))
Application.Quit();
#endif
GUILayout.Space(menuOffset);
var env = System.Environment.GetEnvironmentVariable("VR_OVERRIDE");
if (env != null)
{
GUILayout.Label("VR_OVERRIDE=" + env);
}
GUILayout.Label("Graphics device: " + SystemInfo.graphicsDeviceVersion);
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.EndArea();
if (cursor != null)
{
float x = Input.mousePosition.x, y = Screen.height - Input.mousePosition.y;
float w = cursor.width, h = cursor.height;
GUI.DrawTexture(new Rect(x, y, w, h), cursor);
}
RenderTexture.active = prevActive;
if (bHideMenu)
HideMenu();
}
19
View Source File : DebugChooseFormationComponent.cs
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
private void OnGUI()
{
var selected = GameServices.gameStateManager.unitSelection.selected;
if (selected.groupCount <= 0 || selected.memberCount <= 0)
{
return;
}
if (guiSkin != null && GUI.skin != guiSkin)
{
GUI.skin = guiSkin;
}
float width = 150f;
float height = Screen.height * 0.9f;
float buttonHeight = height / 8f;
GUILayout.BeginArea(new Rect(5f, (Screen.height / 2f) - (height / 2f), width, height));
GUILayout.BeginVertical();
if (GUILayout.Button("Circle Formation (F1)", GUILayout.Width(width), GUILayout.Height(buttonHeight)) || Input.GetKeyUp(KeyCode.F1))
{
SetFormation(new FormationEllipsoid(formationSpacing));
}
else if (GUILayout.Button("Grid Formation (F2)", GUILayout.Width(width), GUILayout.Height(buttonHeight)) || Input.GetKeyUp(KeyCode.F2))
{
SetFormation(new FormationGrid(formationSpacing));
}
else if (GUILayout.Button("Spiral Formation (F3)", GUILayout.Width(width), GUILayout.Height(buttonHeight)) || Input.GetKeyUp(KeyCode.F3))
{
SetFormation(new FormationSpiral(formationSpacing));
}
else if (GUILayout.Button("Wing Formation (F4)", GUILayout.Width(width), GUILayout.Height(buttonHeight)) || Input.GetKeyUp(KeyCode.F4))
{
SetFormation(new FormationWing(formationSpacing));
}
else if (GUILayout.Button("Row Formation (F5)", GUILayout.Width(width), GUILayout.Height(buttonHeight)) || Input.GetKeyUp(KeyCode.F5))
{
SetFormation(new FormationRow(formationSpacing));
}
else if (GUILayout.Button("Line Formation (F6)", GUILayout.Width(width), GUILayout.Height(buttonHeight)) || Input.GetKeyUp(KeyCode.F6))
{
SetFormation(new FormationLine(formationSpacing));
}
else if (GUILayout.Button("No Formation (F7)", GUILayout.Width(width), GUILayout.Height(buttonHeight)) || Input.GetKey(KeyCode.F7))
{
SetFormation(null);
}
GUILayout.EndVertical();
GUILayout.EndArea();
}
19
View Source File : TextBox.cs
License : Apache License 2.0
Project Creator : AantCoder
License : Apache License 2.0
Project Creator : AantCoder
public void Drow(Rect chatAreaOuter, bool scrollToDown = false)
{
var chatAreaInner = new Rect(0, 0, chatAreaOuter.width - ListBox<string>.WidthScrollLine, 0);
if (chatAreaInner.width <= 0) return;
//chatAreaInner.height = Text.CalcHeight(ChatText, chatAreaInner.width);
GUI.skin.textField.wordWrap = true;
chatAreaInner.height = GUI.skin.textField.CalcHeight(new GUIContent(Text), chatAreaInner.width);
//if (chatAreaInner.height > chatAreaOuter.height) chatAreaInner.height -= chatAreaOuter.height;
if (scrollToDown)
{
ScrollPosition.y = chatAreaInner.height - chatAreaOuter.height;
}
ScrollPosition = GUI.BeginScrollView(chatAreaOuter, ScrollPosition, chatAreaInner);
GUILayout.BeginArea(chatAreaInner);
var text = GUILayout.TextArea(Text ?? "", "Label");
if (Editable)
{
Text = text;
}
GUILayout.EndArea();
GUI.EndScrollView();
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void BeginArea(SmartRect rect, string text)
{
UGUI.BeginArea(rect.ToRect(), text);
}
19
View Source File : LongRunningActionExample.cs
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
private void OnGUI()
{
GUILayout.BeginArea(new Rect(5f, 50f, 400f, 200f), GUI.skin.window);
GUILayout.Label("Long Running Action Example\n\n");
GUILayout.Label("Press the number key, to see the corresponding action (in the console):");
GUILayout.Label("1. Long running, 3ms per frame.");
GUILayout.Label("4. Stop long running.");
GUILayout.EndArea();
}
19
View Source File : CinemachineSettings.cs
License : MIT License
Project Creator : BattleDawnNZ
License : MIT License
Project Creator : BattleDawnNZ
[PreferenceItem("Cinemachine")]
#endif
private static void OnGUI()
{
if (CinemachineHeader != null)
{
const float kWidth = 350f;
float aspectRatio = (float)CinemachineHeader.height / (float)CinemachineHeader.width;
GUILayout.BeginScrollView(Vector2.zero, false, false, GUILayout.Width(kWidth), GUILayout.Height(kWidth * aspectRatio));
Rect texRect = new Rect(0f, 0f, kWidth, kWidth * aspectRatio);
GUILayout.BeginArea(texRect);
GUI.DrawTexture(texRect, CinemachineHeader, ScaleMode.ScaleToFit);
GUILayout.EndArea();
GUILayout.EndScrollView();
}
sScrollPosition = GUILayout.BeginScrollView(sScrollPosition);
//CinemachineCore.sShowHiddenObjects
// = EditorGUILayout.Toggle("Show Hidden Objects", CinemachineCore.sShowHiddenObjects);
ShowCoreSettings = EditorGUILayout.Foldout(ShowCoreSettings, "Runtime Settings");
if (ShowCoreSettings)
{
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
Color newActiveGizmoColour = EditorGUILayout.ColorField(Styles.sCoreActiveGizmosColour, CinemachineCoreSettings.ActiveGizmoColour);
if (EditorGUI.EndChangeCheck())
{
CinemachineCoreSettings.ActiveGizmoColour = newActiveGizmoColour;
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
}
if (GUILayout.Button("Reset"))
{
CinemachineCoreSettings.ActiveGizmoColour = CinemachineCoreSettings.kDefaultActiveColour;
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
Color newInactiveGizmoColour = EditorGUILayout.ColorField(Styles.sCoreInactiveGizmosColour, CinemachineCoreSettings.InactiveGizmoColour);
if (EditorGUI.EndChangeCheck())
{
CinemachineCoreSettings.InactiveGizmoColour = newInactiveGizmoColour;
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
}
if (GUILayout.Button("Reset"))
{
CinemachineCoreSettings.InactiveGizmoColour = CinemachineCoreSettings.kDefaultInactiveColour;
}
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel--;
}
ShowComposerSettings = EditorGUILayout.Foldout(ShowComposerSettings, "Composer Settings");
if (ShowComposerSettings)
{
EditorGUI.indentLevel++;
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
float overlayOpacity = EditorGUILayout.Slider(Styles.sComposerOverlayOpacity, ComposerSettings.OverlayOpacity, 0f, 1f);
if (EditorGUI.EndChangeCheck())
{
ComposerSettings.OverlayOpacity = overlayOpacity;
}
if (GUILayout.Button("Reset"))
{
ComposerSettings.OverlayOpacity = ComposerSettings.kDefaultOverlayOpacity;
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
Color newHardEdgeColor = EditorGUILayout.ColorField(Styles.sComposerHardBoundsOverlay, ComposerSettings.HardBoundsOverlayColour);
if (EditorGUI.EndChangeCheck())
{
ComposerSettings.HardBoundsOverlayColour = newHardEdgeColor;
}
if (GUILayout.Button("Reset"))
{
ComposerSettings.HardBoundsOverlayColour = ComposerSettings.kDefaultHardBoundsColour;
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
Color newSoftEdgeColor = EditorGUILayout.ColorField(Styles.sComposerSoftBoundsOverlay, ComposerSettings.SoftBoundsOverlayColour);
if (EditorGUI.EndChangeCheck())
{
ComposerSettings.SoftBoundsOverlayColour = newSoftEdgeColor;
}
if (GUILayout.Button("Reset"))
{
ComposerSettings.SoftBoundsOverlayColour = ComposerSettings.kDefaultSoftBoundsColour;
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
Color newTargetColour = EditorGUILayout.ColorField(Styles.sComposerTargetOverlay, ComposerSettings.TargetColour);
if (EditorGUI.EndChangeCheck())
{
ComposerSettings.TargetColour = newTargetColour;
}
if (GUILayout.Button("Reset"))
{
ComposerSettings.TargetColour = ComposerSettings.kDefaultTargetColour;
}
EditorGUILayout.EndHorizontal();
EditorGUI.BeginChangeCheck();
float targetSide = EditorGUILayout.FloatField(Styles.sComposerTargetOverlayPixels, ComposerSettings.TargetSize);
if (EditorGUI.EndChangeCheck())
{
ComposerSettings.TargetSize = targetSide;
}
EditorGUI.indentLevel--;
}
if (AdditionalCategories != null)
{
AdditionalCategories();
}
GUILayout.EndScrollView();
//if (GUILayout.Button("Open Doreplacedentation"))
//{
// Application.OpenURL(kCinemachineDocURL);
//}
}
19
View Source File : CFXEasyEditor.cs
License : MIT License
Project Creator : Crazy-Marvin
License : MIT License
Project Creator : Crazy-Marvin
void OnGUI()
{
GUILayout.BeginArea(new Rect(0,0,this.position.width - 8,this.position.height));
GUILayout.Space(4);
GUILayout.BeginHorizontal();
GUILayout.Label("CARTOON FX Easy Editor", EditorStyles.boldLabel);
pref_ShowAsToolbox = GUILayout.Toggle(pref_ShowAsToolbox, new GUIContent("Toolbox", "If enabled, the window will be displayed as an external toolbox.\nIf false, it will act as a dockable Unity window."), GUILayout.Width(60));
if(GUI.changed)
{
EditorPrefs.SetBool("CFX_ShowAsToolbox", pref_ShowAsToolbox);
this.Close();
CFXEasyEditor.ShowWindow();
}
GUILayout.EndHorizontal();
GUILayout.Label("Easily change properties of any Particle System!", EditorStyles.miniLabel);
//----------------------------------------------------------------
pref_IncludeChildren = GUILayout.Toggle(pref_IncludeChildren, new GUIContent("Include Children", "If checked, changes will affect every Particle Systems from each child of the selected GameObject(s)"));
if(GUI.changed)
{
EditorPrefs.SetBool("CFX_IncludeChildren", pref_IncludeChildren);
}
EditorGUILayout.BeginHorizontal();
GUILayout.Label("Test effect(s):");
if(GUILayout.Button("Play", EditorStyles.miniButtonLeft, GUILayout.Width(50f)))
{
foreach(GameObject go in Selection.gameObjects)
{
ParticleSystem[] systems = go.GetComponents<ParticleSystem>();
if(systems.Length == 0) continue;
foreach(ParticleSystem system in systems)
system.Play(pref_IncludeChildren);
}
}
if(GUILayout.Button("Pause", EditorStyles.miniButtonMid, GUILayout.Width(50f)))
{
foreach(GameObject go in Selection.gameObjects)
{
ParticleSystem[] systems = go.GetComponents<ParticleSystem>();
if(systems.Length == 0) continue;
foreach(ParticleSystem system in systems)
system.Pause(pref_IncludeChildren);
}
}
if(GUILayout.Button("Stop", EditorStyles.miniButtonMid, GUILayout.Width(50f)))
{
foreach(GameObject go in Selection.gameObjects)
{
ParticleSystem[] systems = go.GetComponents<ParticleSystem>();
if(systems.Length == 0) continue;
foreach(ParticleSystem system in systems)
system.Stop(pref_IncludeChildren);
}
}
if(GUILayout.Button("Clear", EditorStyles.miniButtonRight, GUILayout.Width(50f)))
{
foreach(GameObject go in Selection.gameObjects)
{
ParticleSystem[] systems = go.GetComponents<ParticleSystem>();
if(systems.Length == 0) continue;
foreach(ParticleSystem system in systems)
{
system.Stop(pref_IncludeChildren);
system.Clear(pref_IncludeChildren);
}
}
}
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
//----------------------------------------------------------------
//Separator
GUILayout.Box("",GUILayout.Width(this.position.width - 12), GUILayout.Height(3));
EditorGUI.BeginChangeCheck();
basicFoldout = EditorGUILayout.Foldout(basicFoldout, "QUICK EDIT");
if(EditorGUI.EndChangeCheck())
{
foldoutChanged = true;
}
if(basicFoldout)
{
//----------------------------------------------------------------
GUILayout.BeginHorizontal();
if(GUILayout.Button(new GUIContent("Scale Size", "Changes the size of the Particle System(s) and other values accordingly (speed, gravity, etc.)"), GUILayout.Width(120)))
{
applyScale();
}
GUILayout.Label("Multiplier:",GUILayout.Width(110));
ScalingValue = EditorGUILayout.FloatField(ScalingValue,GUILayout.Width(50));
if(ScalingValue <= 0) ScalingValue = 0.1f;
GUILayout.EndHorizontal();
//----------------------------------------------------------------
GUILayout.BeginHorizontal();
if(GUILayout.Button(new GUIContent("Set Speed", "Changes the speed of the Particle System(s) (if you want quicker or longer effects, 100% = default speed)"), GUILayout.Width(120)))
{
applySpeed();
}
GUILayout.Label("Speed (%):",GUILayout.Width(110));
LTScalingValue = EditorGUILayout.FloatField(LTScalingValue,GUILayout.Width(50));
if(LTScalingValue < 0.1f) LTScalingValue = 0.1f;
else if(LTScalingValue > 9999) LTScalingValue = 9999;
GUILayout.EndHorizontal();
//----------------------------------------------------------------
GUILayout.BeginHorizontal();
if(GUILayout.Button(new GUIContent("Set Duration", "Changes the duration of the Particle System(s)"), GUILayout.Width(120)))
{
applyDuration();
}
GUILayout.Label("Duration (sec):",GUILayout.Width(110));
DurationValue = EditorGUILayout.FloatField(DurationValue,GUILayout.Width(50));
if(DurationValue < 0.1f) DurationValue = 0.1f;
else if(DurationValue > 9999) DurationValue = 9999;
GUILayout.EndHorizontal();
//----------------------------------------------------------------
GUILayout.BeginHorizontal();
if(GUILayout.Button(new GUIContent("Set Delay", "Changes the delay of the Particle System(s)"), GUILayout.Width(120)))
{
applyDelay();
}
GUILayout.Label("Delay :",GUILayout.Width(110));
DelayValue = EditorGUILayout.FloatField(DelayValue,GUILayout.Width(50));
if(DelayValue < 0.0f) DelayValue = 0.0f;
else if(DelayValue > 9999f) DelayValue = 9999f;
GUILayout.EndHorizontal();
//----------------------------------------------------------------
GUILayout.Space(2);
GUILayout.BeginHorizontal();
if(GUILayout.Button(new GUIContent("Loop", "Loop the effect (might not work properly on some effects such as explosions)"), EditorStyles.miniButtonLeft))
{
loopEffect(true);
}
if(GUILayout.Button(new GUIContent("Unloop", "Remove looping from the effect"), EditorStyles.miniButtonRight))
{
loopEffect(false);
}
if(GUILayout.Button(new GUIContent("Prewarm On", "Prewarm the effect (if looped)"), EditorStyles.miniButtonLeft))
{
prewarmEffect(true);
}
if(GUILayout.Button(new GUIContent("Prewarm Off", "Don't prewarm the effect (if looped)"), EditorStyles.miniButtonRight))
{
prewarmEffect(false);
}
GUILayout.EndHorizontal();
GUILayout.Space(2);
//----------------------------------------------------------------
}
//Separator
GUILayout.Box("",GUILayout.Width(this.position.width - 12), GUILayout.Height(3));
EditorGUI.BeginChangeCheck();
colorFoldout = EditorGUILayout.Foldout(colorFoldout, "COLOR EDIT");
if(EditorGUI.EndChangeCheck())
{
foldoutChanged = true;
}
if(colorFoldout)
{
//----------------------------------------------------------------
GUILayout.BeginHorizontal();
if(GUILayout.Button(new GUIContent("Set Start Color(s)", "Changes the color(s) of the Particle System(s)\nSecond Color is used when Start Color is 'Random Between Two Colors'."),GUILayout.Width(120)))
{
applyColor();
}
ColorValue = EditorGUILayout.ColorField(ColorValue);
ColorValue2 = EditorGUILayout.ColorField(ColorValue2);
AffectAlpha = GUILayout.Toggle(AffectAlpha, new GUIContent("Alpha", "If checked, the alpha value will also be changed"));
GUILayout.EndHorizontal();
//----------------------------------------------------------------
GUILayout.BeginHorizontal();
if(GUILayout.Button(new GUIContent("Tint Colors", "Tints the colors of the Particle System(s), including gradients!\n(preserving their saturation and lightness)"),GUILayout.Width(120)))
{
tintColor();
}
TintColorValue = EditorGUILayout.ColorField(TintColorValue);
TintColorValue = HSLColor.FromRGBA(TintColorValue).VividColor();
GUILayout.EndHorizontal();
//----------------------------------------------------------------
/*
GUILayout.BeginHorizontal();
GUILayout.Label("Add/Substract Lightness:");
LightnessStep = EditorGUILayout.IntField(LightnessStep, GUILayout.Width(30));
if(LightnessStep > 99) LightnessStep = 99;
else if(LightnessStep < 1) LightnessStep = 1;
GUILayout.Label("%");
if(GUILayout.Button("-", EditorStyles.miniButtonLeft, GUILayout.Width(22)))
{
addLightness(true);
}
if(GUILayout.Button("+", EditorStyles.miniButtonRight, GUILayout.Width(22)))
{
addLightness(false);
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
*/
//----------------------------------------------------------------
GUILayout.Label("Color Modules to affect:");
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.color = TintStartColor ? ColorSelected : Color.white; if(GUILayout.Button(new GUIContent("Start Color", "If checked, the \"Start Color\" value(s) will be affected."), EditorStyles.toolbarButton, GUILayout.Width(70))) TintStartColor = !TintStartColor;
GUI.color = TintColorModule ? ColorSelected : Color.white; if(GUILayout.Button(new GUIContent("Color over Lifetime", "If checked, the \"Color over Lifetime\" value(s) will be affected."), EditorStyles.toolbarButton, GUILayout.Width(110))) TintColorModule = !TintColorModule;
GUI.color = TintColorSpeedModule ? ColorSelected : Color.white; if(GUILayout.Button(new GUIContent("Color by Speed", "If checked, the \"Color by Speed\" value(s) will be affected."), EditorStyles.toolbarButton, GUILayout.Width(100))) TintColorSpeedModule = !TintColorSpeedModule;
GUI.color = Color.white;
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.Space(4);
//----------------------------------------------------------------
}
//Separator
GUILayout.Box("",GUILayout.Width(this.position.width - 12), GUILayout.Height(3));
// GUILayout.Space(6);
//----------------------------------------------------------------
EditorGUI.BeginChangeCheck();
copyFoldout = EditorGUILayout.Foldout(copyFoldout, "COPY MODULES");
if(EditorGUI.EndChangeCheck())
{
foldoutChanged = true;
}
if(copyFoldout)
{
GUILayout.Label("Copy properties from a Particle System to others!", EditorStyles.miniLabel);
GUILayout.BeginHorizontal();
GUILayout.Label("Source Object:", GUILayout.Width(110));
sourceObject = (ParticleSystem)EditorGUILayout.ObjectField(sourceObject, typeof(ParticleSystem), true);
GUILayout.EndHorizontal();
EditorGUILayout.LabelField("Modules to Copy:");
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if(GUILayout.Button("ALL", EditorStyles.miniButtonLeft, GUILayout.Width(120)))
{
for(int i = 0; i < b_modules.Length; i++) b_modules[i] = true;
}
if(GUILayout.Button("NONE", EditorStyles.miniButtonRight, GUILayout.Width(120)))
{
for(int i = 0; i < b_modules.Length; i++) b_modules[i] = false;
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.Space(4);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.color = b_modules[0] ? ColorSelected : Color.white; if(GUILayout.Button("Initial", EditorStyles.toolbarButton, GUILayout.Width(70))) b_modules[0] = !b_modules[0];
GUI.color = b_modules[1] ? ColorSelected : Color.white; if(GUILayout.Button("Emission", EditorStyles.toolbarButton, GUILayout.Width(70))) b_modules[1] = !b_modules[1];
GUI.color = b_modules[2] ? ColorSelected : Color.white; if(GUILayout.Button("Shape", EditorStyles.toolbarButton, GUILayout.Width(70))) b_modules[2] = !b_modules[2];
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.color = b_modules[3] ? ColorSelected : Color.white; if(GUILayout.Button("Velocity", EditorStyles.toolbarButton, GUILayout.Width(70))) b_modules[3] = !b_modules[3];
GUI.color = b_modules[4] ? ColorSelected : Color.white; if(GUILayout.Button("Limit Velocity", EditorStyles.toolbarButton, GUILayout.Width(100))) b_modules[4] = !b_modules[4];
GUI.color = b_modules[5] ? ColorSelected : Color.white; if(GUILayout.Button("Force", EditorStyles.toolbarButton, GUILayout.Width(70))) b_modules[5] = !b_modules[5];
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.color = b_modules[6] ? ColorSelected : Color.white; if(GUILayout.Button("Color over Lifetime", EditorStyles.toolbarButton, GUILayout.Width(120))) b_modules[6] = !b_modules[6];
GUI.color = b_modules[7] ? ColorSelected : Color.white; if(GUILayout.Button("Color by Speed", EditorStyles.toolbarButton, GUILayout.Width(120))) b_modules[7] = !b_modules[7];
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.color = b_modules[8] ? ColorSelected : Color.white; if(GUILayout.Button("Size over Lifetime", EditorStyles.toolbarButton, GUILayout.Width(120))) b_modules[8] = !b_modules[8];
GUI.color = b_modules[9] ? ColorSelected : Color.white; if(GUILayout.Button("Size by Speed", EditorStyles.toolbarButton, GUILayout.Width(120))) b_modules[9] = !b_modules[9];
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.color = b_modules[10] ? ColorSelected : Color.white; if(GUILayout.Button("Rotation over Lifetime", EditorStyles.toolbarButton, GUILayout.Width(120))) b_modules[10] = !b_modules[10];
GUI.color = b_modules[11] ? ColorSelected : Color.white; if(GUILayout.Button("Rotation by Speed", EditorStyles.toolbarButton, GUILayout.Width(120))) b_modules[11] = !b_modules[11];
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.color = b_modules[12] ? ColorSelected : Color.white; if(GUILayout.Button("Collision", EditorStyles.toolbarButton, GUILayout.Width(100))) b_modules[12] = !b_modules[12];
GUI.color = b_modules[13] ? ColorSelected : Color.white; if(GUILayout.Button("Sub Emitters", EditorStyles.toolbarButton, GUILayout.Width(100))) b_modules[13] = !b_modules[13];
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.color = b_modules[14] ? ColorSelected : Color.white; if(GUILayout.Button("Texture Animation", EditorStyles.toolbarButton, GUILayout.Width(110))) b_modules[14] = !b_modules[14];
GUI.color = b_modules[15] ? ColorSelected : Color.white; if(GUILayout.Button("Renderer", EditorStyles.toolbarButton, GUILayout.Width(90))) b_modules[15] = !b_modules[15];
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUI.color = Color.white;
GUILayout.Space(4);
if(GUILayout.Button("Copy properties to selected Object(s)"))
{
bool foundPs = false;
foreach(GameObject go in Selection.gameObjects)
{
ParticleSystem[] systems;
if(pref_IncludeChildren) systems = go.GetComponentsInChildren<ParticleSystem>(true);
else systems = go.GetComponents<ParticleSystem>();
if(systems.Length == 0) continue;
foundPs = true;
foreach(ParticleSystem system in systems) CopyModules(sourceObject, system);
}
if(!foundPs)
{
Debug.LogWarning("CartoonFX Easy Editor: No Particle System found in the selected GameObject(s)!");
}
}
}
//----------------------------------------------------------------
GUILayout.Space(8);
//Resize window
if(foldoutChanged && Event.current.type == EventType.Repaint)
{
foldoutChanged = false;
Rect r = GUILayoutUtility.GetLastRect();
this.minSize = new Vector2(300,r.y + 8);
this.maxSize = new Vector2(300,r.y + 8);
}
GUILayout.EndArea();
}
See More Examples