fix:代码提初始化
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[CustomEditor(typeof(Enviro.EnviroReflectionProbe))]
|
||||
public class EnviroReflectionProbeEditor : Editor {
|
||||
|
||||
GUIStyle boxStyle;
|
||||
GUIStyle boxStyleModified;
|
||||
GUIStyle wrapStyle;
|
||||
GUIStyle wrapStyle2;
|
||||
GUIStyle clearStyle;
|
||||
|
||||
Enviro.EnviroReflectionProbe myTarget;
|
||||
|
||||
public bool showAudio = false;
|
||||
public bool showFog = false;
|
||||
public bool showSeason = false;
|
||||
public bool showClouds = false;
|
||||
public bool showGeneral = false;
|
||||
public bool showPostProcessing = false;
|
||||
public bool showThirdParty = false;
|
||||
|
||||
private Color boxColor1;
|
||||
|
||||
SerializedObject serializedObj;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
myTarget = (Enviro.EnviroReflectionProbe)target;
|
||||
serializedObj = new SerializedObject (myTarget);
|
||||
boxColor1 = new Color(0.95f, 0.95f, 0.95f,1f);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI ()
|
||||
{
|
||||
myTarget = (Enviro.EnviroReflectionProbe)target;
|
||||
serializedObj.UpdateIfRequiredOrScript ();
|
||||
|
||||
//Set up the box style
|
||||
if (boxStyle == null)
|
||||
{
|
||||
boxStyle = new GUIStyle(GUI.skin.box);
|
||||
boxStyle.normal.textColor = GUI.skin.label.normal.textColor;
|
||||
boxStyle.fontStyle = FontStyle.Bold;
|
||||
boxStyle.alignment = TextAnchor.UpperLeft;
|
||||
}
|
||||
|
||||
if (boxStyleModified == null)
|
||||
{
|
||||
boxStyleModified = new GUIStyle(EditorStyles.helpBox);
|
||||
boxStyleModified.normal.textColor = GUI.skin.label.normal.textColor;
|
||||
boxStyleModified.fontStyle = FontStyle.Bold;
|
||||
boxStyleModified.fontSize = 11;
|
||||
boxStyleModified.alignment = TextAnchor.UpperLeft;
|
||||
}
|
||||
|
||||
//Setup the wrap style
|
||||
if (wrapStyle == null)
|
||||
{
|
||||
wrapStyle = new GUIStyle(GUI.skin.label);
|
||||
wrapStyle.fontStyle = FontStyle.Bold;
|
||||
wrapStyle.wordWrap = true;
|
||||
}
|
||||
|
||||
if (wrapStyle2 == null)
|
||||
{
|
||||
wrapStyle2 = new GUIStyle(GUI.skin.label);
|
||||
wrapStyle2.fontStyle = FontStyle.Normal;
|
||||
wrapStyle2.wordWrap = true;
|
||||
}
|
||||
|
||||
if (clearStyle == null) {
|
||||
clearStyle = new GUIStyle(GUI.skin.label);
|
||||
clearStyle.normal.textColor = GUI.skin.label.normal.textColor;
|
||||
clearStyle.fontStyle = FontStyle.Bold;
|
||||
clearStyle.alignment = TextAnchor.UpperRight;
|
||||
}
|
||||
|
||||
|
||||
GUILayout.BeginVertical(" Enviro - Reflection Probe", boxStyle);
|
||||
GUILayout.Space(30);
|
||||
GUI.backgroundColor = boxColor1;
|
||||
GUILayout.BeginVertical("Information", boxStyleModified);
|
||||
GUI.backgroundColor = Color.white;
|
||||
GUILayout.Space(20);
|
||||
EditorGUILayout.LabelField("Use this component to update your realtime reflection probes with Enviro Sky. You also can enable the 'Custom Rendering' to have enviro effects in your reflection probes!", wrapStyle2);
|
||||
EditorGUILayout.LabelField("Please enable 'Standalone Probe' if you use this component on your own places reflection probes.", wrapStyle2);
|
||||
GUILayout.EndVertical();
|
||||
GUI.backgroundColor = boxColor1;
|
||||
GUILayout.BeginVertical("Setup", boxStyleModified);
|
||||
GUI.backgroundColor = Color.white;
|
||||
GUILayout.Space(20);
|
||||
myTarget.standalone = EditorGUILayout.Toggle("Standalone Probe", myTarget.standalone);
|
||||
|
||||
if (myTarget.standalone)
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
#if ENVIRO_HD
|
||||
GUI.backgroundColor = boxColor1;
|
||||
GUILayout.BeginVertical("Enviro Effects Rendering", boxStyleModified);
|
||||
GUI.backgroundColor = Color.white;
|
||||
GUILayout.Space(20);
|
||||
myTarget.customRendering = EditorGUILayout.Toggle("Render Enviro Effects", myTarget.customRendering);
|
||||
|
||||
if(myTarget.customRendering)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
//myTarget.useFog = EditorGUILayout.Toggle("Use Fog", myTarget.useFog);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
serializedObj.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
#endif
|
||||
GUI.backgroundColor = boxColor1;
|
||||
GUILayout.BeginVertical("Update Settings", boxStyleModified);
|
||||
GUI.backgroundColor = Color.white;
|
||||
GUILayout.Space(20);
|
||||
myTarget.reflectionsUpdateTreshhold = EditorGUILayout.FloatField("Update Treshold in GameTime Hours", myTarget.reflectionsUpdateTreshhold);
|
||||
if (myTarget.customRendering)
|
||||
{
|
||||
myTarget.useTimeSlicing = EditorGUILayout.Toggle("Use Time-Slicing", myTarget.useTimeSlicing);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
// END
|
||||
EditorGUILayout.EndVertical ();
|
||||
EditorUtility.SetDirty (target);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4aeda5365286a2a46ab4f47403442a01
|
||||
timeCreated: 1497912081
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Editor/Modules/Reflections/EnviroReflectionProbeEditor.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,157 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[CustomEditor(typeof(EnviroReflectionsModule))]
|
||||
public class EnviroReflectionsModuleEditor : EnviroModuleEditor
|
||||
{
|
||||
private EnviroReflectionsModule myTarget;
|
||||
|
||||
//Properties
|
||||
//Reflection Probe
|
||||
private SerializedProperty globalReflections, customRendering, customRenderingTimeSlicing, globalReflectionTimeSlicingMode, globalReflectionsUpdateOnGameTime, globalReflectionsUpdateOnPosition, globalReflectionsIntensity, globalReflectionsTimeTreshold, globalReflectionsPositionTreshold, globalReflectionsScale, globalReflectionResolution, globalReflectionLayers, updateDefaultEnvironmentReflections;
|
||||
|
||||
//On Enable
|
||||
public override void OnEnable()
|
||||
{
|
||||
|
||||
if(!target)
|
||||
return;
|
||||
|
||||
base.OnEnable();
|
||||
|
||||
myTarget = (EnviroReflectionsModule)target;
|
||||
serializedObj = new SerializedObject(myTarget);
|
||||
preset = serializedObj.FindProperty("preset");
|
||||
//Reflection Probe
|
||||
globalReflections = serializedObj.FindProperty("Settings.globalReflections");
|
||||
updateDefaultEnvironmentReflections = serializedObj.FindProperty("Settings.updateDefaultEnvironmentReflections");
|
||||
customRendering = serializedObj.FindProperty("Settings.customRendering");
|
||||
customRenderingTimeSlicing = serializedObj.FindProperty("Settings.customRenderingTimeSlicing");
|
||||
globalReflectionTimeSlicingMode = serializedObj.FindProperty("Settings.globalReflectionTimeSlicingMode");
|
||||
globalReflectionsUpdateOnGameTime = serializedObj.FindProperty("Settings.globalReflectionsUpdateOnGameTime");
|
||||
globalReflectionsUpdateOnPosition = serializedObj.FindProperty("Settings.globalReflectionsUpdateOnPosition");
|
||||
globalReflectionsIntensity = serializedObj.FindProperty("Settings.globalReflectionsIntensity");
|
||||
globalReflectionsTimeTreshold = serializedObj.FindProperty("Settings.globalReflectionsTimeTreshold");
|
||||
globalReflectionsPositionTreshold = serializedObj.FindProperty("Settings.globalReflectionsPositionTreshold");
|
||||
globalReflectionsScale = serializedObj.FindProperty("Settings.globalReflectionsScale");
|
||||
globalReflectionResolution = serializedObj.FindProperty("Settings.globalReflectionResolution");
|
||||
globalReflectionLayers = serializedObj.FindProperty("Settings.globalReflectionLayers");
|
||||
}
|
||||
/*
|
||||
|
||||
*/
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if(!target)
|
||||
return;
|
||||
|
||||
base.OnInspectorGUI();
|
||||
|
||||
GUI.backgroundColor = new Color(0.0f,0.0f,0.5f,1f);
|
||||
GUILayout.BeginVertical("",boxStyleModified);
|
||||
GUI.backgroundColor = Color.white;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
myTarget.showModuleInspector = GUILayout.Toggle(myTarget.showModuleInspector, "Reflections", headerFoldout);
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
if(GUILayout.Button("x", EditorStyles.miniButtonRight,GUILayout.Width(18), GUILayout.Height(18)))
|
||||
{
|
||||
EnviroManager.instance.RemoveModule(EnviroManager.ModuleType.Reflections);
|
||||
DestroyImmediate(this);
|
||||
return;
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if(myTarget.showModuleInspector)
|
||||
{
|
||||
//RenderDisableInputBox();
|
||||
serializedObj.UpdateIfRequiredOrScript ();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
GUI.backgroundColor = categoryModuleColor;
|
||||
GUILayout.BeginVertical("",boxStyleModified);
|
||||
GUI.backgroundColor = Color.white;
|
||||
myTarget.showReflectionControls = GUILayout.Toggle(myTarget.showReflectionControls, "Reflection Controls", headerFoldout);
|
||||
if(myTarget.showReflectionControls)
|
||||
{
|
||||
EditorGUILayout.PropertyField(globalReflections);
|
||||
GUILayout.Space(5);
|
||||
EditorGUILayout.PropertyField(globalReflectionsIntensity);
|
||||
#if !ENVIRO_HDRP
|
||||
EditorGUILayout.PropertyField(globalReflectionResolution);
|
||||
#endif
|
||||
EditorGUILayout.PropertyField(globalReflectionLayers);
|
||||
EditorGUILayout.PropertyField(globalReflectionsScale);
|
||||
#if !ENVIRO_HDRP
|
||||
|
||||
#if ENVIRO_URP
|
||||
EditorGUILayout.PropertyField(updateDefaultEnvironmentReflections);
|
||||
GUILayout.Space(5);
|
||||
EditorGUILayout.PropertyField(globalReflectionTimeSlicingMode);
|
||||
#else
|
||||
GUILayout.Space(5);
|
||||
EditorGUILayout.PropertyField(updateDefaultEnvironmentReflections);
|
||||
GUILayout.Space(5);
|
||||
EditorGUILayout.PropertyField(customRendering);
|
||||
|
||||
if (myTarget.Settings.customRendering)
|
||||
EditorGUILayout.PropertyField(customRenderingTimeSlicing);
|
||||
else
|
||||
EditorGUILayout.PropertyField(globalReflectionTimeSlicingMode);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.PropertyField(globalReflectionsUpdateOnGameTime);
|
||||
if(myTarget.Settings.globalReflectionsUpdateOnGameTime)
|
||||
EditorGUILayout.PropertyField(globalReflectionsTimeTreshold);
|
||||
GUILayout.Space(5);
|
||||
EditorGUILayout.PropertyField(globalReflectionsUpdateOnPosition);
|
||||
if(myTarget.Settings.globalReflectionsUpdateOnPosition)
|
||||
EditorGUILayout.PropertyField(globalReflectionsPositionTreshold);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
|
||||
/// Save Load
|
||||
GUI.backgroundColor = categoryModuleColor;
|
||||
GUILayout.BeginVertical("",boxStyleModified);
|
||||
GUI.backgroundColor = Color.white;
|
||||
myTarget.showSaveLoad = GUILayout.Toggle(myTarget.showSaveLoad, "Save/Load", headerFoldout);
|
||||
|
||||
if(myTarget.showSaveLoad)
|
||||
{
|
||||
EditorGUILayout.PropertyField(preset);
|
||||
GUILayout.BeginHorizontal("",wrapStyle);
|
||||
if(myTarget.preset != null)
|
||||
{
|
||||
if(GUILayout.Button("Load"))
|
||||
{
|
||||
myTarget.LoadModuleValues();
|
||||
}
|
||||
if(GUILayout.Button("Save"))
|
||||
{
|
||||
myTarget.SaveModuleValues(myTarget.preset);
|
||||
}
|
||||
}
|
||||
if(GUILayout.Button("Save As New"))
|
||||
{
|
||||
myTarget.SaveModuleValues();
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
/// Save Load End
|
||||
|
||||
ApplyChanges ();
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
if(myTarget.showModuleInspector)
|
||||
GUILayout.Space(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97b7cead2ccaee54e80b6be7d7273231
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/Editor/Modules/Reflections/EnviroReflectionsModuleEditor.cs
|
||||
uploadId: 660896
|
||||
Reference in New Issue
Block a user