This commit is contained in:
2025-09-17 18:56:28 +08:00
commit 54c72710a5
5244 changed files with 5717609 additions and 0 deletions

View File

@@ -0,0 +1,123 @@
using UnityEditor;
using UnityEngine;
namespace DestroyIt
{
[CustomEditor (typeof(ColorCorrectionCurves))]
class ColorCorrectionCurvesEditor : Editor {
SerializedObject serObj;
SerializedProperty mode;
SerializedProperty redChannel;
SerializedProperty greenChannel;
SerializedProperty blueChannel;
SerializedProperty useDepthCorrection;
SerializedProperty depthRedChannel;
SerializedProperty depthGreenChannel;
SerializedProperty depthBlueChannel;
SerializedProperty zCurveChannel;
SerializedProperty saturation;
SerializedProperty selectiveCc;
SerializedProperty selectiveFromColor;
SerializedProperty selectiveToColor;
private bool applyCurveChanges = false;
void OnEnable () {
serObj = new SerializedObject (target);
mode = serObj.FindProperty ("mode");
saturation = serObj.FindProperty ("saturation");
redChannel = serObj.FindProperty ("redChannel");
greenChannel = serObj.FindProperty ("greenChannel");
blueChannel = serObj.FindProperty ("blueChannel");
useDepthCorrection = serObj.FindProperty ("useDepthCorrection");
zCurveChannel = serObj.FindProperty ("zCurve");
depthRedChannel = serObj.FindProperty ("depthRedChannel");
depthGreenChannel = serObj.FindProperty ("depthGreenChannel");
depthBlueChannel = serObj.FindProperty ("depthBlueChannel");
serObj.ApplyModifiedProperties ();
selectiveCc = serObj.FindProperty ("selectiveCc");
selectiveFromColor = serObj.FindProperty ("selectiveFromColor");
selectiveToColor = serObj.FindProperty ("selectiveToColor");
}
void CurveGui ( string name, SerializedProperty animationCurve, Color color) {
// @NOTE: EditorGUILayout.CurveField is buggy and flickers, using PropertyField for now
//animationCurve.animationCurveValue = EditorGUILayout.CurveField (GUIContent (name), animationCurve.animationCurveValue, color, Rect (0.0f,0.0f,1.0f,1.0f));
EditorGUILayout.PropertyField (animationCurve, new GUIContent (name));
if (GUI.changed)
applyCurveChanges = true;
}
void BeginCurves () {
applyCurveChanges = false;
}
void ApplyCurves () {
if (applyCurveChanges) {
serObj.ApplyModifiedProperties ();
(serObj.targetObject as ColorCorrectionCurves).gameObject.SendMessage ("UpdateTextures");
}
}
public override void OnInspectorGUI () {
serObj.Update ();
GUILayout.Label ("Use curves to tweak RGB channel colors", EditorStyles.miniBoldLabel);
saturation.floatValue = EditorGUILayout.Slider( "Saturation", saturation.floatValue, 0.0f, 5.0f);
EditorGUILayout.PropertyField (mode, new GUIContent ("Mode"));
EditorGUILayout.Separator ();
BeginCurves ();
CurveGui (" Red", redChannel, Color.red);
CurveGui (" Green", greenChannel, Color.green);
CurveGui (" Blue", blueChannel, Color.blue);
EditorGUILayout.Separator ();
if (mode.intValue > 0)
useDepthCorrection.boolValue = true;
else
useDepthCorrection.boolValue = false;
if (useDepthCorrection.boolValue) {
CurveGui (" Red (depth)", depthRedChannel, Color.red);
CurveGui (" Green (depth)", depthGreenChannel, Color.green);
CurveGui (" Blue (depth)", depthBlueChannel, Color.blue);
EditorGUILayout.Separator ();
CurveGui (" Blend Curve", zCurveChannel, Color.grey);
}
EditorGUILayout.Separator ();
EditorGUILayout.PropertyField (selectiveCc, new GUIContent ("Selective"));
if (selectiveCc.boolValue) {
EditorGUILayout.PropertyField (selectiveFromColor, new GUIContent (" Key"));
EditorGUILayout.PropertyField (selectiveToColor, new GUIContent (" Target"));
}
ApplyCurves ();
if (!applyCurveChanges)
serObj.ApplyModifiedProperties ();
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 4db7e5f0702b8664a9dcc0d4dfba5691
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:

View File

@@ -0,0 +1,23 @@
using UnityEditor;
namespace DestroyIt
{
[CustomEditor(typeof(Follow))]
public class FollowEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
Follow script = target as Follow;
// FixedFromPosition and FixedDistance should only be available when FixedPosition is true.
script.isPositionFixed = EditorGUILayout.Toggle("Is Fixed From Position", script.isPositionFixed);
if (script.isPositionFixed)
{
script.fixedFromPosition = EditorGUILayout.Vector3Field("Position", script.fixedFromPosition);
script.fixedDistance = EditorGUILayout.FloatField("Distance", script.fixedDistance);
}
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 997b49b1f5939cf4dbe4fcee14094752
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,46 @@
using UnityEditor;
using UnityEngine;
namespace DestroyIt
{
public class SetupDestroyItDemo
{
[MenuItem("Window/DestroyIt/Setup - First Person Controller")]
public static void SetupFirstPersonControllerMenuOption()
{
DestructionManager destructionManager = Object.FindObjectOfType<DestructionManager>();
if (destructionManager == null)
SetupDestroyIt.SetupMinimalMenuOption();
destructionManager = Object.FindObjectOfType<DestructionManager>();
string fpControllerPath = "Assets/DestroyIt/Demos (safe to delete)/Prefabs/Character Controllers/First Person Controller.prefab";
GameObject fpController = AssetDatabase.LoadAssetAtPath<GameObject>(fpControllerPath);
if (fpController == null)
{
Debug.LogWarning("Could not find asset " + fpControllerPath);
return;
}
// if there is already a Main camera in the scene, disable it.
Camera cam = Camera.main;
if (cam != null)
cam.gameObject.SetActive(false);
GameObject fpControllerObj = PrefabUtility.InstantiatePrefab(fpController) as GameObject;
InputManager inputManager = fpControllerObj.GetComponent<InputManager>();
ObjectPool pool = destructionManager.gameObject.GetComponent<ObjectPool>();
pool.prefabsToPool.Add(new PoolEntry() {Count = 20, Prefab = inputManager.bulletPrefab});
pool.prefabsToPool.Add(new PoolEntry() {Count = 5, Prefab = inputManager.rocketPrefab});
pool.prefabsToPool.Add(new PoolEntry() {Count = 20, Prefab = inputManager.cannonballPrefab});
pool.prefabsToPool.Add(new PoolEntry() {Count = 1, Prefab = inputManager.nukePrefab});
pool.prefabsToPool.Add(new PoolEntry() {Count = 1, Prefab = inputManager.dustWallPrefab});
string effectsPrefabPath = "Assets/DestroyIt/Demos (safe to delete)/Prefabs/Effects/";
GameObject rocketSmokeTrailPrefab = AssetDatabase.LoadAssetAtPath<GameObject>(effectsPrefabPath + "Rocket Smoke Trail.prefab");
pool.prefabsToPool.Add(new PoolEntry() {Count = 10, Prefab = rocketSmokeTrailPrefab});
GameObject burstFlamePrefabPath = AssetDatabase.LoadAssetAtPath<GameObject>(effectsPrefabPath + "BurstFlame.prefab");
pool.prefabsToPool.Add(new PoolEntry() {Count = 10, Prefab = burstFlamePrefabPath});
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6b5d95ba491b4bc298e4e51460a6ad97
timeCreated: 1546043554

View File

@@ -0,0 +1,80 @@
using UnityEditor;
using UnityEngine;
namespace DestroyIt
{
[CustomEditor (typeof(Tonemapping))]
class TonemappingEditor : Editor
{
SerializedObject serObj;
SerializedProperty type;
// CURVE specific parameter
SerializedProperty remapCurve;
SerializedProperty exposureAdjustment;
// REINHARD specific parameter
SerializedProperty middleGrey;
SerializedProperty white;
SerializedProperty adaptionSpeed;
SerializedProperty adaptiveTextureSize;
void OnEnable () {
serObj = new SerializedObject (target);
type = serObj.FindProperty ("type");
remapCurve = serObj.FindProperty ("remapCurve");
exposureAdjustment = serObj.FindProperty ("exposureAdjustment");
middleGrey = serObj.FindProperty ("middleGrey");
white = serObj.FindProperty ("white");
adaptionSpeed = serObj.FindProperty ("adaptionSpeed");
adaptiveTextureSize = serObj.FindProperty("adaptiveTextureSize");
}
public override void OnInspectorGUI () {
serObj.Update ();
GUILayout.Label("Mapping HDR to LDR ranges since 1982", EditorStyles.miniLabel);
Camera cam = (target as Tonemapping).GetComponent<Camera>();
if (cam != null) {
if (!cam.allowHDR) {
EditorGUILayout.HelpBox("The camera is not HDR enabled. This will likely break the Tonemapper.", MessageType.Warning);
}
else if (!(target as Tonemapping).validRenderTextureFormat) {
EditorGUILayout.HelpBox("The input to Tonemapper is not in HDR. Make sure that all effects prior to this are executed in HDR.", MessageType.Warning);
}
}
EditorGUILayout.PropertyField (type, new GUIContent ("Technique"));
if (type.enumValueIndex == (int) Tonemapping.TonemapperType.UserCurve) {
EditorGUILayout.PropertyField (remapCurve, new GUIContent ("Remap curve", "Specify the mapping of luminances yourself"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.SimpleReinhard) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.Hable) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.Photographic) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.OptimizedHejiDawson) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.AdaptiveReinhard) {
EditorGUILayout.PropertyField (middleGrey, new GUIContent ("Middle grey", "Middle grey defines the average luminance thus brightening or darkening the entire image."));
EditorGUILayout.PropertyField (white, new GUIContent ("White", "Smallest luminance value that will be mapped to white"));
EditorGUILayout.PropertyField (adaptionSpeed, new GUIContent ("Adaption Speed", "Speed modifier for the automatic adaption"));
EditorGUILayout.PropertyField (adaptiveTextureSize, new GUIContent ("Texture size", "Defines the amount of downsamples needed."));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.AdaptiveReinhardAutoWhite) {
EditorGUILayout.PropertyField (middleGrey, new GUIContent ("Middle grey", "Middle grey defines the average luminance thus brightening or darkening the entire image."));
EditorGUILayout.PropertyField (adaptionSpeed, new GUIContent ("Adaption Speed", "Speed modifier for the automatic adaption"));
EditorGUILayout.PropertyField (adaptiveTextureSize, new GUIContent ("Texture size", "Defines the amount of downsamples needed."));
}
GUILayout.Label("All following effects will use LDR color buffers", EditorStyles.miniBoldLabel);
serObj.ApplyModifiedProperties();
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2ddd43d5ae63f0242b491e0cc5236a0c
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName: