using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
[CustomEditor(typeof(ConversationTrigger))]
public class ConversationTriggerEditor : Editor
{
private ConversationTrigger conversationtrigger;
private void OnEnable()
{
conversationtrigger = FindObjectOfType<ConversationTrigger>();
}
public override void OnInspectorGUI()
{
DrawDefaultInspector();
if(GUI.Button(new Rect(0.1f,0.5f,0.1f,0.1f), "Add new item"))
{
conversationtrigger.conversations.Add(new Conversation());
}
if (GUILayout.Button("Save Conversations"))
{
conversationtrigger.SaveConversations();
}
if (GUILayout.Button("Load Conversations"))
{
Undo.RecordObject(conversationtrigger, "Loaded conversations from JSON");
conversationtrigger.LoadConversations();
}
}
}
I tried this line :
if(GUI.Button(new Rect(0.1f,0.5f,0.1f,0.1f), "Add new item"))
But that make the button vanished like deleted.
If I’m using GUILayout.Button I will see the button but then I can’t set the button position so I’m using GUI.Button.
I want to position the button “Add new item” before the Canvas and always after the last conversation item in this case the Locked Room and if I will add a new item the button should be stay after the new added item and before the Canvas.
I guess this values of the Rect are wrong making the button to be positioned out of the window.
This is a screenshot of the Inspector :
