Welcome,
Guest
. Please
login
or
register
.
October 03, 2024, 09:44:52 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Can you add editor classes support to EventDelegates?
« previous
next »
Print
Pages: [
1
]
Author
Topic: Can you add editor classes support to EventDelegates? (Read 2861 times)
vexe
Full Member
Thank You
-Given: 0
-Receive: 0
Posts: 153
Can you add editor classes support to EventDelegates?
«
on:
February 26, 2014, 11:39:20 AM »
I have a RenameNotifer MonoBehaviour attached to some of my gameObjects, whenever there's a change in their name, it notifies a method in their editors. However, I had to make a slight adjustment for the delegate to be executed:
if
(
Application
.
isPlaying
)
{
call
(
)
;
}
else
if
(
call
.
Target
!=
null
)
{
System
.
Type
type
=
call
.
Target
.
GetType
(
)
;
object
[
]
objs
=
type
.
GetCustomAttributes
(
typeof
(
ExecuteInEditMode
)
,
true
)
;
if
(
objs
!=
null
&&
objs
.
Length
>
0
||
type
.
IsSubclassOf
(
typeof
(
UnityEditor
.
Editor
)
)
)
call
(
)
;
}
Can you add this to NGUI's code?
Thanks!
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Can you add editor classes support to EventDelegates?
«
Reply #1 on:
February 26, 2014, 02:24:42 PM »
UnityEditor is not available at run-time. This code won't compile. What is it you're trying to do? You shouldn't register any delegates at edit time.
Logged
vexe
Full Member
Thank You
-Given: 0
-Receive: 0
Posts: 153
Re: Can you add editor classes support to EventDelegates?
«
Reply #2 on:
February 27, 2014, 04:14:14 AM »
As I mentioned before, there's a certain method in my editor that I want to execute when there's a rename on a certain GameObject (which has RenameNotifier attached to it - if there's a rename, it executes onRename which is a List<eventdelegate>)
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Can you add editor classes support to EventDelegates?
«
Reply #3 on:
February 27, 2014, 05:25:51 PM »
Durr. That entire section is in an #if UNITY_EDITOR check. My bad. Yes, your code makes perfect sense now, thanks.
Logged
vexe
Full Member
Thank You
-Given: 0
-Receive: 0
Posts: 153
Re: Can you add editor classes support to EventDelegates?
«
Reply #4 on:
February 27, 2014, 05:57:02 PM »
yeah well I tried doing what I was doing, it seems that this is not the only place one has to make changes to, to be able to notify editors. since I'm interested in notifying my editor (which is a non-MB) - the "Target" of the delegate will be null, since you're only targeting MBs. I've also had issues with the delegate not serializing, probably related to the fact that the target is null or something, haven't looked into it in depth, but yea... more stuff needs to be editor in order to fully support that. I would love to see it happen though
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Can you add editor classes support to EventDelegates?
«
Reply #5 on:
February 27, 2014, 06:17:55 PM »
Yea... might be easier to just use regular delegates.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Can you add editor classes support to EventDelegates?