Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Dec 12, 2018 at 01:43 PM by Bunny83 for the following reason:

The question is answered, right answer was accepted

avatar image
5
Question by ScotchBunny · Apr 09, 2015 at 07:12 AM · c#script.warnings

EditorGUILayout.ObjectField obsolete?

Hi guys

I am writing my first editor script, and I need a field for dragging in a prefab holding one of my classes.

Right now I am using EditorGUILayout.ObjectField and i works just fine; something like this:

 target.myClass = EditorGUILayout.ObjectField("Label:", target.myClass, typeof(MyClass));

However, I get a warning in the console, saying that the function is obsolete, telling me to look at the docs for the usage of the new parameter 'allowSceneObjects'. A similar massage is in the API docs:

EditorGUILayout.ObjectField

Googling allowSceneObjects has yielded no answers so far, so could someone fill me in on what is going on? I am using Unity 5 and C# scripts.

Comment
Comments Locked
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

  • Sort: 
avatar image
18
Best Answer

Answer by frarees · Apr 09, 2015 at 09:04 AM

Use the recommended overloads instead. In your case:

 target.myClass = EditorGUILayout.ObjectField("Label:", target.myClass, typeof(MyClass), true);

That true above tells the editor property to allow also scene objects. Set to false if you only want assets to be allowed.

Comment
Comments Locked · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
6

Answer by FlightOfOne · Mar 09, 2016 at 12:59 PM

Hopefully this might help someone, this is how I did it. Key is to have 'true' at the end.

 GameObject fireEffect
 
 --------------------------------------------- 
 
 myDmgScript.fireEffect = (GameObject)EditorGUILayout.ObjectField("Fire Effect", myDmgScript.fireEffect, typeof(GameObject), true);


Comment
Comments Locked · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Mar 09, 2016 at 04:17 PM -1
Share

This answer doesn't add anthing useful. The question has already been answered in april 2015 by frarees. He also explains what that new last parameter is good for which you didn't even mention. You just bumped the question

avatar image jasond916 · Aug 16, 2018 at 07:48 AM 1
Share

I was trying to figure out how to make it for a GameObject. Thanks!!!!

avatar image
5

Answer by KitoCode · Apr 09, 2015 at 10:16 AM

When receiving a warning that the method or constructor is Obsolete, that is Unity's way of saying that we no longer are going to support this method in future updates. AllowSceneObjects is a parameter of ObjectField().

Parameters

label
Optional label in front of the field.

obj
The object the field shows.

objType
The type of the objects that can be assigned.

allowSceneObjects
Allow assigning scene objects. See Description for more info.

options An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the style. See Also: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Could you provide us with the exact warning. If this isn't a pressing matter, these kind of warning can often be over looked. It is bad coding practice, but hey, Camer.mainCamera is still around after being obsolete for years!

Comment
Comments Locked · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

25 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

Is it possible to create sound with scripting? 4 Answers

How do I make the platform spawn after the other one 1 Answer

How to keep the old line text? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges