• 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 /
avatar image
0
Question by manGo29 · Dec 26, 2015 at 03:20 PM · c#prefabprefab-instance

Prefabs & Instances

I have a bunch of prefabbed characters that all have a "unitAI" C# script attached to them. One public variable in this ai script is a public enum list, which contains "player," "neutral," or "enemy" strings, and another public variable for me to choose which Owner the unit belongs to. Currently, whenever I make any change to the unit's other variables and apply it to the prefab, it'll change this Owner enum value to this particular instance.

So, if I've already placed a dozen of this unit in an area as Neutrals, and now I'm planting a bunch of enemies and change any value on my prefab, ALL of these prefab instances now become Enemy instances. I understand that this is how prefabs are built to work, but is there a way to flag or tag my enum variables so that changing the prefab won't affect this one variable per instance?

Comment
Add comment · Show 1
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 pako · Dec 26, 2015 at 09:22 PM 0
Share

Not as far as I know. $$anonymous$$aybe you should consider using a different prefab per setting, otherwise whenever you change a setting in the prefab all instances based on that prefab will change (as you very well know). So, either change the setting on the instances only, rather than the prefab, or have a separate prefab per setting you want to instantiate.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by NGC6543 · Dec 27, 2015 at 01:05 AM

You'd better creating multiple prefabs for each "player", "neutral", and "enemy", I guess. That's exactly what prefab is intended to do.

Comment
Add comment · 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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

45 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 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

Link GUIText to a prefab? 2 Answers

Prefabs spawn with wrong values 0 Answers

How can I destroy a gameobject that is part of a prefab ? 0 Answers

Multiple Cars not working 1 Answer

Changes to prefab instance generated from script aren't remembered 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges