Editor.target vs Editor.serializedObject2019 Community Moderator ElectionStill can't make Escape key to quit game even in Standalone mode. How can i solve it?Dynamically creating a CustomEditor class in Unity / C#Unity Custom Inspector with sub-inspectorsUsing C# Attributes, how would I trigger functions to be executed on change of their assigned fieldIs there a way to stretch a RenderTexture playing on a plane with a VideoPlayer in Unity?How to handle touch selection on Unity3D using LeanTouch free asset?
If nine coins are tossed, what is the probability that the number of heads is even?
Generating a list with duplicate entries
Inorganic chemistry handbook with reaction lists
How to recover against Snake as a heavyweight character?
Does an unused member variable take up memory?
Too soon for a plot twist?
Short story about cities being connected by a conveyor belt
What is the oldest European royal house?
Professor forcing me to attend a conference, I can't afford even with 50% funding
After Brexit, will the EU recognize British passports that are valid for more than ten years?
Is divide-by-zero a security vulnerability?
Is there a math expression equivalent to the conditional ternary operator?
How does learning spells work when leveling a multiclass character?
What can I do if someone tampers with my SSH public key?
Why do we call complex numbers “numbers” but we don’t consider 2-vectors numbers?
Why isn't P and P/poly trivially the same?
ESPP--any reason not to go all in?
Where is the License file location for Identity Server in Sitecore 9.1?
What does *dead* mean in *What do you mean, dead?*?
Is there a logarithm base for which the logarithm becomes an identity function?
Is the differential, dp, exact or not?
What do you call someone who likes to pick fights?
Short SF story. Females use stingers to implant eggs in yearfathers
Does the US political system, in principle, allow for a no-party system?
Editor.target vs Editor.serializedObject
2019 Community Moderator ElectionStill can't make Escape key to quit game even in Standalone mode. How can i solve it?Dynamically creating a CustomEditor class in Unity / C#Unity Custom Inspector with sub-inspectorsUsing C# Attributes, how would I trigger functions to be executed on change of their assigned fieldIs there a way to stretch a RenderTexture playing on a plane with a VideoPlayer in Unity?How to handle touch selection on Unity3D using LeanTouch free asset?
So I have this simple script:
using UnityEngine;
public class MyScript: MonoBehaviour
public int damage = 25;
public void PrintStuff()
Debug.Log("Stuff");
And this CustomEditor where I use Editor.serializedObject
:
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(MyScript))]
public class LookAtPointEditor : Editor
SerializedProperty damageProp;
void OnEnable()
// Setup the SerializedProperties.
damageProp = serializedObject.FindProperty("damage");
public override void OnInspectorGUI()
serializedObject.Update();
EditorGUILayout.IntSlider(damageProp, 0, 100, new GUIContent("Damage"));
serializedObject.ApplyModifiedProperties();
This works fine: Undo thing works, exiting out of Play Mode works but I can do the same thing using Editor.target
and a lot easier. And all functionality works fine with Editor.target
. What is the purpose of serializedObject
then?
unity3d
add a comment |
So I have this simple script:
using UnityEngine;
public class MyScript: MonoBehaviour
public int damage = 25;
public void PrintStuff()
Debug.Log("Stuff");
And this CustomEditor where I use Editor.serializedObject
:
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(MyScript))]
public class LookAtPointEditor : Editor
SerializedProperty damageProp;
void OnEnable()
// Setup the SerializedProperties.
damageProp = serializedObject.FindProperty("damage");
public override void OnInspectorGUI()
serializedObject.Update();
EditorGUILayout.IntSlider(damageProp, 0, 100, new GUIContent("Damage"));
serializedObject.ApplyModifiedProperties();
This works fine: Undo thing works, exiting out of Play Mode works but I can do the same thing using Editor.target
and a lot easier. And all functionality works fine with Editor.target
. What is the purpose of serializedObject
then?
unity3d
add a comment |
So I have this simple script:
using UnityEngine;
public class MyScript: MonoBehaviour
public int damage = 25;
public void PrintStuff()
Debug.Log("Stuff");
And this CustomEditor where I use Editor.serializedObject
:
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(MyScript))]
public class LookAtPointEditor : Editor
SerializedProperty damageProp;
void OnEnable()
// Setup the SerializedProperties.
damageProp = serializedObject.FindProperty("damage");
public override void OnInspectorGUI()
serializedObject.Update();
EditorGUILayout.IntSlider(damageProp, 0, 100, new GUIContent("Damage"));
serializedObject.ApplyModifiedProperties();
This works fine: Undo thing works, exiting out of Play Mode works but I can do the same thing using Editor.target
and a lot easier. And all functionality works fine with Editor.target
. What is the purpose of serializedObject
then?
unity3d
So I have this simple script:
using UnityEngine;
public class MyScript: MonoBehaviour
public int damage = 25;
public void PrintStuff()
Debug.Log("Stuff");
And this CustomEditor where I use Editor.serializedObject
:
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(MyScript))]
public class LookAtPointEditor : Editor
SerializedProperty damageProp;
void OnEnable()
// Setup the SerializedProperties.
damageProp = serializedObject.FindProperty("damage");
public override void OnInspectorGUI()
serializedObject.Update();
EditorGUILayout.IntSlider(damageProp, 0, 100, new GUIContent("Damage"));
serializedObject.ApplyModifiedProperties();
This works fine: Undo thing works, exiting out of Play Mode works but I can do the same thing using Editor.target
and a lot easier. And all functionality works fine with Editor.target
. What is the purpose of serializedObject
then?
unity3d
unity3d
asked 2 days ago
Petro KovalPetro Koval
18510
18510
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Good question! The Editor API docs
explains this but the info is mostly scattered so I'll summarize:
For starters, there's an option CanEditMultipleObjects
which you're currently not using. A quote form the docs:
If this approach is used a user can select multiple assets in the
hierarchy window and change the values for all of them at once.
For a basic example of this, select two GameObjects
in your scene that have the same Unity component (like Image
or Rigidbody
) and you'll be able to modify those components at the same time to have the same values. Most built-in components support it.
This is the first advantage using serializedObject
will give you; it supports multi-object editing and Editor.target
does not (you'd need Editor.targets
for that). So now if you're wondering, "why wouldn't I just use Editor.targets
for multi-object editing?" consider this quote from the docs:
Instead of modifying script variables directly, it's advantageous to
use the SerializedObject and SerializedProperty system to edit them,
since this automatically handles multi-object editing, undo, and
Prefab overrides.
What this boils down to is that if you don't want undo, prefab override, and multi-object-editing features to be automatically handled for you, just use Editor.target
or Editor.targets
. If you do want those features to just work automatically, use SerializedObject
and SerializedProperty
.
@PetroKoval and undo, and prefab overrides, no?
– DMGregory
2 days ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55027410%2feditor-target-vs-editor-serializedobject%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Good question! The Editor API docs
explains this but the info is mostly scattered so I'll summarize:
For starters, there's an option CanEditMultipleObjects
which you're currently not using. A quote form the docs:
If this approach is used a user can select multiple assets in the
hierarchy window and change the values for all of them at once.
For a basic example of this, select two GameObjects
in your scene that have the same Unity component (like Image
or Rigidbody
) and you'll be able to modify those components at the same time to have the same values. Most built-in components support it.
This is the first advantage using serializedObject
will give you; it supports multi-object editing and Editor.target
does not (you'd need Editor.targets
for that). So now if you're wondering, "why wouldn't I just use Editor.targets
for multi-object editing?" consider this quote from the docs:
Instead of modifying script variables directly, it's advantageous to
use the SerializedObject and SerializedProperty system to edit them,
since this automatically handles multi-object editing, undo, and
Prefab overrides.
What this boils down to is that if you don't want undo, prefab override, and multi-object-editing features to be automatically handled for you, just use Editor.target
or Editor.targets
. If you do want those features to just work automatically, use SerializedObject
and SerializedProperty
.
@PetroKoval and undo, and prefab overrides, no?
– DMGregory
2 days ago
add a comment |
Good question! The Editor API docs
explains this but the info is mostly scattered so I'll summarize:
For starters, there's an option CanEditMultipleObjects
which you're currently not using. A quote form the docs:
If this approach is used a user can select multiple assets in the
hierarchy window and change the values for all of them at once.
For a basic example of this, select two GameObjects
in your scene that have the same Unity component (like Image
or Rigidbody
) and you'll be able to modify those components at the same time to have the same values. Most built-in components support it.
This is the first advantage using serializedObject
will give you; it supports multi-object editing and Editor.target
does not (you'd need Editor.targets
for that). So now if you're wondering, "why wouldn't I just use Editor.targets
for multi-object editing?" consider this quote from the docs:
Instead of modifying script variables directly, it's advantageous to
use the SerializedObject and SerializedProperty system to edit them,
since this automatically handles multi-object editing, undo, and
Prefab overrides.
What this boils down to is that if you don't want undo, prefab override, and multi-object-editing features to be automatically handled for you, just use Editor.target
or Editor.targets
. If you do want those features to just work automatically, use SerializedObject
and SerializedProperty
.
@PetroKoval and undo, and prefab overrides, no?
– DMGregory
2 days ago
add a comment |
Good question! The Editor API docs
explains this but the info is mostly scattered so I'll summarize:
For starters, there's an option CanEditMultipleObjects
which you're currently not using. A quote form the docs:
If this approach is used a user can select multiple assets in the
hierarchy window and change the values for all of them at once.
For a basic example of this, select two GameObjects
in your scene that have the same Unity component (like Image
or Rigidbody
) and you'll be able to modify those components at the same time to have the same values. Most built-in components support it.
This is the first advantage using serializedObject
will give you; it supports multi-object editing and Editor.target
does not (you'd need Editor.targets
for that). So now if you're wondering, "why wouldn't I just use Editor.targets
for multi-object editing?" consider this quote from the docs:
Instead of modifying script variables directly, it's advantageous to
use the SerializedObject and SerializedProperty system to edit them,
since this automatically handles multi-object editing, undo, and
Prefab overrides.
What this boils down to is that if you don't want undo, prefab override, and multi-object-editing features to be automatically handled for you, just use Editor.target
or Editor.targets
. If you do want those features to just work automatically, use SerializedObject
and SerializedProperty
.
Good question! The Editor API docs
explains this but the info is mostly scattered so I'll summarize:
For starters, there's an option CanEditMultipleObjects
which you're currently not using. A quote form the docs:
If this approach is used a user can select multiple assets in the
hierarchy window and change the values for all of them at once.
For a basic example of this, select two GameObjects
in your scene that have the same Unity component (like Image
or Rigidbody
) and you'll be able to modify those components at the same time to have the same values. Most built-in components support it.
This is the first advantage using serializedObject
will give you; it supports multi-object editing and Editor.target
does not (you'd need Editor.targets
for that). So now if you're wondering, "why wouldn't I just use Editor.targets
for multi-object editing?" consider this quote from the docs:
Instead of modifying script variables directly, it's advantageous to
use the SerializedObject and SerializedProperty system to edit them,
since this automatically handles multi-object editing, undo, and
Prefab overrides.
What this boils down to is that if you don't want undo, prefab override, and multi-object-editing features to be automatically handled for you, just use Editor.target
or Editor.targets
. If you do want those features to just work automatically, use SerializedObject
and SerializedProperty
.
edited 2 days ago
answered 2 days ago
FoggzieFoggzie
7,50612443
7,50612443
@PetroKoval and undo, and prefab overrides, no?
– DMGregory
2 days ago
add a comment |
@PetroKoval and undo, and prefab overrides, no?
– DMGregory
2 days ago
@PetroKoval and undo, and prefab overrides, no?
– DMGregory
2 days ago
@PetroKoval and undo, and prefab overrides, no?
– DMGregory
2 days ago
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55027410%2feditor-target-vs-editor-serializedobject%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown