12345678910111213141516171819202122232425262728293031323334353637 |
- /****************************************************************************
- * Copyright 2019 Nreal Techonology Limited. All rights reserved.
- *
- * This file is part of NRSDK.
- *
- * https://www.nreal.ai/
- *
- *****************************************************************************/
- namespace NRKernal
- {
- using System;
- using UnityEditor;
- /// <summary> Manager for script orders. </summary>
- [InitializeOnLoad]
- public class ScriptOrderManager
- {
- /// <summary> Static constructor. </summary>
- 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);
- }
- }
- }
- }
- }
- }
|