Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by zackyang421 · Oct 13, 2021 at 01:37 AM · unityeditorobjects

Game Object Created by script disappeared after reopen the project

Hello Guys:
I'm currently writing a game manager, which can be used to edit some basic status of the game character before we put it to the scene. So I'm using the following script to add a character

 public class AddCharacter : EditorWindow
 {
     GameObject obj = null;
     GameObject tempobj = null;
     Vector3 vec3 = new Vector3(0, 0, 0);
     CharacterClass classname = null;
     string objname = "";
     [MenuItem("Asset/TestCreate")]
     public static void ShowWindow()
     {
         var window = GetWindow<AddCharacter>();
         window.title = "Create Character";
     }
     public void OnGUI()
     {
         EditorGUILayout.BeginVertical();
         obj = EditorGUILayout.ObjectField("Select game object to place", obj, typeof(GameObject), true) as GameObject;
         vec3 = EditorGUILayout.Vector3Field("placement position:", vec3);
         objname = EditorGUILayout.TextField("Name for new Character: ", objname);
 
         if (obj && objname != "")
         {
             if (GUILayout.Button("Add to scene"))
             {
                 tempobj = (GameObject)Instantiate(obj, vec3, Quaternion.identity);
                 tempobj.name = objname;
                 Characters temp = tempobj.GetComponent<Characters>();
                 CharacterClass selectedclass = AIManager.Instance.GetNewCharInfo();
                 temp.SetName(objname);
                 temp.SetClass(selectedclass);
                 temp.UpdateCharacter();
                 selectedclass.AddCharacters(objname);
                 AIManager.Instance.setnewChar(true);
                 AIManager.Instance.CreateCharacters(objname);
                 Close();
             }
         }
         else
         {
             EditorGUILayout.LabelField("You must select an object and give it a name first");
         }
         EditorGUILayout.EndVertical();
     }
 }
 

However, I found that everything I've created by using this game manager is disappeared after I reopen my project, so I'm wondering is there a way to keep those changes(Add/delete a game object by script) in Unity?

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

0 Replies

· Add your reply
  • Sort: 

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.

Follow this Question

Answers Answers and Comments

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

Can we do object recognition functionality in unity using IR touch panel tangible object? 0 Answers

Unity Ads Vs Unity Ads 2.0 0 Answers

(Final IK) How can I change the Type of the Weight Curve of an Interaction Object from the script? 0 Answers

UNITY EN USB PARA OSCILOSCOPIO 0 Answers

Unity Editor Slows Down, It's Lagging, & Problem navigating in Unity Editor 0 Answers


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