mirror of
https://github.com/muskit/H3VR-TNH-Quality-of-Life-Improvements.git
synced 2026-06-03 04:34:26 -07:00
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
|
|
// Alloy Physical Shader Framework
|
||
|
|
// Copyright 2013-2017 RUST LLC.
|
||
|
|
// http://www.alloy.rustltd.com/
|
||
|
|
using System;
|
||
|
|
using System.Linq;
|
||
|
|
using MeatKit;
|
||
|
|
using UnityEditor;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
[CustomEditor(typeof(Camera))]
|
||
|
|
[CanEditMultipleObjects]
|
||
|
|
public class AlloyCameraEditor : Editor {
|
||
|
|
Editor m_editor;
|
||
|
|
|
||
|
|
Type GetTypeGlobal(string typeName) {
|
||
|
|
return AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypesSafe()).FirstOrDefault(t => t.Name == typeName);
|
||
|
|
}
|
||
|
|
|
||
|
|
void OnEnable() {
|
||
|
|
m_editor = CreateEditor(targets, GetTypeGlobal("CameraEditor"));
|
||
|
|
}
|
||
|
|
|
||
|
|
void OnDisable() {
|
||
|
|
DestroyImmediate(m_editor);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void OnInspectorGUI() {
|
||
|
|
m_editor.OnInspectorGUI();
|
||
|
|
bool anyMissing = targets.Any(c => ((Camera)c).GetComponent<AlloyEffectsManager>() == null);
|
||
|
|
|
||
|
|
if (anyMissing) {
|
||
|
|
if (GUILayout.Button("Convert to Alloy Effects Manager", EditorStyles.toolbarButton)) {
|
||
|
|
foreach (Camera camera in targets) {
|
||
|
|
Undo.AddComponent<AlloyEffectsManager>(camera.gameObject);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|