- Home /
Move Editor Button
I have been working on creating an editor extension and I am getting the hang of it fairly good. My problem I currently have and can not find the solution to is when creating editor buttons they stack down wards one below the next. I want to make it so that at least two of the buttons are on the same line. Here is the code as I have it now.
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor(typeof(ObjectBuildingScript))]
public class ObjectBuilderEditor : Editor {
private Texture2D m_Logo = null;
public override void OnInspectorGUI()
{
DrawDefaultInspector();
m_Logo = (Texture2D)Resources.Load("y",typeof(Texture2D));
ObjectBuildingScript myScript = (ObjectBuildingScript)target;
if(GUILayout.Button(m_Logo,GUILayout.Width(70),GUILayout.Height(70)))
{
myScript.BuildObject();
}
if(GUILayout.Button(m_Logo,GUILayout.Width(70),GUILayout.Height(70)))
{
myScript.BuildObject();
}
if(GUILayout.Button(m_Logo,GUILayout.Width(70),GUILayout.Height(70)))
{
myScript.BuildObject();
}
}
}
Answer by smallbit · Aug 12, 2014 at 04:44 PM
I usually use Editor Gui Layout for custom editors it features auto layout ( you can use begin horizontal for buttons in same line etc. http://docs.unity3d.com/ScriptReference/EditorGUILayout.html
If you prefer to stick to GUIlayout it also features automatic layout, you need to tell unity how you want components to be lay out :) use this http://docs.unity3d.com/ScriptReference/GUILayout.BeginHorizontal.html
Alternatively you can switch to GUI/EditorGUi and define your fixed layout.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Initialising List array for use in a custom Editor 1 Answer
Editor Modules?? Like the one in the particle system and postprocessing stack. 0 Answers
Any way to attach a bit of code to individual UI Windows [Editor] 1 Answer
How to properly handle Undo events in custom inspector? 0 Answers