Search Unity

unity run editor function everytime I save a script

Discussion in 'Editor & General Support' started by TheGameLearner, Jan 2, 2019.

  1. TheGameLearner

    TheGameLearner

    Joined:
    Feb 10, 2018
    Posts:
    20
    I have used a script which if placed in my 'Editor' folder adds creation date and time to my script. As a result I know exactly when my script was created.
    I would like to write a editor script that runs on all my scripts and If I save a script during development, It should search for a variable (updateTime) and replace the date and time with my current date and time.
    I send out scripts to others for integration and It is really hard to remember all scripts where i make minor changes after last send.

    Any minor script to do this or how to achieve it is appreciated.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Instead of this approach, you might also/instead consider using source code control, like Github.
     
  3. TheGameLearner

    TheGameLearner

    Joined:
    Feb 10, 2018
    Posts:
    20
    I have moved to git but I am curious now as to how to achieve it. Basically search a particular pattern like 'LastUpdated : 12/18/2018 3:57:41 PM' and edit it to 'LastUpdated : 12/18/2018 4:16:01 PM' or whatever is the current time.
    I tried with 'OnWillSaveAssets(string path)' but there was no effect of this.

    Also attaching the file and how I tried to code it along with my default Script Template.
     

    Attached Files:

  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You use Git commands to see when a file was last updated, never explicitly write date information
     
    TheGameLearner likes this.