Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

updating Editor Hierachy

Discussion in 'Scripting' started by buckius82, Dec 19, 2015.

  1. buckius82

    buckius82

    Joined:
    Nov 19, 2013
    Posts:
    40
    i have a function in a script

    Code (CSharp):
    1.  public void SaveCharacter(){
    2.         // check if character exists
    3.         // if it does delete file
    4.         // save new file
    5.  
    6.         BinaryFormatter bf = new BinaryFormatter();
    7.         FileStream file = File.Create(Application.dataPath + "/Resources/"+ firstname + Race + ".dat");
    8.         RTSCharContainer charCont = new RTSCharContainer();
    9. #region datainput
    10.  
    11.         charCont.Firstname = firstname;
    12.         charCont.LastName = secondname;
    13.  
    14.         charCont.Race = _raceName;
    15.         charCont.Bloodline = _bloodLine;
    16.  
    17.         charCont.Male = _male;
    18.  
    19. #endregion
    20.  
    21.         bf.Serialize(file,charCont);
    22.         file.Close();
    23.         UnityEditor.EditorApplication.RepaintHierarchyWindow();
    24.     }
    the purpose is to save a characters values to be loaded when needed;

    the problem i have is that when i invoke this function nothing happens VISUALLY the hierachy is not changed however the file is saved so it works; yay!!

    the only way i can see the file is if i bring a non unity window to the for ground: like internet explorer or chrome and then bring the unity editor to the for ground.

    or if i minimize and maximize unity. i need to know the update function called on the unity editor when unity is minimized and maximized and how to invoke if.

    is there a system update function called on windows applications?
    thank you for your help.
     
  2. buckius82

    buckius82

    Joined:
    Nov 19, 2013
    Posts:
    40
    So i solved it myself

    i called

    UnityEditor.AssetDatabase.Refresh();