- Home /
Question by
JoshPriceGames · Mar 19, 2021 at 02:59 AM ·
editorcalling
Call Function From Editor Script on Start
Hello, I have multiple editor scripts to generate terrain related stuff. I am hoping to call these on start so that every time I load the game it randomizes the terrain. (The script is called TerrainStratumPainter)
For example for the textures, in a editor window:
If I press that button it does:
if(GUI.Button(buttonRect,"do painting"))
DoPaint();
But how can I make a script to call "DoPaint" when the scene starts?
I thought it might be something like:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GenerateMap : MonoBehaviour {
// Use this for initialization
void Start () {
TerrainStratumPainter<>.DoPaint;
}
}
But it doesn't work
capture.png
(158.8 kB)
Comment
Answer by MrTinzie · Mar 19, 2021 at 10:18 AM
You'll probably want to make use of the ExecuteInEditMode script modifier. From there I would expect that you need to use the Awake function for something to happen as soon as you open the project (or change scene).
Your answer
