- Home /
Question by
Qbasic8 · Apr 07, 2020 at 07:04 PM ·
c#custom editor
Custom Editor value change
I am having a problem where I have a public string "DefaultURL" in my script. I made a custom editor that will change the "DefaultURL" to point to a new URL when a button is pressed.
Example: DefaultURL = "http://www.myaddress.com/". After pressing a button it should become: http://www.myaddress.com/Bugs/TodaysDate.html". After clicking the button it does update. When you hit play DefaultURL turns back to "http://www.myaddress.com".
in my script I have:
public string DefaultURL;
public void VisitDefaultURL()
{
if(DefaultURL != string.Empty)
{
System.Diagnostics.Process.Start(DefaultURL);
}
}
My Editor Script: [CustomEditor(typeof(VisitWebSite))] [ExecuteInEditMode] public class BugFix : Editor { public override void OnInspectorGUI() { DrawDefaultInspector();
if(GUILayout.Button("Todays Bug Fix"))
{
VisitWebSite web = (VisitWebSite)target;
string newURL = "http://www.xXxXxXx.com/Bugs/" + DateTime.Now.ToString("MM-dd-yyyy") + ".html";
web.DefaultURL = newURL;
}
}
}
What am I missing??
Comment