/**************************************************************************** * Copyright 2019 Nreal Techonology Limited. All rights reserved. * * This file is part of NRSDK. * * https://www.nreal.ai/ * *****************************************************************************/ namespace NRKernal { using System; using UnityEditor; /// Manager for script orders. [InitializeOnLoad] public class ScriptOrderManager { /// Static constructor. static ScriptOrderManager() { foreach (MonoScript monoScript in MonoImporter.GetAllRuntimeMonoScripts()) { if (monoScript.GetClass() != null) { foreach (var a in Attribute.GetCustomAttributes(monoScript.GetClass(), typeof(ScriptOrder))) { var currentOrder = MonoImporter.GetExecutionOrder(monoScript); var newOrder = ((ScriptOrder)a).order; if (currentOrder != newOrder) MonoImporter.SetExecutionOrder(monoScript, newOrder); } } } } } }