工具间修改+高亮插件导入

This commit is contained in:
taosuqi 2024-08-09 15:35:00 +08:00
parent 9f85a2fafa
commit f673dc54cb
97 changed files with 12106 additions and 21 deletions

View File

@ -11,6 +11,8 @@ GameObject:
- component: {fileID: 2399593117452945566} - component: {fileID: 2399593117452945566}
- component: {fileID: 2399593117452945567} - component: {fileID: 2399593117452945567}
- component: {fileID: 2399593117452945568} - component: {fileID: 2399593117452945568}
- component: {fileID: 3910755197489471127}
- component: {fileID: 7005868485670428847}
m_Layer: 0 m_Layer: 0
m_Name: Player m_Name: Player
m_TagString: Player m_TagString: Player
@ -54,13 +56,13 @@ MonoBehaviour:
mouseSensitivity: 2 mouseSensitivity: 2
maxLookAngle: 50 maxLookAngle: 50
lockCursor: 0 lockCursor: 0
crosshair: 0 crosshair: 1
crosshairImage: {fileID: 0} crosshairImage: {fileID: 21300000, guid: be4ce60e2c9768c44b9b10b9c5258045, type: 3}
crosshairColor: {r: 1, g: 1, b: 1, a: 1} crosshairColor: {r: 1, g: 1, b: 1, a: 1}
yaw: 0 yaw: 0
pitch: 0 pitch: 0
enableZoom: 0 enableZoom: 0
holdToZoom: 0 holdToZoom: 1
zoomKey: 324 zoomKey: 324
zoomFOV: 30 zoomFOV: 30
zoomStepTime: 5 zoomStepTime: 5
@ -68,8 +70,8 @@ MonoBehaviour:
stopForce: 1 stopForce: 1
walkSpeed: 5 walkSpeed: 5
maxVelocityChange: 10 maxVelocityChange: 10
enableSprint: 0 enableSprint: 1
unlimitedSprint: 0 unlimitedSprint: 1
enableSprintZoom: 0 enableSprintZoom: 0
sprintKey: 304 sprintKey: 304
sprintSpeed: 7 sprintSpeed: 7
@ -82,7 +84,7 @@ MonoBehaviour:
sprintBarBG: {fileID: 0} sprintBarBG: {fileID: 0}
sprintBar: {fileID: 0} sprintBar: {fileID: 0}
sprintBarWidthPercent: 0.3 sprintBarWidthPercent: 0.3
sprintBarHeightPercent: 0.015 sprintBarHeightPercent: 0.02
enableJump: 0 enableJump: 0
jumpKey: 32 jumpKey: 32
jumpPower: 5 jumpPower: 5
@ -111,6 +113,28 @@ Rigidbody:
m_Interpolate: 0 m_Interpolate: 0
m_Constraints: 112 m_Constraints: 112
m_CollisionDetection: 0 m_CollisionDetection: 0
--- !u!136 &3910755197489471127
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2399593117452945565}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.5
m_Height: 1
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!33 &7005868485670428847
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2399593117452945565}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &2399593117623680739 --- !u!1 &2399593117623680739
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -240,7 +264,6 @@ GameObject:
- component: {fileID: 2399593117846495248} - component: {fileID: 2399593117846495248}
- component: {fileID: 2399593117846495251} - component: {fileID: 2399593117846495251}
- component: {fileID: 2399593117846495250} - component: {fileID: 2399593117846495250}
- component: {fileID: 2399593117846495249}
m_Layer: 0 m_Layer: 0
m_Name: Capsule m_Name: Capsule
m_TagString: Untagged m_TagString: Untagged
@ -314,17 +337,3 @@ MeshRenderer:
m_SortingLayer: 0 m_SortingLayer: 0
m_SortingOrder: 0 m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0} m_AdditionalVertexStreams: {fileID: 0}
--- !u!136 &2399593117846495249
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2399593117846495247}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.5
m_Height: 2
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 32fcef8fb35968e48a77e010ca7b63f4
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c981a85c287232f44b4e35be69f425ea
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c4d9487b5d51a5340b44d2df89c0d411
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,675 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace HighlightPlus {
[CustomEditor(typeof(HighlightEffect))]
[CanEditMultipleObjects]
public class HighlightEffectEditor : Editor {
#pragma warning disable 0618
SerializedProperty profile, profileSync, camerasLayerMask, ignoreObjectVisibility, reflectionProbes, GPUInstancing;
SerializedProperty ignore, previewInEditor, effectGroup, effectGroupLayer, effectNameFilter, combineMeshes, alphaCutOff, cullBackFaces, depthClip, normalsOption, subMeshMask;
SerializedProperty highlighted, fadeInDuration, fadeOutDuration, flipY, constantWidth;
SerializedProperty overlay, overlayMode, overlayColor, overlayAnimationSpeed, overlayMinIntensity, overlayBlending, overlayTexture, overlayTextureUVSpace, overlayTextureScale;
SerializedProperty outline, outlineColor, outlineColorStyle, outlineGradient, outlineGradientInLocalSpace, outlineWidth, outlineQuality, outlineDownsampling, outlineVisibility, outlineOptimalBlit, outlineBlitDebug, outlineIndependent;
SerializedProperty glow, glowWidth, glowQuality, glowDownsampling, glowHQColor, glowDithering, glowMagicNumber1, glowMagicNumber2, glowAnimationSpeed, glowBlendPasses, glowPasses, glowVisibility, glowBlendMode, glowOptimalBlit, glowBlitDebug, glowIgnoreMask;
SerializedProperty innerGlow, innerGlowWidth, innerGlowColor, innerGlowVisibility;
SerializedProperty seeThrough, seeThroughOccluderMask, seeThroughOccluderMaskAccurate, seeThroughOccluderThreshold, seeThroughOccluderCheckInterval, seeThroughOccluderCheckIndividualObjects, seeThroughDepthOffset, seeThroughMaxDepth;
SerializedProperty seeThroughIntensity, seeThroughTintAlpha, seeThroughTintColor, seeThroughNoise, seeThroughBorder, seeThroughBorderWidth, seeThroughBorderColor, seeThroughOrdered, seeThroughBorderOnly, seeThroughTexture, seeThroughTextureUVSpace, seeThroughTextureScale;
SerializedProperty targetFX, targetFXTexture, targetFXColor, targetFXCenter, targetFXRotationSpeed, targetFXInitialScale, targetFXEndScale, targetFXScaleToRenderBounds;
SerializedProperty targetFXAlignToGround, targetFXFadePower, targetFXGroundMaxDistance, targetFXGroundLayerMask, targetFXTransitionDuration, targetFXStayDuration, targetFXVisibility;
SerializedProperty hitFxInitialIntensity, hitFxMode, hitFxFadeOutDuration, hitFxColor, hitFxRadius;
SerializedProperty cameraDistanceFade, cameraDistanceFadeNear, cameraDistanceFadeFar;
HighlightEffect thisEffect;
bool profileChanged, enableProfileApply;
bool expandGeneralSettings, expandHighlightOptions;
bool showCurrentOccluders;
const string HP_GENERAL_SETTINGS = "HPGeneralSettings";
const string HP_HIGHLIGHT_OPTIONS = "HPHighlightOptions";
GUIStyle foldoutBold;
void OnEnable() {
expandGeneralSettings = EditorPrefs.GetBool("HPGeneralSettings", true);
expandHighlightOptions = EditorPrefs.GetBool("HPHighlightOptions", true);
profile = serializedObject.FindProperty("profile");
profileSync = serializedObject.FindProperty("profileSync");
camerasLayerMask = serializedObject.FindProperty("camerasLayerMask");
reflectionProbes = serializedObject.FindProperty("reflectionProbes");
ignoreObjectVisibility = serializedObject.FindProperty("ignoreObjectVisibility");
GPUInstancing = serializedObject.FindProperty("GPUInstancing");
normalsOption = serializedObject.FindProperty("normalsOption");
subMeshMask = serializedObject.FindProperty("subMeshMask");
ignore = serializedObject.FindProperty("ignore");
previewInEditor = serializedObject.FindProperty("previewInEditor");
effectGroup = serializedObject.FindProperty("effectGroup");
effectGroupLayer = serializedObject.FindProperty("effectGroupLayer");
effectNameFilter = serializedObject.FindProperty("effectNameFilter");
combineMeshes = serializedObject.FindProperty("combineMeshes");
alphaCutOff = serializedObject.FindProperty("alphaCutOff");
cullBackFaces = serializedObject.FindProperty("cullBackFaces");
depthClip = serializedObject.FindProperty("depthClip");
highlighted = serializedObject.FindProperty("_highlighted");
fadeInDuration = serializedObject.FindProperty("fadeInDuration");
fadeOutDuration = serializedObject.FindProperty("fadeOutDuration");
flipY = serializedObject.FindProperty("flipY");
constantWidth = serializedObject.FindProperty("constantWidth");
overlay = serializedObject.FindProperty("overlay");
overlayMode = serializedObject.FindProperty("overlayMode");
overlayColor = serializedObject.FindProperty("overlayColor");
overlayAnimationSpeed = serializedObject.FindProperty("overlayAnimationSpeed");
overlayMinIntensity = serializedObject.FindProperty("overlayMinIntensity");
overlayBlending = serializedObject.FindProperty("overlayBlending");
overlayTexture = serializedObject.FindProperty("overlayTexture");
overlayTextureUVSpace = serializedObject.FindProperty("overlayTextureUVSpace");
overlayTextureScale = serializedObject.FindProperty("overlayTextureScale");
outline = serializedObject.FindProperty("outline");
outlineColor = serializedObject.FindProperty("outlineColor");
outlineColorStyle = serializedObject.FindProperty("outlineColorStyle");
outlineGradient = serializedObject.FindProperty("outlineGradient");
outlineGradientInLocalSpace = serializedObject.FindProperty("outlineGradientInLocalSpace");
outlineWidth = serializedObject.FindProperty("outlineWidth");
outlineQuality = serializedObject.FindProperty("outlineQuality");
outlineDownsampling = serializedObject.FindProperty("outlineDownsampling");
outlineVisibility = serializedObject.FindProperty("outlineVisibility");
outlineOptimalBlit = serializedObject.FindProperty("outlineOptimalBlit");
outlineBlitDebug = serializedObject.FindProperty("outlineBlitDebug");
outlineIndependent = serializedObject.FindProperty("outlineIndependent");
glow = serializedObject.FindProperty("glow");
glowWidth = serializedObject.FindProperty("glowWidth");
glowQuality = serializedObject.FindProperty("glowQuality");
glowDownsampling = serializedObject.FindProperty("glowDownsampling");
glowHQColor = serializedObject.FindProperty("glowHQColor");
glowAnimationSpeed = serializedObject.FindProperty("glowAnimationSpeed");
glowBlendPasses = serializedObject.FindProperty("glowBlendPasses");
glowDithering = serializedObject.FindProperty("glowDithering");
glowMagicNumber1 = serializedObject.FindProperty("glowMagicNumber1");
glowMagicNumber2 = serializedObject.FindProperty("glowMagicNumber2");
glowAnimationSpeed = serializedObject.FindProperty("glowAnimationSpeed");
glowPasses = serializedObject.FindProperty("glowPasses");
glowVisibility = serializedObject.FindProperty("glowVisibility");
glowBlendMode = serializedObject.FindProperty("glowBlendMode");
glowOptimalBlit = serializedObject.FindProperty("glowOptimalBlit");
glowBlitDebug = serializedObject.FindProperty("glowBlitDebug");
glowIgnoreMask = serializedObject.FindProperty("glowIgnoreMask");
innerGlow = serializedObject.FindProperty("innerGlow");
innerGlowColor = serializedObject.FindProperty("innerGlowColor");
innerGlowWidth = serializedObject.FindProperty("innerGlowWidth");
innerGlowVisibility = serializedObject.FindProperty("innerGlowVisibility");
seeThrough = serializedObject.FindProperty("seeThrough");
seeThroughOccluderMask = serializedObject.FindProperty("seeThroughOccluderMask");
seeThroughOccluderMaskAccurate = serializedObject.FindProperty("seeThroughOccluderMaskAccurate");
seeThroughOccluderThreshold = serializedObject.FindProperty("seeThroughOccluderThreshold");
seeThroughOccluderCheckInterval = serializedObject.FindProperty("seeThroughOccluderCheckInterval");
seeThroughOccluderCheckIndividualObjects = serializedObject.FindProperty("seeThroughOccluderCheckIndividualObjects");
seeThroughDepthOffset = serializedObject.FindProperty("seeThroughDepthOffset");
seeThroughMaxDepth = serializedObject.FindProperty("seeThroughMaxDepth");
seeThroughIntensity = serializedObject.FindProperty("seeThroughIntensity");
seeThroughTintAlpha = serializedObject.FindProperty("seeThroughTintAlpha");
seeThroughTintColor = serializedObject.FindProperty("seeThroughTintColor");
seeThroughNoise = serializedObject.FindProperty("seeThroughNoise");
seeThroughBorder = serializedObject.FindProperty("seeThroughBorder");
seeThroughBorderWidth = serializedObject.FindProperty("seeThroughBorderWidth");
seeThroughBorderColor = serializedObject.FindProperty("seeThroughBorderColor");
seeThroughOrdered = serializedObject.FindProperty("seeThroughOrdered");
seeThroughBorderOnly = serializedObject.FindProperty("seeThroughBorderOnly");
seeThroughTexture = serializedObject.FindProperty("seeThroughTexture");
seeThroughTextureScale = serializedObject.FindProperty("seeThroughTextureScale");
seeThroughTextureUVSpace = serializedObject.FindProperty("seeThroughTextureUVSpace");
targetFX = serializedObject.FindProperty("targetFX");
targetFXTexture = serializedObject.FindProperty("targetFXTexture");
targetFXRotationSpeed = serializedObject.FindProperty("targetFXRotationSpeed");
targetFXInitialScale = serializedObject.FindProperty("targetFXInitialScale");
targetFXEndScale = serializedObject.FindProperty("targetFXEndScale");
targetFXScaleToRenderBounds = serializedObject.FindProperty("targetFXScaleToRenderBounds");
targetFXAlignToGround = serializedObject.FindProperty("targetFXAlignToGround");
targetFXFadePower = serializedObject.FindProperty("targetFXFadePower");
targetFXGroundMaxDistance = serializedObject.FindProperty("targetFXGroundMaxDistance");
targetFXGroundLayerMask = serializedObject.FindProperty("targetFXGroundLayerMask");
targetFXColor = serializedObject.FindProperty("targetFXColor");
targetFXCenter = serializedObject.FindProperty("targetFXCenter");
targetFXTransitionDuration = serializedObject.FindProperty("targetFXTransitionDuration");
targetFXStayDuration = serializedObject.FindProperty("targetFXStayDuration");
targetFXVisibility = serializedObject.FindProperty("targetFXVisibility");
hitFxInitialIntensity = serializedObject.FindProperty("hitFxInitialIntensity");
hitFxMode = serializedObject.FindProperty("hitFxMode");
hitFxFadeOutDuration = serializedObject.FindProperty("hitFxFadeOutDuration");
hitFxColor = serializedObject.FindProperty("hitFxColor");
hitFxRadius = serializedObject.FindProperty("hitFxRadius");
cameraDistanceFade = serializedObject.FindProperty("cameraDistanceFade");
cameraDistanceFadeNear = serializedObject.FindProperty("cameraDistanceFadeNear");
cameraDistanceFadeFar = serializedObject.FindProperty("cameraDistanceFadeFar");
thisEffect = (HighlightEffect)target;
thisEffect.Refresh();
}
private void OnDisable() {
EditorPrefs.SetBool(HP_GENERAL_SETTINGS, expandGeneralSettings);
EditorPrefs.SetBool(HP_HIGHLIGHT_OPTIONS, expandHighlightOptions);
}
public override void OnInspectorGUI() {
bool isManager = IsDefaultEffectUsedByManager();
EditorGUILayout.Separator();
serializedObject.Update();
if (foldoutBold == null) {
foldoutBold = new GUIStyle(EditorStyles.foldout);
foldoutBold.fontStyle = FontStyle.Bold;
}
EditorGUILayout.BeginHorizontal();
HighlightProfile prevProfile = (HighlightProfile)profile.objectReferenceValue;
EditorGUILayout.PropertyField(profile, new GUIContent("Profile", "Create or load stored presets."));
if (profile.objectReferenceValue != null) {
if (prevProfile != profile.objectReferenceValue) {
profileChanged = true;
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
GUILayout.Label("", GUILayout.Width(EditorGUIUtility.labelWidth));
if (GUILayout.Button(new GUIContent("Create", "Creates a new profile which is a copy of the current settings."), GUILayout.Width(60))) {
CreateProfile();
profileChanged = false;
enableProfileApply = false;
GUIUtility.ExitGUI();
return;
}
if (GUILayout.Button(new GUIContent("Load", "Updates settings with the profile configuration."), GUILayout.Width(60))) {
profileChanged = true;
}
if (!enableProfileApply)
GUI.enabled = false;
if (GUILayout.Button(new GUIContent("Save", "Updates profile configuration with changes in this inspector."), GUILayout.Width(60))) {
enableProfileApply = false;
profileChanged = false;
thisEffect.profile.Save(thisEffect);
EditorUtility.SetDirty(thisEffect.profile);
GUIUtility.ExitGUI();
return;
}
GUI.enabled = true;
if (GUILayout.Button(new GUIContent("Locate", "Finds the profile in the project"), GUILayout.Width(60))) {
if (thisEffect.profile != null) {
Selection.activeObject = thisEffect.profile;
EditorGUIUtility.PingObject(thisEffect.profile);
}
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.PropertyField(profileSync, new GUIContent("Sync With Profile", "If disabled, profile settings will only be loaded when clicking 'Load' which allows you to customize settings after loading a profile and keep those changes."));
EditorGUILayout.BeginHorizontal();
} else {
if (GUILayout.Button(new GUIContent("Create", "Creates a new profile which is a copy of the current settings."), GUILayout.Width(60))) {
CreateProfile();
GUIUtility.ExitGUI();
return;
}
}
EditorGUILayout.EndHorizontal();
if (isManager) {
EditorGUILayout.HelpBox("These are default settings for highlighted objects. If the highlighted object already has a Highlight Effect component, those properties will be used.", MessageType.Info);
}
expandGeneralSettings = EditorGUILayout.Foldout(expandGeneralSettings, "General Settings", true, foldoutBold);
if (expandGeneralSettings) {
if (!isManager) {
EditorGUILayout.PropertyField(previewInEditor);
}
EditorGUILayout.PropertyField(camerasLayerMask);
EditorGUILayout.PropertyField(ignoreObjectVisibility);
if (thisEffect.staticChildren) {
EditorGUILayout.HelpBox("This GameObject or one of its children is marked as static. If highlight is not visible, add a MeshCollider to them (the MeshCollider can be disabled).", MessageType.Warning);
}
EditorGUILayout.PropertyField(reflectionProbes);
EditorGUILayout.PropertyField(normalsOption);
EditorGUILayout.PropertyField(subMeshMask);
EditorGUILayout.PropertyField(GPUInstancing);
EditorGUILayout.Separator();
}
if (!isManager) {
EditorGUILayout.LabelField("State", EditorStyles.boldLabel);
if (isManager) {
EditorGUILayout.LabelField(new GUIContent("Highlighted", "Highlight state (controlled by Highlight Manager)."), new GUIContent(thisEffect.highlighted.ToString()));
} else {
EditorGUILayout.PropertyField(highlighted);
}
EditorGUILayout.LabelField(new GUIContent("Selected", "Selection state (used by Highlight Trigger or Manager) when using multi-selection option."), new GUIContent(thisEffect.isSelected.ToString()));
EditorGUILayout.Separator();
}
EditorGUILayout.BeginHorizontal();
expandHighlightOptions = EditorGUILayout.Foldout(expandHighlightOptions, "Highlight Options", true, foldoutBold);
if (GUILayout.Button("Help", GUILayout.Width(50))) {
EditorUtility.DisplayDialog("Quick Help", "Move the mouse over a setting for a short description.\n\nVisit kronnect.com's forum for support, questions and more cool assets.\n\nIf you like Highlight Plus please rate it or leave a review on the Asset Store! Thanks.", "Ok");
}
EditorGUILayout.EndHorizontal();
if (expandHighlightOptions) {
EditorGUI.BeginChangeCheck();
if (!isManager) {
EditorGUILayout.PropertyField(ignore, new GUIContent("Ignore", "This object won't be highlighted."));
}
if (!ignore.boolValue) {
EditorGUILayout.PropertyField(effectGroup, new GUIContent("Include", "Additional objects to highlight. Pro tip: when highlighting multiple objects at the same time include them in the same layer or under the same parent."));
if (effectGroup.intValue == (int)TargetOptions.LayerInScene || effectGroup.intValue == (int)TargetOptions.LayerInChildren) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(effectGroupLayer, new GUIContent("Layer"));
EditorGUI.indentLevel--;
}
bool usesHQEffects = (outlineQuality.intValue == (int)QualityLevel.Highest && outline.floatValue > 0) || (glowQuality.intValue == (int)QualityLevel.Highest && glow.floatValue > 0);
if (effectGroup.intValue != (int)TargetOptions.OnlyThisObject) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(effectNameFilter, new GUIContent("Object Name Filter"));
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(combineMeshes);
if (combineMeshes.boolValue) {
if (GUILayout.Button("Refresh", GUILayout.Width(70))) {
thisEffect.Refresh(true);
}
}
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel--;
}
EditorGUILayout.PropertyField(alphaCutOff, new GUIContent("Alpha Cut Off", "Only for semi-transparent objects. Leave this to zero for normal opaque objects."));
EditorGUILayout.PropertyField(cullBackFaces);
EditorGUILayout.PropertyField(fadeInDuration);
EditorGUILayout.PropertyField(fadeOutDuration);
EditorGUILayout.PropertyField(cameraDistanceFade);
if (cameraDistanceFade.boolValue) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(cameraDistanceFadeNear, new GUIContent("Near Distance"));
EditorGUILayout.PropertyField(cameraDistanceFadeFar, new GUIContent("Far Distance"));
EditorGUI.indentLevel--;
}
if (usesHQEffects) {
EditorGUILayout.PropertyField(depthClip);
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS || EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android) {
EditorGUILayout.HelpBox("On mobile, consider enabling 'Depth Clip' option for better results.", MessageType.Info);
}
if (VRCheck.IsActive()) {
EditorGUILayout.PropertyField(flipY, new GUIContent("Flip Y Fix", "Flips outline/glow effect to fix bug introduced in Unity 2019.1.0 when VR is enabled."));
}
}
if (glowQuality.intValue != (int)QualityLevel.Highest || outlineQuality.intValue != (int)QualityLevel.Highest) {
EditorGUILayout.PropertyField(constantWidth, new GUIContent("Constant Width", "Compensates outline/glow width with depth increase."));
}
EditorGUILayout.PropertyField(outlineIndependent, new GUIContent("Independent", "Do not combine outline or glow with other highlighted objects."));
}
}
if (!ignore.boolValue) {
EditorGUILayout.Separator();
EditorGUILayout.LabelField("Effects", EditorStyles.boldLabel);
EditorGUILayout.BeginVertical(GUI.skin.box);
DrawSectionField(outline, "Outline", outline.floatValue > 0);
if (outline.floatValue > 0) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(outlineWidth, new GUIContent("Width"));
EditorGUILayout.BeginHorizontal();
QualityPropertyField(outlineQuality);
if (outlineQuality.intValue == (int)QualityLevel.Highest) {
GUILayout.Label("(Screen-Space Effect)");
} else {
GUILayout.Label("(Mesh-based Effect)");
}
EditorGUILayout.EndHorizontal();
CheckVRSupport(outlineQuality.intValue);
if (outlineQuality.intValue == (int)QualityLevel.Highest) {
EditorGUILayout.PropertyField(outlineColor, new GUIContent("Color"));
} else {
EditorGUILayout.PropertyField(outlineColorStyle, new GUIContent("Color Style"));
switch ((ColorStyle)outlineColorStyle.intValue) {
case ColorStyle.SingleColor:
EditorGUILayout.PropertyField(outlineColor, new GUIContent("Color"));
break;
case ColorStyle.Gradient:
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(outlineGradient, new GUIContent("Gradient"));
EditorGUILayout.PropertyField(outlineGradientInLocalSpace, new GUIContent("In Local Space"));
EditorGUI.indentLevel--;
break;
}
}
if (outlineQuality.intValue == (int)QualityLevel.Highest) {
EditorGUILayout.PropertyField(outlineDownsampling, new GUIContent("Downsampling"));
EditorGUILayout.PropertyField(outlineOptimalBlit, new GUIContent("Optimal Blit", "Blits result over a section of the screen instead of rendering to the full screen buffer."));
if (outlineOptimalBlit.boolValue) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(outlineBlitDebug, new GUIContent("Debug View", "Shows the blitting rectangle on the screen."));
if (outlineBlitDebug.boolValue && (!previewInEditor.boolValue || !highlighted.boolValue)) {
EditorGUILayout.HelpBox("Enable \"Preview In Editor\" and \"Highlighted\" to display the outline Debug View.", MessageType.Warning);
}
EditorGUI.indentLevel--;
}
}
GUI.enabled = outlineQuality.intValue != (int)QualityLevel.Highest || CheckForwardMSAA();
if (outlineQuality.intValue == (int)QualityLevel.Highest && glowQuality.intValue == (int)QualityLevel.Highest && glow.floatValue > 0) {
EditorGUILayout.PropertyField(glowVisibility, new GUIContent("Visibility"));
} else {
EditorGUILayout.PropertyField(outlineVisibility, new GUIContent("Visibility"));
}
GUI.enabled = true;
EditorGUI.indentLevel--;
}
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical(GUI.skin.box);
DrawSectionField(glow, "Outer Glow", glow.floatValue > 0);
if (glow.floatValue > 0) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(glowWidth, new GUIContent("Width"));
EditorGUILayout.BeginHorizontal();
QualityPropertyField(glowQuality);
if (glowQuality.intValue == (int)QualityLevel.Highest) {
GUILayout.Label("(Screen-Space Effect)");
} else {
GUILayout.Label("(Mesh-based Effect)");
}
EditorGUILayout.EndHorizontal();
CheckVRSupport(glowQuality.intValue);
if (glowQuality.intValue == (int)QualityLevel.Highest) {
EditorGUILayout.PropertyField(glowDownsampling, new GUIContent("Downsampling"));
EditorGUILayout.PropertyField(glowHQColor, new GUIContent("Color"));
EditorGUILayout.PropertyField(glowOptimalBlit, new GUIContent("Optimal Blit", "Blits result over a section of the screen instead of rendering to the full screen buffer."));
if (glowOptimalBlit.boolValue) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(glowBlitDebug, new GUIContent("Debug View", "Shows the blitting rectangle on the screen."));
if (glowBlitDebug.boolValue && (!previewInEditor.boolValue || !highlighted.boolValue)) {
EditorGUILayout.HelpBox("Enable \"Preview In Editor\" and \"Highlighted\" to display the glow Debug View.", MessageType.Warning);
}
EditorGUI.indentLevel--;
}
GUI.enabled = glowQuality.intValue != (int)QualityLevel.Highest || CheckForwardMSAA();
EditorGUILayout.PropertyField(glowVisibility, new GUIContent("Visibility"));
EditorGUILayout.PropertyField(glowBlendMode, new GUIContent("Blend Mode"));
GUI.enabled = true;
} else {
GUI.enabled = glowQuality.intValue != (int)QualityLevel.Highest || CheckForwardMSAA();
EditorGUILayout.PropertyField(glowVisibility, new GUIContent("Visibility"));
GUI.enabled = true;
EditorGUILayout.PropertyField(glowDithering, new GUIContent("Dithering"));
if (glowDithering.boolValue) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(glowMagicNumber1, new GUIContent("Magic Number 1"));
EditorGUILayout.PropertyField(glowMagicNumber2, new GUIContent("Magic Number 2"));
EditorGUI.indentLevel--;
}
EditorGUILayout.PropertyField(glowBlendPasses, new GUIContent("Blend Passes"));
if (!glowBlendPasses.boolValue) {
HighlightEffect ef = (HighlightEffect)target;
if (ef.glowPasses != null) {
for (int k = 0; k < ef.glowPasses.Length - 1; k++) {
if (ef.glowPasses[k].offset > ef.glowPasses[k + 1].offset) {
EditorGUILayout.HelpBox("Glow pass " + k + " has a greater offset than the next one. Reduce it to ensure the next glow pass is visible.", MessageType.Warning);
}
}
}
}
EditorGUILayout.PropertyField(glowPasses, true);
}
EditorGUILayout.PropertyField(glowAnimationSpeed, new GUIContent("Animation Speed"));
EditorGUILayout.PropertyField(glowIgnoreMask, new GUIContent("Ignore Mask"));
EditorGUI.indentLevel--;
}
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical(GUI.skin.box);
DrawSectionField(innerGlow, "Inner Glow", innerGlow.floatValue > 0);
if (innerGlow.floatValue > 0) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(innerGlowColor, new GUIContent("Color"));
EditorGUILayout.PropertyField(innerGlowWidth, new GUIContent("Width"));
EditorGUILayout.PropertyField(innerGlowVisibility, new GUIContent("Visibility"));
EditorGUI.indentLevel--;
}
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical(GUI.skin.box);
DrawSectionField(overlay, "Overlay", overlay.floatValue > 0);
if (overlay.floatValue > 0) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(overlayMode, new GUIContent("Mode"));
EditorGUILayout.PropertyField(overlayColor, new GUIContent("Color"));
EditorGUILayout.PropertyField(overlayTexture, new GUIContent("Texture"));
if (overlayTexture.objectReferenceValue != null) {
EditorGUILayout.PropertyField(overlayTextureUVSpace, new GUIContent("UV Space"));
EditorGUILayout.PropertyField(overlayTextureScale, new GUIContent("Texture Scale"));
}
EditorGUILayout.PropertyField(overlayBlending, new GUIContent("Blending"));
EditorGUILayout.PropertyField(overlayMinIntensity, new GUIContent("Min Intensity"));
EditorGUILayout.PropertyField(overlayAnimationSpeed, new GUIContent("Animation Speed"));
EditorGUI.indentLevel--;
}
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical(GUI.skin.box);
DrawSectionField(targetFX, "Target", targetFX.boolValue);
if (targetFX.boolValue) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(targetFXTexture, new GUIContent("Texture", "The texture that contains the shape to be drawn over the highlighted object."));
EditorGUILayout.PropertyField(targetFXColor, new GUIContent("Color"));
EditorGUILayout.PropertyField(targetFXCenter, new GUIContent("Center", "Optionally assign a transform. Target will follow transform. If the object is skinned, you can also assign a bone to reflect currenct animation position."));
EditorGUILayout.PropertyField(targetFXRotationSpeed, new GUIContent("Rotation Speed"));
EditorGUILayout.PropertyField(targetFXInitialScale, new GUIContent("Initial Scale"));
EditorGUILayout.PropertyField(targetFXEndScale, new GUIContent("End Scale"));
EditorGUILayout.PropertyField(targetFXScaleToRenderBounds, new GUIContent("Scale To Object Bounds"));
EditorGUILayout.PropertyField(targetFXAlignToGround, new GUIContent("Align To Ground"));
if (targetFXAlignToGround.boolValue) {
EditorGUI.indentLevel++;
if (thisEffect.includedObjectsCount > 1 && targetFXCenter.objectReferenceValue == null && effectGroup.intValue != (int)TargetOptions.OnlyThisObject) {
EditorGUILayout.HelpBox("It's recommended to specify in the 'Center' property above, the specific object used to position the target fx image (will be rendered under that object on the ground).", MessageType.Info);
}
EditorGUILayout.PropertyField(targetFXGroundMaxDistance, new GUIContent("Ground Max Distance"));
EditorGUILayout.PropertyField(targetFXGroundLayerMask, new GUIContent("Ground Layer Mask"));
HighlightEffect he = (HighlightEffect)target;
if ((targetFXGroundLayerMask.intValue & (1 << he.gameObject.layer)) != 0) {
EditorGUILayout.HelpBox("Ground Layer Mask should not include this object layer.", MessageType.Warning);
}
EditorGUILayout.PropertyField(targetFXFadePower, new GUIContent("Fade Power"));
EditorGUI.indentLevel--;
}
EditorGUILayout.PropertyField(targetFXTransitionDuration, new GUIContent("Transition Duration"));
EditorGUILayout.PropertyField(targetFXStayDuration, new GUIContent("Stay Duration"));
EditorGUILayout.PropertyField(targetFXVisibility, new GUIContent("Visibility"));
EditorGUI.indentLevel--;
}
EditorGUILayout.EndVertical();
}
EditorGUILayout.BeginVertical(GUI.skin.box);
EditorGUILayout.PropertyField(seeThrough);
if (seeThrough.intValue != (int)SeeThroughMode.Never) {
if (isManager && seeThrough.intValue == (int)SeeThroughMode.AlwaysWhenOccluded) {
EditorGUILayout.HelpBox("This option is not valid in Manager.\nTo make an object always visible add a Highlight Effect component to the gameobject and enable this option on the component.", MessageType.Error);
}
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(seeThroughOccluderMask, new GUIContent("Occluder Layer"));
if (seeThroughOccluderMask.intValue > 0) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(seeThroughOccluderMaskAccurate, new GUIContent("Accurate"));
EditorGUILayout.PropertyField(seeThroughOccluderThreshold, new GUIContent("Radius Threshold", "Multiplier to the object bounds. Making the bounds smaller prevents false occlusion tests."));
EditorGUILayout.PropertyField(seeThroughOccluderCheckInterval, new GUIContent("Check Interval", "Interval in seconds between occlusion tests."));
EditorGUILayout.PropertyField(seeThroughOccluderCheckIndividualObjects, new GUIContent("Check Individual Objects"));
if (!showCurrentOccluders && Camera.main != null) {
GUI.enabled = Application.isPlaying;
EditorGUILayout.BeginHorizontal();
GUILayout.Label("", GUILayout.Width(30));
if (GUILayout.Button(" Show Current Occluders (only during Play Mode) ")) {
showCurrentOccluders = true;
}
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
GUI.enabled = true;
}
if (showCurrentOccluders) {
HighlightEffect h = (HighlightEffect)target;
List<Renderer> occluders = h.GetOccluders(Camera.main);
int count = occluders != null ? occluders.Count : 0;
if (count == 0) {
EditorGUILayout.LabelField("No occluders found (using main camera)");
} else {
EditorGUILayout.LabelField("Occluders found (using main camera):");
for (int k = 0; k < count; k++) {
if (occluders[k] == null) continue;
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(occluders[k].name);
if (GUILayout.Button("Select")) {
Selection.activeGameObject = occluders[k].gameObject;
GUIUtility.ExitGUI();
}
EditorGUILayout.EndHorizontal();
}
}
}
EditorGUI.indentLevel--;
}
EditorGUILayout.PropertyField(seeThroughDepthOffset, new GUIContent("Depth Offset" + ((seeThroughDepthOffset.floatValue > 0) ? " •" : "")));
EditorGUILayout.PropertyField(seeThroughMaxDepth, new GUIContent("Max Depth" + ((seeThroughMaxDepth.floatValue > 0) ? " •" : "")));
EditorGUILayout.PropertyField(seeThroughIntensity, new GUIContent("Intensity"));
EditorGUILayout.PropertyField(seeThroughTintColor, new GUIContent("Color"));
EditorGUILayout.PropertyField(seeThroughTintAlpha, new GUIContent("Color Blend"));
EditorGUILayout.PropertyField(seeThroughNoise, new GUIContent("Noise"));
EditorGUILayout.PropertyField(seeThroughTexture, new GUIContent("Texture"));
if (seeThroughTexture.objectReferenceValue != null) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(seeThroughTextureUVSpace, new GUIContent("UV Space"));
EditorGUILayout.PropertyField(seeThroughTextureScale, new GUIContent("Texture Scale"));
EditorGUI.indentLevel--;
}
EditorGUILayout.PropertyField(seeThroughBorder, new GUIContent("Border When Hidden" + ((seeThroughBorder.floatValue > 0) ? " •" : "")));
if (seeThroughBorder.floatValue > 0) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(seeThroughBorderWidth, new GUIContent("Width"));
EditorGUILayout.PropertyField(seeThroughBorderColor, new GUIContent("Color"));
EditorGUILayout.PropertyField(seeThroughBorderOnly, new GUIContent("Border Only"));
EditorGUI.indentLevel--;
}
EditorGUILayout.PropertyField(seeThroughOrdered, new GUIContent("Ordered"));
EditorGUI.indentLevel--;
}
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical(GUI.skin.box);
DrawSectionField(hitFxInitialIntensity, "Hit FX", hitFxInitialIntensity.floatValue > 0);
if (hitFxInitialIntensity.floatValue > 0) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(hitFxMode, new GUIContent("Mode"));
EditorGUILayout.PropertyField(hitFxFadeOutDuration, new GUIContent("Fade Out Duration"));
EditorGUILayout.PropertyField(hitFxColor, new GUIContent("Color"));
if ((HitFxMode)hitFxMode.intValue == HitFxMode.LocalHit) {
EditorGUILayout.PropertyField(hitFxRadius, new GUIContent("Radius"));
}
EditorGUI.indentLevel--;
}
if (!Application.isPlaying) {
EditorGUILayout.HelpBox("Enter Play Mode to test this feature. In your code, call effect.HitFX() method to execute this hit effect.", MessageType.Info);
} else {
EditorGUI.indentLevel++;
if (GUILayout.Button("Execute Hit")) {
thisEffect.HitFX();
}
EditorGUI.indentLevel--;
}
EditorGUILayout.EndVertical();
if (serializedObject.ApplyModifiedProperties() || profileChanged || Event.current.commandName == "UndoRedoPerformed") {
if (thisEffect.profile != null) {
if (profileChanged) {
thisEffect.profile.Load(thisEffect);
profileChanged = false;
enableProfileApply = false;
} else {
enableProfileApply = true;
}
}
foreach (HighlightEffect effect in targets) {
effect.Refresh();
}
}
}
void DrawSectionField(SerializedProperty property, string label, bool active) {
EditorGUILayout.PropertyField(property, new GUIContent(active ? label + " •" : label));
}
void CheckVRSupport(int qualityLevel) {
if (qualityLevel == (int)QualityLevel.Highest && VRCheck.IsActive()) {
if (PlayerSettings.stereoRenderingPath != StereoRenderingPath.MultiPass) {
EditorGUILayout.HelpBox("Highest Quality only supports VR Multi-Pass as CommandBuffers do not support this VR mode yet. Either switch to 'High Quality' or change VR Stereo mode to Multi-Pass.", MessageType.Error);
}
}
}
bool CheckForwardMSAA() {
if (QualitySettings.antiAliasing > 1) {
if (Camera.main != null && Camera.main.allowMSAA && !depthClip.boolValue) {
EditorGUILayout.HelpBox("Effect will be shown always on top due to MSAA. To enable depth clipping enable 'Depth Clip' option above OR disable MSAA in Quality Settings OR choose a different quality level.", MessageType.Info);
return false;
}
}
return true;
}
static readonly int[] qualityValues = { 0, 3, 1, 2 };
static readonly GUIContent[] qualityTexts = { new GUIContent("Fastest"), new GUIContent("Medium"), new GUIContent("High"), new GUIContent("Highest") };
public static void QualityPropertyField(SerializedProperty prop) {
prop.intValue = EditorGUILayout.IntPopup(new GUIContent("Quality", "Default and High use a mesh displacement technique. Highest quality can provide best look and also performance depending on the complexity of mesh."), prop.intValue, qualityTexts, qualityValues);
}
bool IsDefaultEffectUsedByManager() {
MonoBehaviour[] components = thisEffect.GetComponents<MonoBehaviour>();
if (components != null) {
for (int k = 0; k < components.Length; k++) {
if (components[k] == null || !components[k].enabled)
continue;
string name = components[k].GetType().Name;
if ("HighlightManager".Equals(name)) return true;
}
}
return false;
}
#region Profile handling
void CreateProfile() {
HighlightProfile newProfile = CreateInstance<HighlightProfile>();
newProfile.Save(thisEffect);
AssetDatabase.CreateAsset(newProfile, "Assets/Highlight Plus Profile.asset");
AssetDatabase.SaveAssets();
EditorUtility.FocusProjectWindow();
Selection.activeObject = newProfile;
thisEffect.profile = newProfile;
}
#endregion
#pragma warning restore 0618
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: be287539f47634552a716f0705710448
timeCreated: 1542886545
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,71 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace HighlightPlus {
[CustomEditor(typeof(HighlightManager))]
public class HighlightManagerEditor : Editor {
SerializedProperty highlightOnHover, layerMask, raycastCamera, raycastSource, minDistance, maxDistance, respectUI;
SerializedProperty selectOnClick, selectedProfile, selectedAndHighlightedProfile, singleSelection, toggleOnClick, keepSelection;
void OnEnable() {
highlightOnHover = serializedObject.FindProperty("highlightOnHover");
layerMask = serializedObject.FindProperty("layerMask");
raycastCamera = serializedObject.FindProperty("raycastCamera");
raycastSource = serializedObject.FindProperty("raycastSource");
minDistance = serializedObject.FindProperty("minDistance");
maxDistance = serializedObject.FindProperty("maxDistance");
respectUI = serializedObject.FindProperty("respectUI");
selectOnClick = serializedObject.FindProperty("selectOnClick");
selectedProfile = serializedObject.FindProperty("selectedProfile");
selectedAndHighlightedProfile = serializedObject.FindProperty("selectedAndHighlightedProfile");
singleSelection = serializedObject.FindProperty("singleSelection");
toggleOnClick = serializedObject.FindProperty("toggle");
keepSelection = serializedObject.FindProperty("keepSelection");
}
public override void OnInspectorGUI() {
EditorGUILayout.Separator();
EditorGUILayout.HelpBox("Only objects with a collider can be highlighted automatically.", MessageType.Info);
serializedObject.Update();
EditorGUILayout.PropertyField(layerMask);
EditorGUILayout.PropertyField(raycastCamera);
EditorGUILayout.PropertyField(raycastSource);
EditorGUILayout.PropertyField(minDistance);
EditorGUILayout.PropertyField(maxDistance);
EditorGUILayout.PropertyField(respectUI);
EditorGUILayout.PropertyField(highlightOnHover);
EditorGUILayout.PropertyField(selectOnClick);
if (selectOnClick.boolValue) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(selectedProfile);
EditorGUILayout.PropertyField(selectedAndHighlightedProfile);
EditorGUILayout.PropertyField(singleSelection);
EditorGUILayout.PropertyField(toggleOnClick);
EditorGUILayout.PropertyField(keepSelection);
EditorGUI.indentLevel--;
}
serializedObject.ApplyModifiedProperties();
}
[MenuItem("GameObject/Effects/Highlight Plus/Create Manager", false, 10)]
static void CreateManager(MenuCommand menuCommand) {
HighlightManager manager = FindObjectOfType<HighlightManager>();
if (manager == null) {
GameObject managerGO = new GameObject("HighlightPlusManager");
manager = managerGO.AddComponent<HighlightManager>();
// Register root object for undo.
Undo.RegisterCreatedObjectUndo(manager, "Create Highlight Plus Manager");
}
Selection.activeObject = manager;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ace58d1d278d649c98e5a2b5a066b3cd
timeCreated: 1548711355
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,355 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace HighlightPlus {
[CustomEditor(typeof(HighlightProfile))]
[CanEditMultipleObjects]
public class HighlightProfileEditor : Editor {
SerializedProperty effectGroup, effectGroupLayer, effectNameFilter, combineMeshes, alphaCutOff, cullBackFaces, depthClip, normalsOption;
SerializedProperty overlay, overlayMode, overlayColor, overlayAnimationSpeed, overlayMinIntensity, overlayTexture, overlayTextureScale, overlayTextureUVSpace, overlayBlending;
SerializedProperty fadeInDuration, fadeOutDuration, constantWidth;
SerializedProperty outline, outlineColor, outlineColorStyle, outlineGradient, outlineGradientInLocalSpace, outlineWidth, outlineQuality, outlineDownsampling, outlineOptimalBlit, outlineVisibility, outlineIndependent;
SerializedProperty glow, glowWidth, glowQuality, glowOptimalBlit, glowDownsampling, glowHQColor, glowDithering, glowMagicNumber1, glowMagicNumber2, glowAnimationSpeed, glowVisibility, glowBlendMode, glowBlendPasses, glowPasses, glowIgnoreMask;
SerializedProperty innerGlow, innerGlowWidth, innerGlowColor, innerGlowVisibility;
SerializedProperty targetFX, targetFXTexture, targetFXColor, targetFXRotationSpeed, targetFXInitialScale, targetFXEndScale, targetFXScaleToRenderBounds;
SerializedProperty targetFXAlignToGround, targetFXFadePower, targetFXGroundMaxDistance, targetFXGroundLayerMask, targetFXTransitionDuration, targetFXStayDuration, targetFXVisibility;
SerializedProperty seeThrough, seeThroughOccluderMask, seeThroughOccluderMaskAccurate, seeThroughOccluderThreshold, seeThroughOccluderCheckInterval, seeThroughOccluderCheckIndividualObjects, seeThroughDepthOffset, seeThroughMaxDepth;
SerializedProperty seeThroughIntensity, seeThroughTintAlpha, seeThroughTintColor, seeThroughNoise, seeThroughBorder, seeThroughBorderWidth, seeThroughBorderColor, seeThroughOrdered, seeThroughBorderOnly, seeThroughTexture, seeThroughTextureUVSpace, seeThroughTextureScale;
SerializedProperty hitFxInitialIntensity, hitFxMode, hitFxFadeOutDuration, hitFxColor, hitFxRadius;
SerializedProperty cameraDistanceFade, cameraDistanceFadeNear, cameraDistanceFadeFar;
void OnEnable() {
effectGroup = serializedObject.FindProperty("effectGroup");
effectGroupLayer = serializedObject.FindProperty("effectGroupLayer");
effectNameFilter = serializedObject.FindProperty("effectNameFilter");
combineMeshes = serializedObject.FindProperty("combineMeshes");
alphaCutOff = serializedObject.FindProperty("alphaCutOff");
cullBackFaces = serializedObject.FindProperty("cullBackFaces");
depthClip = serializedObject.FindProperty("depthClip");
normalsOption = serializedObject.FindProperty("normalsOption");
fadeInDuration = serializedObject.FindProperty("fadeInDuration");
fadeOutDuration = serializedObject.FindProperty("fadeOutDuration");
constantWidth = serializedObject.FindProperty("constantWidth");
overlay = serializedObject.FindProperty("overlay");
overlayMode = serializedObject.FindProperty("overlayMode");
overlayColor = serializedObject.FindProperty("overlayColor");
overlayAnimationSpeed = serializedObject.FindProperty("overlayAnimationSpeed");
overlayMinIntensity = serializedObject.FindProperty("overlayMinIntensity");
overlayBlending = serializedObject.FindProperty("overlayBlending");
overlayTexture = serializedObject.FindProperty("overlayTexture");
overlayTextureUVSpace = serializedObject.FindProperty("overlayTextureUVSpace");
overlayTextureScale = serializedObject.FindProperty("overlayTextureScale");
outline = serializedObject.FindProperty("outline");
outlineColor = serializedObject.FindProperty("outlineColor");
outlineColorStyle = serializedObject.FindProperty("outlineColorStyle");
outlineGradient = serializedObject.FindProperty("outlineGradient");
outlineGradientInLocalSpace = serializedObject.FindProperty("outlineGradientInLocalSpace");
outlineWidth = serializedObject.FindProperty("outlineWidth");
outlineQuality = serializedObject.FindProperty("outlineQuality");
outlineOptimalBlit = serializedObject.FindProperty("outlineOptimalBlit");
outlineDownsampling = serializedObject.FindProperty("outlineDownsampling");
outlineVisibility = serializedObject.FindProperty("outlineVisibility");
outlineIndependent = serializedObject.FindProperty("outlineIndependent");
glow = serializedObject.FindProperty("glow");
glowWidth = serializedObject.FindProperty("glowWidth");
glowQuality = serializedObject.FindProperty("glowQuality");
glowOptimalBlit = serializedObject.FindProperty("glowOptimalBlit");
glowDownsampling = serializedObject.FindProperty("glowDownsampling");
glowHQColor = serializedObject.FindProperty("glowHQColor");
glowAnimationSpeed = serializedObject.FindProperty("glowAnimationSpeed");
glowDithering = serializedObject.FindProperty("glowDithering");
glowMagicNumber1 = serializedObject.FindProperty("glowMagicNumber1");
glowMagicNumber2 = serializedObject.FindProperty("glowMagicNumber2");
glowAnimationSpeed = serializedObject.FindProperty("glowAnimationSpeed");
glowBlendPasses = serializedObject.FindProperty("glowBlendPasses");
glowVisibility = serializedObject.FindProperty("glowVisibility");
glowBlendMode = serializedObject.FindProperty("glowBlendMode");
glowPasses = serializedObject.FindProperty("glowPasses");
glowIgnoreMask = serializedObject.FindProperty("glowIgnoreMask");
innerGlow = serializedObject.FindProperty("innerGlow");
innerGlowColor = serializedObject.FindProperty("innerGlowColor");
innerGlowWidth = serializedObject.FindProperty("innerGlowWidth");
innerGlowVisibility = serializedObject.FindProperty("innerGlowVisibility");
targetFX = serializedObject.FindProperty("targetFX");
targetFXTexture = serializedObject.FindProperty("targetFXTexture");
targetFXRotationSpeed = serializedObject.FindProperty("targetFXRotationSpeed");
targetFXInitialScale = serializedObject.FindProperty("targetFXInitialScale");
targetFXEndScale = serializedObject.FindProperty("targetFXEndScale");
targetFXScaleToRenderBounds = serializedObject.FindProperty("targetFXScaleToRenderBounds");
targetFXAlignToGround = serializedObject.FindProperty("targetFXAlignToGround");
targetFXGroundMaxDistance = serializedObject.FindProperty("targetFXGroundMaxDistance");
targetFXGroundLayerMask = serializedObject.FindProperty("targetFXGroundLayerMask");
targetFXFadePower = serializedObject.FindProperty("targetFXFadePower");
targetFXColor = serializedObject.FindProperty("targetFXColor");
targetFXTransitionDuration = serializedObject.FindProperty("targetFXTransitionDuration");
targetFXStayDuration = serializedObject.FindProperty("targetFXStayDuration");
targetFXVisibility = serializedObject.FindProperty("targetFXVisibility");
seeThrough = serializedObject.FindProperty("seeThrough");
seeThroughOccluderMask = serializedObject.FindProperty("seeThroughOccluderMask");
seeThroughOccluderMaskAccurate = serializedObject.FindProperty("seeThroughOccluderMaskAccurate");
seeThroughOccluderThreshold = serializedObject.FindProperty("seeThroughOccluderThreshold");
seeThroughOccluderCheckInterval = serializedObject.FindProperty("seeThroughOccluderCheckInterval");
seeThroughOccluderCheckIndividualObjects = serializedObject.FindProperty("seeThroughOccluderCheckIndividualObjects");
seeThroughDepthOffset = serializedObject.FindProperty("seeThroughDepthOffset");
seeThroughMaxDepth = serializedObject.FindProperty("seeThroughMaxDepth");
seeThroughIntensity = serializedObject.FindProperty("seeThroughIntensity");
seeThroughTintAlpha = serializedObject.FindProperty("seeThroughTintAlpha");
seeThroughTintColor = serializedObject.FindProperty("seeThroughTintColor");
seeThroughNoise = serializedObject.FindProperty("seeThroughNoise");
seeThroughBorder = serializedObject.FindProperty("seeThroughBorder");
seeThroughBorderWidth = serializedObject.FindProperty("seeThroughBorderWidth");
seeThroughBorderColor = serializedObject.FindProperty("seeThroughBorderColor");
seeThroughBorderOnly = serializedObject.FindProperty("seeThroughBorderOnly");
seeThroughOrdered = serializedObject.FindProperty("seeThroughOrdered");
seeThroughTexture = serializedObject.FindProperty("seeThroughTexture");
seeThroughTextureScale = serializedObject.FindProperty("seeThroughTextureScale");
seeThroughTextureUVSpace = serializedObject.FindProperty("seeThroughTextureUVSpace");
hitFxInitialIntensity = serializedObject.FindProperty("hitFxInitialIntensity");
hitFxMode = serializedObject.FindProperty("hitFxMode");
hitFxFadeOutDuration = serializedObject.FindProperty("hitFxFadeOutDuration");
hitFxColor = serializedObject.FindProperty("hitFxColor");
hitFxRadius = serializedObject.FindProperty("hitFxRadius");
cameraDistanceFade = serializedObject.FindProperty("cameraDistanceFade");
cameraDistanceFadeNear = serializedObject.FindProperty("cameraDistanceFadeNear");
cameraDistanceFadeFar = serializedObject.FindProperty("cameraDistanceFadeFar");
}
public override void OnInspectorGUI() {
EditorGUILayout.Separator();
EditorGUILayout.LabelField("Highlight Options", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(effectGroup, new GUIContent("Include"));
if (effectGroup.intValue == (int)TargetOptions.LayerInScene || effectGroup.intValue == (int)TargetOptions.LayerInChildren) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(effectGroupLayer, new GUIContent("Layer"));
EditorGUI.indentLevel--;
}
if (effectGroup.intValue != (int)TargetOptions.OnlyThisObject && effectGroup.intValue != (int)TargetOptions.Scripting) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(effectNameFilter, new GUIContent("Object Name Filter"));
EditorGUILayout.PropertyField(combineMeshes);
EditorGUI.indentLevel--;
}
EditorGUILayout.PropertyField(alphaCutOff);
EditorGUILayout.PropertyField(cullBackFaces);
EditorGUILayout.PropertyField(normalsOption);
EditorGUILayout.PropertyField(depthClip);
EditorGUILayout.PropertyField(fadeInDuration);
EditorGUILayout.PropertyField(fadeOutDuration);
EditorGUILayout.PropertyField(cameraDistanceFade);
if (cameraDistanceFade.boolValue) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(cameraDistanceFadeNear, new GUIContent("Near Distance"));
EditorGUILayout.PropertyField(cameraDistanceFadeFar, new GUIContent("Far Distance"));
EditorGUI.indentLevel--;
}
EditorGUILayout.PropertyField(constantWidth);
EditorGUILayout.PropertyField(outlineIndependent, new GUIContent("Independent", "Do not combine outline with other highlighted objects."));
EditorGUILayout.Separator();
EditorGUILayout.LabelField("Effects", EditorStyles.boldLabel);
EditorGUILayout.BeginVertical(GUI.skin.box);
DrawSectionField(outline, "Outline", outline.floatValue > 0);
if (outline.floatValue > 0) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(outlineWidth, new GUIContent("Width"));
HighlightEffectEditor.QualityPropertyField(outlineQuality);
if (outlineQuality.intValue == (int)QualityLevel.Highest) {
EditorGUILayout.PropertyField(outlineColor, new GUIContent("Color"));
} else {
EditorGUILayout.PropertyField(outlineColorStyle, new GUIContent("Color Style"));
switch ((ColorStyle)outlineColorStyle.intValue) {
case ColorStyle.SingleColor:
EditorGUILayout.PropertyField(outlineColor, new GUIContent("Color"));
break;
case ColorStyle.Gradient:
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(outlineGradient, new GUIContent("Gradient"));
EditorGUILayout.PropertyField(outlineGradientInLocalSpace, new GUIContent("In Local Space"));
EditorGUI.indentLevel--;
break;
}
}
if (outlineQuality.intValue == (int)QualityLevel.Highest) {
EditorGUILayout.PropertyField(outlineDownsampling, new GUIContent("Downsampling"));
EditorGUILayout.PropertyField(outlineOptimalBlit, new GUIContent("Optimal Blit", "Blits result over a section of the screen instead of rendering to the full screen buffer."));
}
if (outlineQuality.intValue == (int)QualityLevel.Highest && glowQuality.intValue == (int)QualityLevel.Highest) {
EditorGUILayout.PropertyField(glowVisibility, new GUIContent("Visibility"));
} else {
EditorGUILayout.PropertyField(outlineVisibility, new GUIContent("Visibility"));
}
EditorGUI.indentLevel--;
}
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical(GUI.skin.box);
DrawSectionField(glow, "Outer Glow", glow.floatValue > 0);
if (glow.floatValue > 0) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(glowWidth, new GUIContent("Width"));
HighlightEffectEditor.QualityPropertyField(glowQuality);
if (glowQuality.intValue == (int)QualityLevel.Highest) {
EditorGUILayout.PropertyField(glowDownsampling, new GUIContent("Downsampling"));
EditorGUILayout.PropertyField(glowHQColor, new GUIContent("Color"));
EditorGUILayout.PropertyField(glowOptimalBlit, new GUIContent("Optimal Blit", "Blits result over a section of the screen instead of rendering to the full screen buffer."));
}
EditorGUILayout.PropertyField(glowAnimationSpeed, new GUIContent("Animation Speed"));
EditorGUILayout.PropertyField(glowVisibility, new GUIContent("Visibility"));
EditorGUILayout.PropertyField(glowBlendMode, new GUIContent("Blend Mode"));
if (glowQuality.intValue != (int)QualityLevel.Highest) {
EditorGUILayout.PropertyField(glowDithering, new GUIContent("Dithering"));
if (glowDithering.boolValue) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(glowMagicNumber1, new GUIContent("Magic Number 1"));
EditorGUILayout.PropertyField(glowMagicNumber2, new GUIContent("Magic Number 2"));
EditorGUI.indentLevel--;
}
EditorGUILayout.PropertyField(glowBlendPasses, new GUIContent("Blend Passes"));
EditorGUILayout.PropertyField(glowPasses, true);
EditorGUILayout.PropertyField(glowIgnoreMask, new GUIContent("Ignore Mask"));
}
EditorGUI.indentLevel--;
}
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical(GUI.skin.box);
DrawSectionField(innerGlow, "Inner Glow", innerGlow.floatValue > 0);
if (innerGlow.floatValue > 0) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(innerGlowColor, new GUIContent("Color"));
EditorGUILayout.PropertyField(innerGlowWidth, new GUIContent("Width"));
EditorGUILayout.PropertyField(innerGlowVisibility, new GUIContent("Visibility"));
EditorGUI.indentLevel--;
}
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical(GUI.skin.box);
DrawSectionField(overlay, "Overlay", overlay.floatValue > 0);
if (overlay.floatValue > 0) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(overlayMode, new GUIContent("Mode"));
EditorGUILayout.PropertyField(overlayColor, new GUIContent("Color"));
EditorGUILayout.PropertyField(overlayTexture, new GUIContent("Texture"));
if (overlayTexture.objectReferenceValue != null) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(overlayTextureUVSpace, new GUIContent("UV Space"));
EditorGUILayout.PropertyField(overlayTextureScale, new GUIContent("Texture Scale"));
EditorGUI.indentLevel--;
}
EditorGUILayout.PropertyField(overlayBlending, new GUIContent("Blending"));
EditorGUILayout.PropertyField(overlayMinIntensity, new GUIContent("Min Intensity"));
EditorGUILayout.PropertyField(overlayAnimationSpeed, new GUIContent("Animation Speed"));
EditorGUI.indentLevel--;
}
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical(GUI.skin.box);
DrawSectionField(targetFX, "Target", targetFX.boolValue);
if (targetFX.boolValue) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(targetFXTexture, new GUIContent("Texture"));
EditorGUILayout.PropertyField(targetFXColor, new GUIContent("Color"));
EditorGUILayout.PropertyField(targetFXRotationSpeed, new GUIContent("Rotation Speed"));
EditorGUILayout.PropertyField(targetFXInitialScale, new GUIContent("Initial Scale"));
EditorGUILayout.PropertyField(targetFXEndScale, new GUIContent("End Scale"));
EditorGUILayout.PropertyField(targetFXScaleToRenderBounds, new GUIContent("Scale To Object Bounds"));
EditorGUILayout.PropertyField(targetFXAlignToGround, new GUIContent("Align To Ground"));
if (targetFXAlignToGround.boolValue) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(targetFXGroundMaxDistance, new GUIContent("Ground Max Distance"));
EditorGUILayout.PropertyField(targetFXGroundLayerMask, new GUIContent("Ground Layer Mask"));
EditorGUILayout.PropertyField(targetFXFadePower, new GUIContent("Fade Power"));
EditorGUI.indentLevel--;
}
EditorGUILayout.PropertyField(targetFXTransitionDuration, new GUIContent("Transition Duration"));
EditorGUILayout.PropertyField(targetFXStayDuration, new GUIContent("Stay Duration"));
EditorGUILayout.PropertyField(targetFXVisibility, new GUIContent("Visibility"));
EditorGUI.indentLevel--;
}
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical(GUI.skin.box);
EditorGUILayout.PropertyField(seeThrough);
if (seeThrough.intValue != (int)SeeThroughMode.Never) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(seeThroughOccluderMask, new GUIContent("Occluder Layer"));
if (seeThroughOccluderMask.intValue > 0) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(seeThroughOccluderMaskAccurate, new GUIContent("Accurate"));
EditorGUILayout.PropertyField(seeThroughOccluderThreshold, new GUIContent("Radius Threshold", "Multiplier to the object bounds. Making the bounds smaller prevents false occlusion tests."));
EditorGUILayout.PropertyField(seeThroughOccluderCheckInterval, new GUIContent("Check Interval", "Interval in seconds between occlusion tests."));
EditorGUILayout.PropertyField(seeThroughOccluderCheckIndividualObjects, new GUIContent("Check Individual Objects", "Interval in seconds between occlusion tests."));
EditorGUI.indentLevel--;
}
EditorGUILayout.PropertyField(seeThroughDepthOffset, new GUIContent("Depth Offset" + ((seeThroughDepthOffset.floatValue > 0) ? " •" : "")));
EditorGUILayout.PropertyField(seeThroughMaxDepth, new GUIContent("Max Depth" + ((seeThroughMaxDepth.floatValue > 0) ? " •" : "")));
EditorGUILayout.PropertyField(seeThroughIntensity, new GUIContent("Intensity"));
EditorGUILayout.PropertyField(seeThroughTintColor, new GUIContent("Color"));
EditorGUILayout.PropertyField(seeThroughTintAlpha, new GUIContent("Color Blend"));
EditorGUILayout.PropertyField(seeThroughNoise, new GUIContent("Noise"));
EditorGUILayout.PropertyField(seeThroughTexture, new GUIContent("Texture"));
if (seeThroughTexture.objectReferenceValue != null) {
EditorGUILayout.PropertyField(seeThroughTextureUVSpace, new GUIContent("UV Space"));
EditorGUILayout.PropertyField(seeThroughTextureScale, new GUIContent("Texture Scale"));
}
EditorGUILayout.PropertyField(seeThroughBorder, new GUIContent("Border When Hidden"));
if (seeThroughBorder.floatValue > 0) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(seeThroughBorderWidth, new GUIContent("Width"));
EditorGUILayout.PropertyField(seeThroughBorderColor, new GUIContent("Color"));
EditorGUILayout.PropertyField(seeThroughBorderOnly, new GUIContent("Border Only"));
EditorGUI.indentLevel--;
}
EditorGUILayout.PropertyField(seeThroughOrdered, new GUIContent("Ordered"));
EditorGUI.indentLevel--;
}
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical(GUI.skin.box);
DrawSectionField(hitFxInitialIntensity, "Hit FX", hitFxInitialIntensity.floatValue > 0);
if (hitFxInitialIntensity.floatValue > 0) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(hitFxInitialIntensity, new GUIContent("Initial Intensity"));
EditorGUILayout.PropertyField(hitFxMode, new GUIContent("Mode"));
EditorGUILayout.PropertyField(hitFxFadeOutDuration, new GUIContent("Fade Out Duration"));
EditorGUILayout.PropertyField(hitFxColor, new GUIContent("Color"));
if ((HitFxMode)hitFxMode.intValue == HitFxMode.LocalHit) {
EditorGUILayout.PropertyField(hitFxRadius, new GUIContent("Radius"));
}
EditorGUI.indentLevel--;
}
EditorGUILayout.EndVertical();
if (serializedObject.ApplyModifiedProperties() || (Event.current.type == EventType.ValidateCommand &&
Event.current.commandName == "UndoRedoPerformed")) {
// Triggers profile reload on all Highlight Effect scripts
HighlightEffect[] effects = FindObjectsOfType<HighlightEffect>();
for (int t = 0; t < targets.Length; t++) {
HighlightProfile profile = (HighlightProfile)targets[t];
for (int k = 0; k < effects.Length; k++) {
if (effects[k] != null && effects[k].profile == profile && effects[k].profileSync) {
profile.Load(effects[k]);
effects[k].Refresh();
}
}
}
EditorUtility.SetDirty(target);
}
}
void DrawSectionField(SerializedProperty property, string label, bool active) {
EditorGUILayout.PropertyField(property, new GUIContent(active ? label + " •" : label));
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b3b0e551d6f4f4f3987e8e5be2e89285
timeCreated: 1542886545
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,33 @@
using UnityEditor;
using UnityEngine;
namespace HighlightPlus {
[CustomEditor(typeof(HighlightSeeThroughOccluder))]
public class HighlightSeeThroughOccluderEditor : Editor {
SerializedProperty mode, detectionMethod;
void OnEnable() {
mode = serializedObject.FindProperty("mode");
detectionMethod = serializedObject.FindProperty("detectionMethod");
}
public override void OnInspectorGUI() {
serializedObject.Update();
EditorGUILayout.PropertyField(mode);
if (mode.intValue == (int)OccluderMode.BlocksSeeThrough) {
EditorGUILayout.HelpBox("This object will occlude any see-through effect.", MessageType.Info);
EditorGUILayout.PropertyField(detectionMethod);
} else {
EditorGUILayout.HelpBox("This object will trigger see-through effect. Use only on objects that do not write to depth buffer normally, like sprites or transparent objects.", MessageType.Info);
}
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 11e725ecbe4d74569b232e1a0d57efba
timeCreated: 1548711355
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,105 @@
using UnityEditor;
using UnityEngine;
namespace HighlightPlus {
[CustomEditor(typeof(HighlightTrigger))]
public class HighlightTriggerEditor : Editor {
SerializedProperty highlightOnHover, triggerMode, raycastCamera, raycastSource, raycastLayerMask;
SerializedProperty minDistance, maxDistance, respectUI, volumeLayerMask;
SerializedProperty selectOnClick, selectedProfile, selectedAndHighlightedProfile, singleSelection, toggleOnClick, keepSelection;
HighlightTrigger trigger;
void OnEnable() {
highlightOnHover = serializedObject.FindProperty("highlightOnHover");
triggerMode = serializedObject.FindProperty("triggerMode");
raycastCamera = serializedObject.FindProperty("raycastCamera");
raycastSource = serializedObject.FindProperty("raycastSource");
raycastLayerMask = serializedObject.FindProperty("raycastLayerMask");
minDistance = serializedObject.FindProperty("minDistance");
maxDistance = serializedObject.FindProperty("maxDistance");
respectUI = serializedObject.FindProperty("respectUI");
volumeLayerMask = serializedObject.FindProperty("volumeLayerMask");
selectOnClick = serializedObject.FindProperty("selectOnClick");
selectedProfile = serializedObject.FindProperty("selectedProfile");
selectedAndHighlightedProfile = serializedObject.FindProperty("selectedAndHighlightedProfile");
singleSelection = serializedObject.FindProperty("singleSelection");
toggleOnClick = serializedObject.FindProperty("toggle");
keepSelection = serializedObject.FindProperty("keepSelection");
trigger = (HighlightTrigger)target;
trigger.Init();
}
public override void OnInspectorGUI() {
serializedObject.Update();
if (trigger.triggerMode == TriggerMode.RaycastOnThisObjectAndChildren) {
if (trigger.colliders == null || trigger.colliders.Length == 0) {
EditorGUILayout.HelpBox("No collider found on this object or any of its children. Add colliders to allow automatic highlighting.", MessageType.Warning);
}
} else {
#if ENABLE_INPUT_SYSTEM
if (trigger.triggerMode == TriggerMode.ColliderEventsOnlyOnThisObject) {
EditorGUILayout.HelpBox("This trigger mode is not compatible with the new input system.", MessageType.Error);
}
#endif
if (trigger.GetComponent<Collider>() == null) {
EditorGUILayout.HelpBox("No collider found on this object. Add a collider to allow automatic highlighting.", MessageType.Error);
}
}
EditorGUILayout.PropertyField(triggerMode);
switch (trigger.triggerMode) {
case TriggerMode.RaycastOnThisObjectAndChildren:
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(raycastCamera);
EditorGUILayout.PropertyField(raycastSource);
EditorGUILayout.PropertyField(raycastLayerMask);
EditorGUILayout.PropertyField(minDistance);
EditorGUILayout.PropertyField(maxDistance);
EditorGUI.indentLevel--;
break;
case TriggerMode.Volume:
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(volumeLayerMask);
EditorGUI.indentLevel--;
break;
}
if (trigger.triggerMode != TriggerMode.Volume) {
EditorGUILayout.PropertyField(respectUI);
}
EditorGUILayout.PropertyField(highlightOnHover);
EditorGUILayout.PropertyField(selectOnClick);
if (selectOnClick.boolValue) {
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(selectedProfile);
EditorGUILayout.PropertyField(selectedAndHighlightedProfile);
EditorGUILayout.PropertyField(singleSelection);
EditorGUILayout.PropertyField(toggleOnClick);
if (trigger.triggerMode == TriggerMode.RaycastOnThisObjectAndChildren) {
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(keepSelection);
if (EditorGUI.EndChangeCheck()) {
// Update all triggers
HighlightTrigger[] triggers = FindObjectsOfType<HighlightTrigger>();
foreach(HighlightTrigger t in triggers) {
if (t.keepSelection != keepSelection.boolValue) {
t.keepSelection = keepSelection.boolValue;
EditorUtility.SetDirty(t);
}
}
}
}
EditorGUI.indentLevel--;
}
if (serializedObject.ApplyModifiedProperties()) {
trigger.Init();
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: eaf7f56fbcfa343efb5081d4309cb76b
timeCreated: 1548711355
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,132 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEditor;
namespace HighlightPlus {
public class TransparentWithDepth {
static Material bmDepthOnly;
static Material bmDepthClipping;
[MenuItem ("GameObject/Effects/Highlight Plus/Add Depth To Transparent Object", false, 100)]
static void AddDepthOption () {
Renderer renderer = GetRenderer ();
if (renderer == null)
return;
if (!EditorUtility.DisplayDialog("Add Depth to Transparent Object", "This option will force the transparent object to write to the depth buffer by adding a new special material to the renderer (existing materials are preserved) so it can occlude and allow See-Through effect.\nOnly use on transparent objects.\n\nProceed?", "Yes", "No")) {
return;
}
Material[] materials = renderer.sharedMaterials;
for (int k = 0; k < materials.Length; k++) {
if (materials [k] == bmDepthOnly) {
EditorUtility.DisplayDialog ("Depth Support", "Already set! Nothing to do.", "Ok");
return;
}
}
if (materials == null) {
renderer.sharedMaterial = bmDepthOnly;
} else {
List<Material> newMaterials = new List<Material> (materials);
newMaterials.Insert (0, bmDepthOnly);
renderer.sharedMaterials = newMaterials.ToArray ();
}
}
[MenuItem("GameObject/Effects/Highlight Plus/Make Transparent Object Compatible with Depth Clipping", false, 101)]
static void AddDepthClippingOption() {
Renderer renderer = GetRenderer();
if (renderer == null)
return;
if (!EditorUtility.DisplayDialog("Make Transparent Object Compatible with Depth Clipping", "This option will force the transparent object to write to _CameraDepthBuffer which is used by depth clip option (existing materials are preserved) so it can occlude outline and glow effects in High Quality mode.\nOnly use on transparent objects which need to occlude other outline / glow effects in high quality mode.\n\nProceed?", "Yes", "No")) {
return;
}
Material[] materials = renderer.sharedMaterials;
for (int k = 0; k < materials.Length; k++) {
if (materials[k] == bmDepthClipping) {
EditorUtility.DisplayDialog("Depth Clipping Support", "Already set! Nothing to do.", "Ok");
return;
}
}
if (materials == null) {
renderer.sharedMaterial = bmDepthClipping;
} else {
List<Material> newMaterials = new List<Material>(materials);
newMaterials.Insert(0, bmDepthClipping);
renderer.sharedMaterials = newMaterials.ToArray();
}
}
[MenuItem("GameObject/Effects/Highlight Plus/Remove Depth Compatibility", false, 102)]
static void RemoveDepthOption() {
Renderer renderer = GetRenderer();
if (renderer == null)
return;
bool found = false;
Material[] materials = renderer.sharedMaterials;
for (int k = 0; k < materials.Length; k++) {
if (materials[k] == bmDepthOnly || materials[k] == bmDepthClipping) {
materials[k] = null;
found = true;
}
}
if (found) {
List<Material> newMaterials = new List<Material>();
for (int k = 0; k < materials.Length; k++) {
if (materials[k] != null) {
newMaterials.Add(materials[k]);
}
}
renderer.sharedMaterials = newMaterials.ToArray();
return;
}
EditorUtility.DisplayDialog("Depth Support", "This object was not previously modified! Nothing to do.", "Ok");
}
static Renderer GetRenderer() {
if (Selection.activeGameObject == null) {
EditorUtility.DisplayDialog("Depth Support", "This option can only be used on GameObjects.", "Ok");
return null;
}
Renderer renderer = Selection.activeGameObject.GetComponent<Renderer>();
if (renderer == null) {
EditorUtility.DisplayDialog("Depth Support", "This option can only be used on GameObjects with a Renderer component attached.", "Ok");
return null;
}
if (bmDepthOnly == null) {
bmDepthOnly = Resources.Load<Material>("HighlightPlus/HighlightPlusDepthWrite");
if (bmDepthOnly == null) {
EditorUtility.DisplayDialog("Depth Support", "HighlightPlusDepthWrite material not found!", "Ok");
return null;
}
}
if (bmDepthClipping == null) {
bmDepthClipping = Resources.Load<Material>("HighlightPlus/HighlightPlusDepthClipComp");
if (bmDepthClipping == null) {
EditorUtility.DisplayDialog("Depth Clipping Support", "HighlightPlusDepthClipComp material not found!", "Ok");
return null;
}
}
return renderer;
}
}
}

View File

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: be6e3be6d17ed49a3bd16d816815d6fd
timeCreated: 1515683694
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,47 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.XR;
namespace HighlightPlus {
public static class VRCheck {
#if UNITY_2019_3_OR_NEWER
static List<XRDisplaySubsystemDescriptor> displaysDescs = new List<XRDisplaySubsystemDescriptor>();
static List<XRDisplaySubsystem> displays = new List<XRDisplaySubsystem>();
public static bool IsActive() {
displaysDescs.Clear();
SubsystemManager.GetSubsystemDescriptors(displaysDescs);
// If there are registered display descriptors that is a good indication that VR is most likely "enabled"
return displaysDescs.Count > 0;
}
public static bool IsVrRunning() {
bool vrIsRunning = false;
displays.Clear();
SubsystemManager.GetInstances(displays);
foreach (var displaySubsystem in displays) {
if (displaySubsystem.running) {
vrIsRunning = true;
break;
}
}
return vrIsRunning;
}
#else
public static bool IsActive() {
return PlayerSettings.virtualRealitySupported;
}
public static bool IsVrRunning() {
return Application.isPlaying && PlayerSettings.virtualRealitySupported;
}
#endif
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e692cbce37dc14e29b436d0c876f45dc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,484 @@
**************************************
* HIGHLIGHT PLUS *
* Created by Ramiro Oliva (Kronnect) *
* README FILE *
**************************************
Quick help: how to use this asset?
----------------------------------
1) Highlighting specific objects: add HighlightEffect.cs script to any GameObject. Customize the appearance options.
In the Highlight Effect inspector, you can specify which objects, in addition to this one, are also affected by the effect:
a) Only this object
b) This object and its children
c) All objects from the root to the children
d) All objects belonging to a layer
2) Control highlight effect when mouse is over:
Add HighlightTrigger.cs script to the GameObject. It will activate highlight on the gameobject when mouse pass over it.
3) Highlighting any object in the scene:
Select top menu GameObject -> Effects -> Highlight Plus -> Create Manager.
Customize appearance and behaviour of Highlight Manager. Those settings are default settings for all objects. If you want different settings for certain objects just add another HighlightEffect script to each different object. The manager will use those settings.
4) Make transparent shaders compatible with See-Through effect:
If you want the See-Through effect be seen through other transparent objects, they need to be modified so they write to depth buffer (by default transparent objects do not write to z-buffer).
To do so, select top menu GameObject -> Effects -> Highlight Plus -> Add Depth To Transparent Object.
5) Static batching:
Objects marked as "static" need a MeshCollider in order to be highlighted. This is because Unity combines the meshes of static objects so it's not possible to highlight individual objects if their meshes are combined.
To allow highlighting static objects make sure they have a MeshCollider attached (the MeshCollider can be disabled).
Help & Support Forum
--------------------
Check the Documentation folder for detailed instructions:
Have any question or issue?
* Support-Web: https://kronnect.com/support
* Support-Discord: https://discord.gg/EH2GMaM
* Email: contact@kronnect.com
* Twitter: @Kronnect
If you like Highlight Plus, please rate it on the Asset Store. It encourages us to keep improving it! Thanks!
Universal Rendering Pipeline
----------------------------
Customers can download a specific version of Highlight Plus designed for Universal Rendering Pipeline for free from our support forum on https://kronnect.com
Please sign up on the forum and send a pm to "Kronnect" or email to contact@kronnect.com to get access to the private board.
The Unity Asset Store currently does not allow you to select which package according to the pipeline to download so we have to offer this way so you can download it.
Future updates
--------------
All our assets follow an incremental development process by which a few beta releases are published on our support forum (kronnect.com).
We encourage you to signup and engage our forum. The forum is the primary support and feature discussions medium.
Of course, all updates of Highlight Plus will be eventually available on the Asset Store.
More Cool Assets!
-----------------
Check out our other assets here:
https://assetstore.unity.com/publishers/15018
Version history
---------------
Current version
- Added new "UV Space" options to Overlay effect (now: triplanar, object space or screen space)
- Added mask texture and "UV Space" options to See-Through effect
- Camera Distance Fade now also affects the see-through effect
Version 9.5
- Outline: added Color Style property and new Gradient option
- Internal buffer for highest quality outline/glow format changed to R8 format to reduce memory and improve performance on mobile
- API: Refresh(discardCachedMeshes): added discardCachedMeshes optional parameter to force refresh of cached meshes (useful for combined meshes that have changed)
Version 9.4
- Highlight See Through Occluder: added mode for triggering the see-through offect on sprites and transparent objects
- [Fix] Fixed a problem on Quest 2 standalone when using with other render features (ie. Liquid Volume Pro 2 irregular topology)
Version 9.3
- Overlay: added "Mode" option (only when highlighted or always)
- Nested highlight effects are now included unless the 'Ignore' option is selected
- Cached meshes are now reconstructed when calling the Refresh() method
Version 9.2
- Improved shared mesh cache handling
- Improved see-through camera-layer based detection
Version 9.1.2
- [Fix] Fixed outline/glow distortion due to floating point math issues at distant positions from origin
Version 9.1.1
- Added support for Unity 2022
- Added Layer Mask option to Highlight Trigger
- Added "Keep Selection" option in Highlight Manager and Highlight Trigger
- [Fix] Fixed a potential issue that could exceed the maximum 64k vertices when combining meshes
Version 9.0
- Added "Camera Distance Fade" option
- Improved see-through accurate method which now takes into account multi-part meshes from compound parents
- [Fix] Fixed glow/outline aspect ratio in Single Pass Instanced VR mode
Version 8.5
- Improved outline effect when combining "Independent" option with many elements in "Children" selection
- Improved see-through border only effect
Version 8.4
- Added "Border Only" option to See-Through effect
- Outline/glow shape now properly cuts when partially occluded (instead of following the shape of the occluder)
- Adding a Highlight Effect component to a parent no longer deactivates highlighted children
Version 8.3
- Upgraded to Unity 2020.3.16
- [Fix] Fixed outline/glow render issue when MSAA is enabled
Version 8.2
- Added "Ignore Mask" option to glow. Can be used to render the glow effect alone
- [Fix] Fixed issue with new input system and highlight manager/trigger if no Event System is present in the scene
- [Fix] Fixed glow passes UI overlap in Unity 2021.3.3 due to reorderable array bug
Version 8.1
- Selection state is now visible in inspector (used only by trigger and manager components)
- [Fix] Fixed mobile input using the new input system
- [Fix] Fixed outline settings mismatch when using a combination of Highlight Trigger and Manager
Version 8.0
- Added SelectObject / ToggleObject / UnselectObject methods to Highlight Manager
- Added ability to control rendering order of effects (check documentation: Custom sorting section)
Version 7.9.1
- Default values for all effects are now 0 (disabled) except outline so desired effects must be enabled. This option allows you to ensure no extra/undesired effects are activated by mistake
- Redesigned Highlight Plus Profile editor interface
- Removed dependency of HighlightManager
Version 7.8
- Added outer glow blend mode option
- API: added OnObjectHighlightStart/End events to HighlightTrigger (check documentation for differences with similar events on Highlight Effect main script)
- [Fix] API: Fixed specific issues with SetTarget method when used on shader graph based materials that don't use standard texture names
Version 7.7.2
- [Fix] Fixed fade in/out issue when disabling/enabling objects
Version 7.7
- Added support for the new Input System
- [Fix] Fixes to the align to ground option of target fx effect
Version 7.6.2
- [Fix] VR: fixed target effect "Align to Ground" issue with Single Pass Instanced
Version 7.6.1
- [Fix] Fixed overlay animation speed issue
Version 7.6
- Added "Target FX Align to Ground" option
- Added isSeeThroughOccluded(camera). Is true when any see-through occluder using raycast mode is blocking the see-through effect
- All shader keywords are now of local type reducing global keyword usage
- Fixes and improvements to see-through when combined with outline/outer glow
Version 7.5.2
- [Fix] See-through is now visible when using glow/outline/inner glow with Always Visible option
Version 7.5
- Added new HitFX style: "Local Hit"
- Added new demo scene showcasing the HitFx variations
- Added "Overlay Texture" option
- Added "Min Distance" option to Highlight Manager and Highlight Trigger
- Added support for "Domain Reload" disabled option
- API: added OnObjectHighlightStart, OnObjectHighlightEnd events to HighlightManager
- [Fix] Fixed inner glow and overlay issue when MaterialPropertyBlock is used on the character material
Version 7.1
- Added "Respect UI" to Highlight Manager and Trigger which blocks interaction if pointer is over an UI element
Version 7.0.2
- Memory optimizations
Version 7.0.1
- [Fix] Highest quality outline/glow fixes on mobile
Version 7.0
- Added support for Single Pass Instanced
- Internal improvements and fixes
Version 6.9
- Internal improvements to see-through
Version 6.8
- Changed see-through effect rendering order to improve support with other stencil effects
- [Fix] Fixed properties not being reflected in scene immediately when invoking Undo
Version 6.7
- Added "SeeThrough Max Depth" option. Limits the visibility of the see-through effect to certain distance from the occluders
- Added "SeeThrough Check Individual Objects" option. If enabled, occlusion test is performed for each individual child of the object, instead of using combined bounds
Version 6.6
- Added "SeeThrough Depth Offset" option. This option allows you to control the minimum distance from the occluder to the object before showing the see-through effect
- Added "SeeThrough Non Overlap" option. Enable it only if the see-through effect produces flickering due to overlapping geometry in the hidden object
- [Fix] Fixed properties not being reflected in scene immediately when invoking Undo
Version 6.5.1
- Calling ProfileLoad() method will now assign that profile to the highlight effect component in addition to loading its values
- Prevents _Time overflow which can cause glitching on some Android devices
Version 6.5
- Name filter now is ignored when effect group is set to Only This Object
- New shader "HighlightPlus/Geometry/UIMask" to cancel highlight effects when rendering through a UI Canvas (see documentation)
Version 6.4
- Added "Cameras Layer Mask" to specify which cameras can render the effects
- Hit FX color in Highlight Profile now exposes HDR color options
Version 6.3.1
- Added "Single Selection" option to Highlight Manager/Trigger
- Added "Toggle" option to Highlight Manager/Trigger
- Selection is cleared now when clicking anywhere in the scene (requires Highlight Manager)
- API: added SetGlowColor
- Improved Highlight Manager inspector
Version 6.2
- Added TargetFX Scale To Object Bounds (defaults to false)
- Added support for HDR color to Hit FX color field
- Option to list occluders in the inspector when See Through Occluder Mask "Accurate" option is enabled
Version 6.1
- Added more accurate occluder layer system ("Accurate" option)
- Added default hit fx settings to inspector & profile
- Added hit fx modes (overlay or inner glow)
Version 6.0
- Added Selection feature
- Inspector: sections can be now collapsed to reduce screen space
- API: added OnObjectSelected / OnObjectUnSelected events
Version 5.5
- Added "Planar" mode to Normals option. Best choice for highlighting 2D meshes (quad/planes)
Version 5.4 5/Feb/2021
- Added Visibility option to targete effect
- Stencil mask is no longer computed when only overlay or inner glow is used improving performance
Version 5.3.5 22/Jan/2021
- Added "CustomVertexTransform.cginc" file which can be used to include user-defined vertex transformations
- Optimizations to material setters
Version 5.3.4
- Improvements to combine meshes option
Version 5.3.3
- Effects now reflect object transform changes when combines meshes option is enabled
Version 5.3.2
- Memory optimizations
Version 5.3.1
- Optimizations and fixes
Version 5.3
- Added "Combine Meshes" option to profile
Version 5.2
- Added "Object Name Filter" option to profile
Version 5.0
- API: added "TargetFX" method to programmatically start the target effect
- [Fix] Depth Clip option can now be used on mobile even with visibility set to Always On Top
Version 4.9
- Added "Medium" quality level
Version 4.8.1
- [Fix] Fixed outline/glow issue on iOS when using Highest Quality mode in Unity 2010.1
Version 4.8
- Added "Outer Glow Blend Passes" option
- Added support for HDR colors
Version 4.7
- Added "Normals Option" with Smooth, Preserve and Reorient variants to improve results
- Target effect now only renders once per gameobject if a specific target transform is specified
- API: added OnTargetAnimates. Allows you to override center, rotation and scale of target effect on a per-frame basis.
Version 4.6
- Added "SubMesh Mask" which allows to exclude certain submeshes
- [Fix] Fixed shader compilation issue with Single Pass Instanced mode enabled
Version 4.5
- Added "Preserve Original Mesh" option to inspector and profile
Version 4.4
- Added HitFX effect
- Improved quality of outer glow when using Highest Quality mode
- Improvements to SeeThrough Occluder when Detection Mode is set to RayCast
- API: added SetTargets(transform, renderers)
- API: added static method HighlightEffect.DrawEffectsNow() to force render all effects on demand
Version 4.2
- Added GPU Instancing support for outline / glow effects
- Highlight Trigger: added volume collision detection
Version 4.1.1
- [Fix] Fixed issue with grouped objects when independent option is enabled and Highest Quality outer glow or outline is used
Version 4.1
- Improved "Outline Independent" option for Highest Quality Mode
- Consistency: enabling "Outline Independent" in Highest Quality Mode now also affects Outer Glow is used
Version 4.0
- Start up peformance & memory allocation optimizations
- Added "Independent" support to outline in Highest Quality mode
- Added "Make Transparent Object Compatible With Depth Clip" option
Version 3.9
- Added "Depth Clip" option (only applies to HQ outline/glow effects)
Version 3.8
- Glow/Outline downsampling and glow blend mode option added to profiles
- [Fix] Fixed an issue which marked the scene as dirty
- [Fix] Removed VR API usage console warning
Version 3.7
- See Through: added "Occluder Mask" option. When set to a custom layer, it performs a BoxCast check to ensure only objects in the specific layers are occluding the target. Customize this behaviour using the Radius Threshold and Check Interval settings.
- Added "Max Distance" to Highlight Trigger
- Reduced allocations when averaging normals
- [Fix] Fixed flickering of outer glow when used in Highest quality with thin objects
Version 3.6
- Added "Outline Independent" option. Shows full outline regardless of any other highlighted object behind.
Version 3.5
- Improved quality of Outline effect when quality level is set to Highest
- Added "SeeThrough Border" feature
- Added "Blend Mode" option to Outer Glow for highest quality level
- [Fix] Fixed issue during Prefab editor mode
Version 3.4.4
- Added option in occluder script to use raycast instead of stencil buffer to cancel see-through (useful for avoiding terrain triggering see-through effect)
- [Fix] Fixed see-through in deferred rendering path
Version 3.4.2
- [Fix] Fixed an issue when adding the effect at runtime with outline/glow in higuest quality
Version 3.4.1
- [Fix] Fixed occluder objects removing glow effect when placed in the background
- [Fix] Added missing SeeThrough noise option to Highlight Profile asset
Version 3.4
- Added LayerInChildren option to "Include" filter
- Improved occluder system
- [Fix] Prevent an error when the mesh normals count does not match the vertex count
Version 3.3
- Outline, Glow and Inner Glow "Always On Top" option expanded to "Normal", "Always On Top" or "Only When Occluded"
- Added Noise slider to See-Through effect
Version 3.2.4
- [Fix] Fixed flickering issue when combining mesh & skinned mesh renderers
Version 3.2.3
- General improvements and fixes
Version 3.2.2
- [Fix] Fixed issue when trying to read normals from a non-readable mesh
Version 3.2.1
- [Fix] Fixed glow disappearing when object crosses camera near clip
Version 3.2
- Added "Reflection Probes" option
- Internal improvements and fixes
Version 3.1
- Added "Constant Width" option to Glow/Outline in Fastest/High quality level
- Added "Optimal Blit" option to Glow/Outline with Debug View
Version 3.0.2
- API: added proxy methods ProfileLoad, ProfileReload, ProfileSaveChanges to load/store profile settings at runtime. You can also load/save changes between effect and profile using the Load/Save methods on the profile object itself.
Version 3.0.1
- [Fix] Fixed an exception when glow was enabled, outline disabled in highest quality level
Version 3.0
- Added HQ Highest quality glow and outline options
- Added "Include" option to choose which objects are affected by the effects (same gameobject, children, root to children, or many objects in layer)
- Added "Alpha CutOff"
Version 2.6.1
- Minor internal improvements
Version 2.6
- Added Target effect
- Improved performance on Skinned Mesh Renderers. Slightly improved performance on normal renderers.
Version 2.5.2
- [Fix] Fixed issue with HQ Outer Glow not showing when there's multiple selected objects parented to the same object
Version 2.5.1
- Added support for orthographic camera
Version 2.5
- Added support for VR Single Pass Instanced
- Minor improvements and fixes
Version 2.4
- New HighlightSeeThroughOccluder script. Add it to any object to cancel any see-through effect
- Added "Fade In Duration" / "Fade Out Duration" to create smooth transition states
- Added "Glow HQ" to produce better outer glow on certain shapes
- Added "OnRendererHighlightStart" event
- API: added "OverlayOnShot" method for impact effects
Version 2.3
- Added "Raycast Source" to Highlight Trigger and Manager components
- Added "Skinned Mesh Bake Mode" to optimize highlight on many models
Version 2.2
- Added "Always On Top" option to Outline, Outer and Inner Glow
- Added "Trigger Mode" to Highlight Trigger to support complex objects
Version 2.1
- Added "Outline HQ" to inspector. Creates a better outline on certain shapes
- Added "Ignore Object Visibility" to enable effects on disabled renderers or hidden objects
Version 2.0
- Profiles. Store/load/share settings across different objects.
- [Fix] Fixed issue when copying component values between two objects
- [Fix] Fixed effects ignoring culling mask on additional cameras
Version 1.5
- Added "Inner Glow" effect
Version 1.4
- Added "Overlay Min Intensity" and "Overlay Blending" options
- Added "Ignore" option
- Minor improvements & fixes
Version 1.3
- Added option to add depth compatibility for transparent shaders
Version 1.2.4
- [Fix] Fix for multiple skinned models
- [Fix] Fix for scaled skinned models
Version 1.2.3
- [Fix] Fixes for Steam VR
Version 1.2.1
- Internal improvements and fixes
Version 1.2.1
- [Fix] Fixed script execution order issue with scripts changing transform in LateUpdate()
Version 1.2
- Support for LOD groups
Version 1.1
- Redesigned editor inspector
- Minor improvements
Version 1.0.4
- Supports meshes with negative scales
Version 1.0.3
- Support for multiple submeshes
Version 1.0.2
- [Fix] Fixed scale issue with grouped objects
Version 1.0.1
- Supports combined meshes
Version 1.0 - Nov/2018
- Initial release

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 53265a9967ed548efaf71f5807638781
timeCreated: 1542901568
licenseType: Pro
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3a476022645d74299b862c36d0daa1df
folderAsset: yes
timeCreated: 1542876301
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6bd97436761b94109a0785ed6823647c
folderAsset: yes
timeCreated: 1542893576
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
#ifndef CUSTOM_VERTEX_TRANSFORM_INCLUDED
#define CUSTOM_VERTEX_TRANSFORM_INCLUDED
float4 ComputeVertexPosition(float4 vertex) {
// Add here any custom vertex transform
float4 pos = UnityObjectToClipPos(vertex);
return pos;
}
#endif

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e25b1281ec6724b028e33a5df5a3f266
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,49 @@
Shader "HighlightPlus/Geometry/JustDepth"
{
Properties
{
}
SubShader
{
Tags { "RenderType"="Opaque" }
ColorMask 0
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return 0;
}
ENDCG
}
}
}

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 058a572e30b2d446bade2dda32bcef0f
timeCreated: 1515682635
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,43 @@
Shader "HighlightPlus/Geometry/DepthClipComp"
{
Properties
{
}
SubShader
{
Pass {
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#pragma multi_compile_shadowcaster
#pragma multi_compile_instancing
#include "UnityCG.cginc"
struct v2f {
V2F_SHADOW_CASTER;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert( appdata_base v ) {
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
return o;
}
float4 frag( v2f i ) : SV_Target {
SHADOW_CASTER_FRAGMENT(i)
}
ENDCG
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0917f634da79a4983ad78bac83d5a715
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,158 @@
Shader "HighlightPlus/Geometry/BlurGlow" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,0) // not used; dummy property to avoid inspector warning "material has no _Color property"
_BlurScale("Blur Scale", Float) = 2.0
_Speed("Speed", Float) = 1
}
SubShader
{
ZTest Always
ZWrite Off
Cull Off
CGINCLUDE
#include "UnityCG.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
float4 _MainTex_TexelSize;
float4 _MainTex_ST;
float _BlurScale, _Speed;
struct appdata {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2fCross {
float4 pos : SV_POSITION;
float2 uv: TEXCOORD0;
float2 uv1: TEXCOORD1;
float2 uv2: TEXCOORD2;
float2 uv3: TEXCOORD3;
float2 uv4: TEXCOORD4;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2fCross vertCross(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Texture is inverted WRT the main texture
v.texcoord.y = 1.0 - v.texcoord.y;
}
#endif
o.uv = v.texcoord;
float3 offsets = _MainTex_TexelSize.xyx * float3(1,1,-1);
o.uv1 = v.texcoord - offsets.xy;
o.uv2 = v.texcoord - offsets.zy;
o.uv3 = v.texcoord + offsets.zy;
o.uv4 = v.texcoord + offsets.xy;
return o;
}
v2fCross vertBlurH(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Texture is inverted WRT the main texture
v.texcoord.y = 1.0 - v.texcoord.y;
}
#endif
float animatedWidth = _BlurScale * (1.0 + 0.25 * sin(_Time.w * _Speed));
o.uv = v.texcoord;
float2 inc = float2(_MainTex_TexelSize.x * 1.3846153846 * animatedWidth, 0);
o.uv1 = v.texcoord - inc;
o.uv2 = v.texcoord + inc;
float2 inc2 = float2(_MainTex_TexelSize.x * 3.2307692308 * animatedWidth, 0);
o.uv3 = v.texcoord - inc2;
o.uv4 = v.texcoord + inc2;
return o;
}
v2fCross vertBlurV(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Texture is inverted WRT the main texture
v.texcoord.y = 1.0 - v.texcoord.y;
}
#endif
float animatedWidth = _BlurScale * (1.0 + 0.25 * sin(_Time.w * _Speed));
o.uv = v.texcoord;
float2 inc = float2(0, _MainTex_TexelSize.y * 1.3846153846 * animatedWidth);
o.uv1 = v.texcoord - inc;
o.uv2 = v.texcoord + inc;
float2 inc2 = float2(0, _MainTex_TexelSize.y * 3.2307692308 * animatedWidth);
o.uv3 = v.texcoord - inc2;
o.uv4 = v.texcoord + inc2;
return o;
}
float4 fragBlur (v2fCross i): SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float4 pixel = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv) * 0.2270270270
+ (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv1) + UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv2)) * 0.3162162162
+ (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv3) + UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv4)) * 0.0702702703;
return pixel;
}
float4 fragResample(v2fCross i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float4 c1 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv1);
float4 c2 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv2);
float4 c3 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv3);
float4 c4 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv4);
return (c1+c2+c3+c4) * 0.25;
}
ENDCG
Pass {
CGPROGRAM
#pragma vertex vertBlurH
#pragma fragment fragBlur
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vertBlurV
#pragma fragment fragBlur
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vertCross
#pragma fragment fragResample
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 84c84ee93ec484bdda371ffbdebfcc7c
timeCreated: 1556874239
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,156 @@
Shader "HighlightPlus/Geometry/BlurOutline" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,0) // not used; dummy property to avoid inspector warning "material has no _Color property"
_BlurScale("Blur Scale", Float) = 2.0
}
SubShader
{
Tags { "Queue"="Transparent+100" "RenderType"="Transparent" }
ZTest Always
ZWrite Off
Cull Off
CGINCLUDE
#include "UnityCG.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
float4 _MainTex_TexelSize;
float4 _MainTex_ST;
float _BlurScale;
struct appdata {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2fCross {
float4 pos : SV_POSITION;
float2 uv: TEXCOORD0;
float2 uv1: TEXCOORD1;
float2 uv2: TEXCOORD2;
float2 uv3: TEXCOORD3;
float2 uv4: TEXCOORD4;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2fCross vertCross(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Texture is inverted WRT the main texture
v.texcoord.y = 1.0 - v.texcoord.y;
}
#endif
o.uv = v.texcoord;
float3 offsets = _MainTex_TexelSize.xyx * float3(1,1,-1);
o.uv1 = v.texcoord - offsets.xy;
o.uv2 = v.texcoord - offsets.zy;
o.uv3 = v.texcoord + offsets.zy;
o.uv4 = v.texcoord + offsets.xy;
return o;
}
v2fCross vertBlurH(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Texture is inverted WRT the main texture
v.texcoord.y = 1.0 - v.texcoord.y;
}
#endif
o.uv = v.texcoord;
float2 inc = float2(_MainTex_TexelSize.x * 1.3846153846 * _BlurScale, 0);
o.uv1 = v.texcoord - inc;
o.uv2 = v.texcoord + inc;
float2 inc2 = float2(_MainTex_TexelSize.x * 3.2307692308 * _BlurScale, 0);
o.uv3 = v.texcoord - inc2;
o.uv4 = v.texcoord + inc2;
return o;
}
v2fCross vertBlurV(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Texture is inverted WRT the main texture
v.texcoord.y = 1.0 - v.texcoord.y;
}
#endif
o.uv = v.texcoord;
float2 inc = float2(0, _MainTex_TexelSize.y * 1.3846153846 * _BlurScale);
o.uv1 = v.texcoord - inc;
o.uv2 = v.texcoord + inc;
float2 inc2 = float2(0, _MainTex_TexelSize.y * 3.2307692308 * _BlurScale);
o.uv3 = v.texcoord - inc2;
o.uv4 = v.texcoord + inc2;
return o;
}
float4 fragBlur (v2fCross i): SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float4 pixel = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv) * 0.2270270270
+ (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv1) + UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv2)) * 0.3162162162
+ (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv3) + UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv4)) * 0.0702702703;
return pixel;
}
float4 fragResample(v2fCross i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float4 c1 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv1);
float4 c2 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv2);
float4 c3 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv3);
float4 c4 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv4);
return (c1+c2+c3+c4) * 0.25;
}
ENDCG
Pass {
CGPROGRAM
#pragma vertex vertBlurH
#pragma fragment fragBlur
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vertBlurV
#pragma fragment fragBlur
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vertCross
#pragma fragment fragResample
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 74f3491dcf1224f0c91238381c035439
timeCreated: 1556874239
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,97 @@
Shader "HighlightPlus/ClearStencil"
{
Properties
{
}
SubShader
{
Stencil {
Ref 8 // bit 8 is used by HighlightUIMask shader to prevent Clear Stencil passes
Comp NotEqual
Pass zero
ReadMask 8
WriteMask 6
}
ZTest Always
ZWrite Off
Cull Off
ColorMask 0
Pass // Ordered full screen
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = float4(v.vertex.xy, 0, 0.5);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return 0;
}
ENDCG
}
Pass // Ordered object-space
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return 0;
}
ENDCG
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 632d26701d1f14d9ab2950021e6fed87
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,147 @@
Shader "HighlightPlus/Geometry/ComposeGlow" {
Properties {
_MainTex ("Texture", Any) = "black" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
[HideInInspector] _Cull ("Cull Mode", Int) = 2
[HideInInspector] _ZTest ("ZTest Mode", Int) = 0
[HideInInspector] _Flip("Flip", Vector) = (0, 1, 0)
[HideInInspector] _BlendSrc("Blend Src", Int) = 1
[HideInInspector] _BlendDst("Blend Dst", Int) = 1
_Debug("Debug Color", Color) = (0,0,0,0)
[HideInInspector] _GlowStencilComp ("Stencil Comp", Int) = 6
}
SubShader
{
Tags { "Queue"="Transparent+102" "RenderType"="Transparent" }
Blend [_BlendSrc] [_BlendDst]
// Compose effect on camera target
Pass
{
ZWrite Off
ZTest [_ZTest]
Cull Off //[_Cull]
Stencil {
Ref 2
Comp [_GlowStencilComp]
Pass keep
ReadMask 2
WriteMask 2
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_HPComposeGlowFinal);
fixed4 _Color;
float3 _Flip;
fixed4 _Debug;
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float4 scrPos: TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.scrPos = ComputeScreenPos(o.pos);
o.scrPos.y = o.scrPos.w * _Flip.x + o.scrPos.y * _Flip.y;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
fixed4 glow = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_HPComposeGlowFinal, i.scrPos.xy/i.scrPos.w);
fixed4 color = _Color;
color *= glow.r;
color += _Debug;
color.a = saturate(color.a);
return color;
}
ENDCG
}
// Compose effect on camera target (full-screen blit)
Pass
{
ZWrite Off
ZTest Always //[_ZTest]
Cull Off //[_Cull]
Stencil {
Ref 2
Comp NotEqual
Pass keep
ReadMask 2
WriteMask 2
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
float4 _MainTex_ST;
fixed4 _Color;
float3 _Flip;
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert(appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.uv, _MainTex_ST);
o.uv.y = _Flip.x + o.uv.y * _Flip.y;
return o;
}
fixed4 frag(v2f i) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
fixed4 glow = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
fixed4 color = _Color;
color *= glow.r;
color.a = saturate(color.a);
return color;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 975a91ee935da4d9c8a3e807fecd8047
timeCreated: 1544699251
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,144 @@
Shader "HighlightPlus/Geometry/ComposeOutline" {
Properties {
_MainTex ("Texture", Any) = "black" {}
_Color("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_Cull("Cull Mode", Int) = 2
_ZTest("ZTest Mode", Int) = 0
_Flip("Flip", Vector) = (0, 1, 0)
_Debug("Debug Color", Color) = (0,0,0,0)
}
SubShader
{
Tags { "Queue" = "Transparent+120" "RenderType" = "Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
// Compose effect on camera target (optimal quad blit)
Pass
{
ZWrite Off
ZTest [_ZTest]
Cull Off // [_Cull]
Stencil {
Ref 2
Comp NotEqual
Pass keep
ReadMask 2
WriteMask 2
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_HPComposeOutlineFinal);
fixed4 _Color;
float3 _Flip;
fixed4 _Debug;
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float4 scrPos: TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.scrPos = ComputeScreenPos(o.pos);
o.scrPos.y = o.scrPos.w * _Flip.x + o.scrPos.y * _Flip.y;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
fixed4 outline = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_HPComposeOutlineFinal, i.scrPos.xy/i.scrPos.w);
fixed4 color = _Color;
color.a *= outline.r;
color += _Debug;
color.a = saturate(color.a);
return color;
}
ENDCG
}
// Compose effect on camera target (full-screen blit)
Pass
{
ZWrite Off
ZTest Always // [_ZTest]
Cull Off // [_Cull]
Stencil {
Ref 2
Comp NotEqual
Pass keep
ReadMask 2
WriteMask 2
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
float4 _MainTex_ST;
fixed4 _Color;
float3 _Flip;
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert(appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.uv, _MainTex_ST);
o.uv.y = _Flip.x + o.uv.y * _Flip.y;
return o;
}
fixed4 frag(v2f i) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
fixed4 outline = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
fixed4 color = _Color;
color.a *= outline.r;
color = saturate(color);
return color;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0a6de74b6cfa9440182f8f56e4a0e4f1
timeCreated: 1544699251
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,84 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: HighlightGlow
m_Shader: {fileID: 4800000, guid: 049d9e75e07674a78a703cf1203c07dd, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _ConstantWidth: 1
- _Cull: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _GlowZTest: 4
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _Glow: {r: 1, g: 0.025, b: 0.75, a: 0.5}
- _Glow2: {r: 0.01, g: 1, b: 0.5, a: 0}
- _GlowColor: {r: 1, g: 1, b: 1, a: 1}
- _GlowDirection: {r: 1, g: 1, b: 0, a: 1}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 60e964940a24547a585c3ffff7e52e9b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,114 @@
Shader "HighlightPlus/Geometry/Glow" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Glow ("Glow", Vector) = (1, 0.025, 0.75, 0.5)
_Glow2 ("Glow2", Vector) = (0.01, 1, 0.5, 0)
_GlowColor ("Glow Color", Color) = (1,1,1)
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_GlowDirection("GlowDir", Vector) = (1,1,0)
_Cull ("Cull Mode", Int) = 2
_ConstantWidth ("Constant Width", Float) = 1
_GlowZTest ("ZTest", Int) = 4
_GlowStencilOp ("Stencil Operation", Int) = 0
_GlowStencilComp ("Stencil Comp", Int) = 6
}
SubShader
{
Tags { "Queue"="Transparent+102" "RenderType"="Transparent" "DisableBatching"="True" }
// Glow passes
Pass
{
Stencil {
Ref 2
Comp [_GlowStencilComp]
Pass [_GlowStencilOp]
ReadMask 2
WriteMask 2
}
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
Cull [_Cull]
ZTest [_GlowZTest]
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_instancing
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
fixed4 color : COLOR;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
//float4 _Glow; // x = intensity, y = width, z = magic number 1, w = magic number 2
float3 _Glow2; // x = outline width, y = glow speed, z = dither on/off
float _ConstantWidth;
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_DEFINE_INSTANCED_PROP(float4, _GlowColor)
UNITY_DEFINE_INSTANCED_PROP(float4, _Glow)
UNITY_DEFINE_INSTANCED_PROP(float4, _GlowDirection)
UNITY_INSTANCING_BUFFER_END(Props)
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
float4 glowDirection = UNITY_ACCESS_INSTANCED_PROP(Props, _GlowDirection);
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED) || defined(SINGLE_PASS_STEREO)
glowDirection.x *= 2.0;
#endif
v.vertex.xyz += v.normal * glowDirection.z;
float4 pos = ComputeVertexPosition(v.vertex);
float3 norm = mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal);
float2 offset = TransformViewToProjection(normalize(norm.xy));
offset += glowDirection.xy;
float z = lerp(UNITY_Z_0_FAR_FROM_CLIPSPACE(pos.z), 2.0, UNITY_MATRIX_P[3][3]);
z = _ConstantWidth * (z - 2.0) + 2.0;
float outlineWidth = _Glow2.x;
float4 glow = UNITY_ACCESS_INSTANCED_PROP(Props, _Glow);
float animatedWidth = glow.y * (1.0 + 0.25 * sin(_Time.w * _Glow2.y));
offset *= z * (outlineWidth + animatedWidth);
pos.xy += offset;
o.pos = pos;
o.color = UNITY_ACCESS_INSTANCED_PROP(Props, _GlowColor);
o.color.a = glow.x;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(i);
fixed4 color = i.color;
float4 glow = UNITY_ACCESS_INSTANCED_PROP(Props, _Glow);
float2 screenPos = floor( i.pos.xy * glow.z ) * glow.w;
color.a *= saturate(_Glow2.z + frac(screenPos.x + screenPos.y));
return color;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 049d9e75e07674a78a703cf1203c07dd
timeCreated: 1544699250
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,95 @@
Shader "HighlightPlus/Geometry/InnerGlow" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_InnerGlowColor ("Inner Glow Color", Color) = (1,1,1,1)
_InnerGlowWidth ("Width", Float) = 1.0
_CutOff("CutOff", Float ) = 0.5
_Cull ("Cull Mode", Int) = 2
_InnerGlowZTest ("ZTest", Int) = 4
}
SubShader
{
Tags { "Queue"="Transparent+122" "RenderType"="Transparent" "DisableBatching"="True" }
// Inner Glow
Pass
{
Stencil {
Ref 4
ReadMask 4
Comp NotEqual
Pass keep
}
Blend SrcAlpha One
ZWrite Off
ZTest [_InnerGlowZTest]
Cull [_Cull]
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_local _ HP_ALPHACLIP
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float3 normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float3 wpos : TEXCOORD1;
float3 normal : NORMAL;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
float4 _MainTex_ST;
fixed _CutOff;
fixed4 _InnerGlowColor;
fixed _InnerGlowWidth;
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
#if UNITY_REVERSED_Z
o.pos.z += 0.0001;
#else
o.pos.z -= 0.0001;
#endif
o.wpos = mul(unity_ObjectToWorld, v.vertex).xyz;
o.normal = UnityObjectToWorldNormal(v.normal);
o.uv = TRANSFORM_TEX (v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
#if HP_ALPHACLIP
fixed4 color = tex2D(_MainTex, i.uv);
clip(color.a - _CutOff);
#endif
float3 viewDir = normalize(i.wpos - _WorldSpaceCameraPos.xyz);
fixed dx = saturate(_InnerGlowWidth - abs(dot(viewDir, normalize(i.normal)))) / _InnerGlowWidth;
fixed4 col = _InnerGlowColor * dx;
return col;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e5a069457bd344391acd5af227c0ce11
timeCreated: 1544699250
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,140 @@
Shader "HighlightPlus/Geometry/Mask" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_CutOff("CutOff", Float ) = 0.5
_Cull ("Cull Mode", Int) = 2
_ZTest ("ZTest", Int) = 4
}
SubShader
{
Tags { "Queue"="Transparent+100" "RenderType"="Transparent" "DisableBatching"="True" }
CGINCLUDE
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
sampler2D _MainTex;
float4 _MainTex_ST;
float4 _MainTex_TexelSize;
fixed _CutOff;
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float2 uv : TEXCOORD0;
#if HP_DEPTHCLIP
float4 scrPos : TEXCOORD1;
float depth : TEXCOORD2;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
o.uv = TRANSFORM_TEX (v.uv, _MainTex);
#if HP_DEPTHCLIP
o.scrPos = ComputeScreenPos(o.pos);
COMPUTE_EYEDEPTH(o.depth);
#endif
#if UNITY_REVERSED_Z
o.pos.z += 0.0001;
#else
o.pos.z -= 0.0001;
#endif
return o;
}
float GetEyeDepth(float rawDepth) {
float persp = LinearEyeDepth(rawDepth);
float ortho = (_ProjectionParams.z-_ProjectionParams.y)*(1-rawDepth)+_ProjectionParams.y;
return lerp(persp,ortho,unity_OrthoParams.w);
}
fixed4 frag (v2f i) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
#if HP_ALPHACLIP
fixed4 col = tex2D(_MainTex, i.uv);
clip(col.a - _CutOff);
#endif
#if HP_DEPTHCLIP
float sceneZ = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoTransformScreenSpaceTex(i.scrPos.xy / i.scrPos.w));
float sceneDepth = GetEyeDepth(sceneZ);
clip(sceneDepth - i.depth * 0.999);
#endif
return 0;
}
ENDCG
// Create mask
Pass
{
Name "Mask"
Stencil {
Ref 2
Comp always
Pass replace
WriteMask 2
ReadMask 2
}
ColorMask 0
ZWrite Off
Cull [_Cull] // default Cull Back improves glow in high quality)
ZTest [_ZTest]
Offset -1, -1 // avoid issues on Quest 2 standalone when using with other render features (ie. Liquid Volume Pro 2 irregular topology)
CGPROGRAM
#pragma multi_compile_local _ HP_ALPHACLIP
#pragma multi_compile_local _ HP_DEPTHCLIP
#pragma vertex vert
#pragma fragment frag
ENDCG
}
// Create mask for see-through (the only difference is the ZTest)
Pass
{
Name "See-through Mask"
Stencil {
Ref 2
Comp always
Pass replace
WriteMask 2
ReadMask 2
}
ColorMask 0
ZWrite Off
Cull [_Cull] // default Cull Back improves glow in high quality)
ZTest LEqual
Offset -1, -1 // avoid issues on Quest 2 standalone when using with other render features (ie. Liquid Volume Pro 2 irregular topology)
CGPROGRAM
#pragma multi_compile_local _ HP_ALPHACLIP
#pragma multi_compile_local _ HP_DEPTHCLIP
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e694fa934b6db4a00b8d4b9887115332
timeCreated: 1544699251
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,62 @@
Shader "HighlightPlus/Geometry/SeeThroughOccluder" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
}
SubShader
{
Tags { "Queue"="Transparent+100" "RenderType"="Transparent" "DisableBatching"="True" }
// Create mask
Pass
{
Stencil {
Ref 2
Comp always
Pass DecrWrap
}
ColorMask 0
ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
#if UNITY_REVERSED_Z
o.pos.z += 0.0001;
#else
o.pos.z -= 0.0001;
#endif
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return 0;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 229baf997355a43cda580dd4cf86b71e
timeCreated: 1544699251
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,83 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: HighlightOutline
m_Shader: {fileID: 4800000, guid: cbbf740e9c8644e8492d08b1a3fd0203, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _ConstantWidth: 1
- _Cull: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _OutlineWidth: 0.01
- _OutlineZTest: 4
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _OutlineDirection: {r: 0, g: 0, b: 0, a: 1}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 57729312cdd6d4eb685a81a3b0bf8a5b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,174 @@
Shader "HighlightPlus/Geometry/Outline" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Offset", Float) = 0.01
_OutlineDirection("Outline Direction", Vector) = (0,0,0)
_OutlineGradientTex("Outline Gradient Tex", 2D) = "white" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_Cull ("Cull Mode", Int) = 2
_ConstantWidth ("Constant Width", Float) = 1
_OutlineZTest("ZTest", Int) = 4
}
SubShader
{
Tags { "Queue"="Transparent+120" "RenderType"="Transparent" "DisableBatching"="True" }
Pass
{
Name "Outline"
Stencil {
Ref 2
Comp NotEqual
Pass replace
ReadMask 2
WriteMask 2
}
Blend SrcAlpha OneMinusSrcAlpha
ZWrite On
Cull [_Cull]
ZTest [_OutlineZTest]
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_instancing
#pragma multi_compile_local _ HP_ALPHACLIP
#pragma multi_compile_local _ HP_OUTLINE_GRADIENT_WS HP_OUTLINE_GRADIENT_LS
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
fixed yt : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
fixed4 _OutlineColor;
sampler2D _OutlineGradientTex;
float _OutlineWidth;
float _ConstantWidth;
float _OutlineVertexWidth;
fixed2 _OutlineVertexData;
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_DEFINE_INSTANCED_PROP(float4, _OutlineDirection)
UNITY_INSTANCING_BUFFER_END(Props)
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
#if HP_OUTLINE_GRADIENT_WS
float posy = mul(unity_ObjectToWorld, v.vertex).y;
o.yt = saturate( (posy - _OutlineVertexData.x) / _OutlineVertexData.y);
#else
o.yt = saturate( (v.vertex.y - _OutlineVertexData.x) / _OutlineVertexData.y);
#endif
v.vertex.xyz += v.normal * _OutlineVertexWidth;
o.pos = ComputeVertexPosition(v.vertex);
float3 norm = mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal);
float2 offset = TransformViewToProjection(normalize(norm.xy));
float z = lerp(UNITY_Z_0_FAR_FROM_CLIPSPACE(o.pos.z), 2.0, UNITY_MATRIX_P[3][3]);
z = _ConstantWidth * (z - 2.0) + 2.0;
float4 outlineDirection = UNITY_ACCESS_INSTANCED_PROP(Props, _OutlineDirection);
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED) || defined(SINGLE_PASS_STEREO)
outlineDirection.x *= 2.0;
#endif
o.pos.xy += offset * z * _OutlineWidth + outlineDirection.xy * z;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
#if HP_OUTLINE_GRADIENT_WS || HP_OUTLINE_GRADIENT_LS
half4 color = tex2D(_OutlineGradientTex, float2(i.yt, 0));
color.a *= _OutlineColor.a;
#else
half4 color = _OutlineColor;
#endif
return color;
}
ENDCG
}
Pass
{
Name "Outline Clear Stencil"
Stencil {
Ref 8 // bit 8 is used by HighlightUIMask shader to prevent Clear Stencil passes
Comp NotEqual
Pass zero
ReadMask 8
WriteMask 6
}
ColorMask 0
ZWrite Off
Cull [_Cull]
ZTest Always
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
fixed4 _OutlineColor;
float _OutlineWidth;
float2 _OutlineDirection;
float _ConstantWidth;
float _OutlineVertexWidth;
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
v.vertex.xyz += v.normal * _OutlineVertexWidth;
o.pos = ComputeVertexPosition(v.vertex);
float3 norm = mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal);
float2 offset = TransformViewToProjection(normalize(norm.xy));
float z = lerp(UNITY_Z_0_FAR_FROM_CLIPSPACE(o.pos.z), 2.0, UNITY_MATRIX_P[3][3]);
z = _ConstantWidth * (z - 2.0) + 2.0;
o.pos.xy += offset * z * _OutlineWidth + _OutlineDirection * z;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return 0;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: cbbf740e9c8644e8492d08b1a3fd0203
timeCreated: 1544699250
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,143 @@
Shader "HighlightPlus/Geometry/Overlay" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_OverlayColor ("Overlay Color", Color) = (1,1,1,1)
_OverlayBackColor ("Overlay Back Color", Color) = (1,1,1,1)
_OverlayData("Overlay Data", Vector) = (1,0.5,1,1)
_OverlayHitPosData("Overlay Hit Pos Data", Vector) = (0,0,0,0)
_OverlayHitStartTime("Overlay Hit Start Time", Float) = 0
_OverlayTexture("Overlay Texture", 2D) = "white" {}
_CutOff("CutOff", Float ) = 0.5
_Cull ("Cull Mode", Int) = 2
}
SubShader
{
Tags { "Queue"="Transparent+121" "RenderType"="Transparent" "DisableBatching"="True" }
// Overlay
Pass
{
Stencil {
Ref 4
ReadMask 4
Comp NotEqual
Pass keep
}
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
Cull [_Cull]
Offset -1, -1 // avoid issues on Quest 2 standalone when using with other render features (ie. Liquid Volume Pro 2 irregular topology)
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_local _ HP_ALPHACLIP
#pragma multi_compile_local _ HP_TEXTURE_TRIPLANAR HP_TEXTURE_SCREENSPACE HP_TEXTURE_OBJECTSPACE
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float3 norm : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float3 wpos : TEXCOORD1;
#if HP_TEXTURE_TRIPLANAR
float3 wnorm : TEXCOORD2;
#endif
#if HP_TEXTURE_SCREENSPACE
float4 scrPos : TEXCOORD3;
#endif
UNITY_VERTEX_OUTPUT_STEREO
};
fixed4 _OverlayColor;
sampler2D _MainTex;
float4 _MainTex_ST;
fixed4 _OverlayBackColor;
fixed4 _OverlayData; // x = speed, y = MinIntensity, z = blend, w = texture scale
float4 _OverlayHitPosData;
float _OverlayHitStartTime;
fixed _CutOff;
sampler2D _OverlayTexture;
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
#if HP_TEXTURE_SCREENSPACE
o.scrPos = ComputeScreenPos(o.pos);
o.scrPos.x *= _ScreenParams.x / _ScreenParams.y;
#endif
#if UNITY_REVERSED_Z
o.pos.z += 0.0001;
#else
o.pos.z -= 0.0001;
#endif
o.wpos = mul(unity_ObjectToWorld, v.vertex).xyz;
#if HP_TEXTURE_TRIPLANAR
o.wnorm = UnityObjectToWorldNormal(v.norm);
#endif
o.uv = TRANSFORM_TEX (v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 color = tex2D(_MainTex, i.uv);
#if HP_ALPHACLIP
clip(color.a - _CutOff);
#endif
float time = _Time.y % 1000;
fixed t = _OverlayData.y + (1.0 - _OverlayData.y) * 2.0 * abs(0.5 - frac(time * _OverlayData.x));
fixed4 col = lerp(_OverlayColor, color * _OverlayBackColor * _OverlayColor, _OverlayData.z);
col.a *= t;
if (_OverlayHitPosData.w>0) {
float elapsed = _Time.y - _OverlayHitStartTime;
float hitDist = distance(i.wpos, _OverlayHitPosData.xyz);
float atten = saturate( min(elapsed, _OverlayHitPosData.w) / hitDist );
col.a *= atten;
}
#if HP_TEXTURE_TRIPLANAR
half3 triblend = saturate(pow(i.wnorm, 4));
triblend /= max(dot(triblend, half3(1,1,1)), 0.0001);
// triplanar uvs
float3 tpos = i.wpos * _OverlayData.w;
float2 uvX = tpos.zy;
float2 uvY = tpos.xz;
float2 uvZ = tpos.xy;
// albedo textures
fixed4 colX = tex2D(_OverlayTexture, uvX);
fixed4 colY = tex2D(_OverlayTexture, uvY);
fixed4 colZ = tex2D(_OverlayTexture, uvZ);
fixed4 tex = colX * triblend.x + colY * triblend.y + colZ * triblend.z;
col *= tex;
#elif HP_TEXTURE_SCREENSPACE
col *= tex2D(_OverlayTexture, (i.scrPos.xy / i.scrPos.w) * _OverlayData.w);
#elif HP_TEXTURE_OBJECTSPACE
col *= tex2D(_OverlayTexture, i.uv * _OverlayData.w);
#endif
return col;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: d17a98d19ada34bb7b4f86130e590159
timeCreated: 1544699250
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,76 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: HighlightPlusDepthClipComp
m_Shader: {fileID: 4800000, guid: 0917f634da79a4983ad78bac83d5a715, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 94aad838a87c54e1b89e9ef47ecad5bf
timeCreated: 1546857910
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,76 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: HighlightPlusDepthWrite
m_Shader: {fileID: 4800000, guid: 058a572e30b2d446bade2dda32bcef0f, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 825cb444e111842cf97788cbb7583edd
timeCreated: 1546857910
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,132 @@
Shader "HighlightPlus/Geometry/SeeThroughBorder" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_SeeThroughBorderColor ("Outline Color", Color) = (0,0,0,1)
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_CutOff("CutOff", Float ) = 0.5
_SeeThroughBorderWidth ("Outline Offset", Float) = 0.01
_SeeThroughBorderConstantWidth ("Constant Width", Float) = 1
_SeeThroughStencilRef ("Stencil Ref", Int) = 2
_SeeThroughStencilComp ("Stencil Comp", Int) = 5
_SeeThroughDepthOffset ("Depth Offset", Float) = 0
_SeeThroughMaxDepth("Max Depth", Float) = 0
_SeeThroughStencilPassOp ("Stencil Pass Operation", Int) = 0
_SeeThroughOrdered("Ordered", Int) = 1
_ZTest("ZTest", Int) = 4
}
SubShader
{
Tags { "Queue"="Transparent+201" "RenderType"="Transparent" "DisableBatching"="True" }
Pass
{
Name "See-through border"
Stencil {
ReadMask 3
WriteMask 3
Ref [_SeeThroughStencilRef]
Comp [_SeeThroughStencilComp]
Pass [_SeeThroughStencilPassOp]
Fail [_SeeThroughStencilPassOp]
}
ZTest [_ZTest]
ZWrite On
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_local _ HP_ALPHACLIP
#pragma multi_compile_local _ HP_DEPTH_OFFSET
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float3 normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float2 uv : TEXCOORD0;
#if HP_DEPTH_OFFSET
float4 scrPos : TEXCOORD1;
float depth : TEXCOORD2;
#endif
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
float4 _MainTex_ST;
fixed4 _SeeThroughBorderColor;
fixed _CutOff;
float _SeeThroughDepthOffset;
float _SeeThroughMaxDepth;
int _SeeThroughOrdered;
float _SeeThroughBorderWidth;
float _SeeThroughBorderConstantWidth;
fixed _HP_Fade;
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
#if HP_DEPTH_OFFSET
o.scrPos = ComputeScreenPos(o.pos);
COMPUTE_EYEDEPTH(o.depth);
#endif
float3 norm = mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal);
float2 offset = any(norm.xy)!=0 ? TransformViewToProjection(normalize(norm.xy)) : 0.0.xx;
float z = lerp(UNITY_Z_0_FAR_FROM_CLIPSPACE(o.pos.z), 2.0, UNITY_MATRIX_P[3][3]);
z = _SeeThroughBorderConstantWidth * (z - 2.0) + 2.0;
o.pos.xy += offset * z * _SeeThroughBorderWidth;
#if UNITY_REVERSED_Z
o.pos.z -= 0.0001;
o.pos.z = _SeeThroughOrdered ? o.pos.w - (o.pos.w - o.pos.z) * 0.001 : o.pos.z;
#else
o.pos.z += 0.0001;
o.pos.z = _SeeThroughOrdered ? -o.pos.w + ( o.pos.z + o.pos.w ) * 0.001 : o.pos.z;
#endif
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
float GetEyeDepth(float rawDepth) {
float persp = LinearEyeDepth(rawDepth);
float ortho = (_ProjectionParams.z-_ProjectionParams.y)*(1-rawDepth)+_ProjectionParams.y;
return lerp(persp,ortho,unity_OrthoParams.w);
}
fixed4 frag (v2f i) : SV_Target
{
#if HP_DEPTH_OFFSET
float sceneZ = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.scrPos.xy / i.scrPos.w);
float sceneDepth = GetEyeDepth(sceneZ);
if (i.depth - sceneDepth - _SeeThroughDepthOffset < 0 || i.depth - sceneDepth > _SeeThroughMaxDepth) discard;
#endif
#if HP_ALPHACLIP
fixed4 col = tex2D(_MainTex, i.uv);
clip(col.a - _CutOff);
#endif
fixed4 res = _SeeThroughBorderColor;
res.a *= _HP_Fade;
return res;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 47198bbf0b2a44882aceef6af17a467d
timeCreated: 1544699250
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,173 @@
Shader "HighlightPlus/Geometry/SeeThroughInner" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_SeeThrough ("See Through", Range(0,1)) = 0.8
_SeeThroughTintColor ("See Through Tint Color", Color) = (1,0,0,0.8)
_SeeThroughNoise("Noise", Float) = 1
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_CutOff("CutOff", Float ) = 0.5
_SeeThroughStencilRef ("Stencil Ref", Int) = 2
_SeeThroughStencilComp ("Stencil Comp", Int) = 5
_SeeThroughStencilPassOp ("Stencil Pass Operation", Int) = 0
_SeeThroughDepthOffset ("Depth Offset", Float) = 0
_SeeThroughMaxDepth("Max Depth", Float) = 0
_SeeThroughOrdered("Ordered", Int) = 1
_SeeThroughTexture("Mask Texture", 2D) = "white" {}
_SeeThroughTextureScale("Mask Texture Scale", Float) = 1.0
_ZTest("ZTest", Int) = 4
}
SubShader
{
Tags { "Queue"="Transparent+201" "RenderType"="Transparent" "DisableBatching"="True" }
// See through effect
Pass
{
Name "See-through"
Stencil {
ReadMask 3
WriteMask 3
Ref [_SeeThroughStencilRef]
Comp [_SeeThroughStencilComp]
Pass [_SeeThroughStencilPassOp]
Fail [_SeeThroughStencilPassOp]
}
ZTest [_ZTest]
ZWrite On // Needs to be on so see-through border do not overlap
// Cull Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_local _ HP_ALPHACLIP
#pragma multi_compile_local _ HP_DEPTH_OFFSET
#pragma multi_compile_local _ HP_SEETHROUGH_ONLY_BORDER
#pragma multi_compile_local _ HP_TEXTURE_TRIPLANAR HP_TEXTURE_SCREENSPACE HP_TEXTURE_OBJECTSPACE
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 norm : NORMAL;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float2 uv : TEXCOORD0;
#if HP_DEPTH_OFFSET || HP_TEXTURE_SCREENSPACE
float4 scrPos : TEXCOORD1;
#endif
#if HP_DEPTH_OFFSET
float depth : TEXCOORD2;
#endif
float3 wpos : TEXCOORD3;
#if HP_TEXTURE_TRIPLANAR
float3 wnorm : TEXCOORD4;
#endif
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
float4 _MainTex_ST;
fixed _SeeThrough;
fixed4 _SeeThroughTintColor;
fixed _CutOff;
fixed _SeeThroughNoise;
float _SeeThroughDepthOffset;
float _SeeThroughMaxDepth;
int _SeeThroughOrdered;
fixed _HP_Fade;
sampler2D _SeeThroughTexture;
fixed _SeeThroughTextureScale;
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
#if HP_DEPTH_OFFSET || HP_TEXTURE_SCREENSPACE
o.scrPos = ComputeScreenPos(o.pos);
#endif
#if HP_DEPTH_OFFSET
COMPUTE_EYEDEPTH(o.depth);
#endif
o.wpos = mul(unity_ObjectToWorld, v.vertex).xyz;
#if HP_TEXTURE_TRIPLANAR
o.wnorm = UnityObjectToWorldNormal(v.norm);
#endif
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
float GetEyeDepth(float rawDepth) {
float persp = LinearEyeDepth(rawDepth);
float ortho = (_ProjectionParams.z-_ProjectionParams.y)*(1-rawDepth)+_ProjectionParams.y;
return lerp(persp,ortho,unity_OrthoParams.w);
}
fixed4 frag (v2f i) : SV_Target
{
#if HP_SEETHROUGH_ONLY_BORDER
return 0;
#else
#if HP_DEPTH_OFFSET
float sceneZ = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.scrPos.xy / i.scrPos.w);
float sceneDepth = GetEyeDepth(sceneZ);
if (i.depth - sceneDepth - _SeeThroughDepthOffset < 0 || i.depth - sceneDepth > _SeeThroughMaxDepth) discard;
#endif
fixed4 col = tex2D(_MainTex, i.uv);
#if HP_ALPHACLIP
clip(col.a - _CutOff);
#endif
col.rgb = lerp(col.rgb, _SeeThroughTintColor.rgb, _SeeThroughTintColor.a);
float scry = i.pos.y;
float time = _Time.w % 1.0;
col.rgb += _SeeThroughNoise *(frac( scry * time ) * 0.1);
col.a = _SeeThrough;
col.a = lerp(col.a, col.a * ( (scry % 2) - 1.0 ), _SeeThroughNoise);
col.a *= _HP_Fade;
#if HP_TEXTURE_TRIPLANAR
half3 triblend = saturate(pow(i.wnorm, 4));
triblend /= max(dot(triblend, half3(1,1,1)), 0.0001);
// triplanar uvs
float3 tpos = i.wpos * _SeeThroughTextureScale;
float2 uvX = tpos.zy;
float2 uvY = tpos.xz;
float2 uvZ = tpos.xy;
// albedo textures
fixed4 colX = tex2D(_SeeThroughTexture, uvX);
fixed4 colY = tex2D(_SeeThroughTexture, uvY);
fixed4 colZ = tex2D(_SeeThroughTexture, uvZ);
fixed4 tex = colX * triblend.x + colY * triblend.y + colZ * triblend.z;
col *= tex;
#elif HP_TEXTURE_SCREENSPACE
float2 uv = (i.scrPos.xy / i.scrPos.w);
uv.x *= _ScreenParams.x / _ScreenParams.y;
col *= tex2D(_SeeThroughTexture, uv * _SeeThroughTextureScale);
#elif HP_TEXTURE_OBJECTSPACE
col *= tex2D(_SeeThroughTexture, i.uv * _SeeThroughTextureScale);
#endif
return col;
#endif // HP_ONLY_BORDER
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f5e95a6a4248649f7ac2ac6127ca0dd1
timeCreated: 1544699250
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,61 @@
Shader "HighlightPlus/Geometry/SeeThroughMask" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
}
SubShader
{
Tags { "Queue"="Transparent+201" "RenderType"="Transparent" "DisableBatching"="True" }
// See through effect
Pass
{
Stencil {
WriteMask 3
Ref 1
Comp always
Pass replace
}
ZTest Always
ZWrite Off
ColorMask 0
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return 0;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 05afe1e2da9484c1f9317f48d5edb58c
timeCreated: 1544699251
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,101 @@
Shader "HighlightPlus/Geometry/SolidColor" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_CutOff("CutOff", Float ) = 0.5
_Cull ("Cull Mode", Int) = 2
_ZTest("ZTest", Int) = 4
}
SubShader
{
Tags { "Queue"="Transparent+100" "RenderType"="Transparent" }
// Compose effect on camera target
Pass
{
ZWrite Off
Cull [_Cull]
ZTest [_ZTest]
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_local _ HP_ALPHACLIP
#pragma multi_compile_local _ HP_DEPTHCLIP
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
sampler2D _MainTex;
float4 _MainTex_ST;
fixed _CutOff;
fixed4 _Color;
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float2 uv : TEXCOORD0;
#if HP_DEPTHCLIP
float4 scrPos : TEXCOORD1;
float depth : TEXCOORD2;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
o.uv = TRANSFORM_TEX (v.uv, _MainTex);
#if HP_DEPTHCLIP
o.scrPos = ComputeScreenPos(o.pos);
COMPUTE_EYEDEPTH(o.depth);
#endif
#if UNITY_REVERSED_Z
o.pos.z += 0.0001;
#else
o.pos.z -= 0.0001;
#endif
return o;
}
float GetEyeDepth(float rawDepth) {
float persp = LinearEyeDepth(rawDepth);
float ortho = (_ProjectionParams.z-_ProjectionParams.y)*(1-rawDepth)+_ProjectionParams.y;
return lerp(persp,ortho,unity_OrthoParams.w);
}
fixed4 frag (v2f i) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
#if HP_ALPHACLIP
fixed4 col = tex2D(_MainTex, i.uv);
clip(col.a - _CutOff);
#endif
#if HP_DEPTHCLIP
float sceneZ = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoTransformScreenSpaceTex(i.scrPos.xy / i.scrPos.w));
float sceneDepth = GetEyeDepth(sceneZ);
clip(sceneDepth - i.depth * 0.999);
#endif
return fixed4(1.0, 1.0, 1.0, 1.0);
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 77643996218224478a471439e0ea5fb4
timeCreated: 1544699251
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,165 @@
Shader "HighlightPlus/Geometry/Target" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_Color ("Color", Color) = (1,1,1,1)
_ZTest ("ZTest", Int) = 0
}
SubShader
{
Tags { "RenderType" = "Transparent" "Queue" = "Transparent-1" "DisableBatching" = "True" }
Pass
{
Name "Target FX Decal"
Stencil {
Ref 2
Comp NotEqual
ReadMask 2
}
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
ZTest [_ZTest]
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#include "UnityCG.cginc"
struct appdata
{
float4 positionOS : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 positionCS : SV_POSITION;
float4 screenPos : TEXCOORD0;
float4 rayVS : TEXCOORD1;
float3 camPosVS : TEXCOORD2;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
float4 _MainTex_ST;
half4 _Color;
float4 _TargetFXRenderData;
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
#define GROUND_NORMAL _TargetFXRenderData.xyz
#define FADE_POWER _TargetFXRenderData.w
#define UNITY_MATRIX_I_M unity_WorldToObject
v2f vert(appdata input)
{
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.positionCS = UnityObjectToClipPos(input.positionOS);
o.screenPos = ComputeScreenPos(o.positionCS);
float3 viewRay = UnityObjectToViewPos(input.positionOS);
o.rayVS.w = viewRay.z;
float4x4 viewToObject = mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V);
o.rayVS.xyz = mul((float3x3)viewToObject, -viewRay);
o.camPosVS = mul(viewToObject, float4(0,0,0,1)).xyz;
return o;
}
half4 frag(v2f i) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float depth = UNITY_SAMPLE_DEPTH(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraDepthTexture, i.screenPos.xy / i.screenPos.w));
float3 decalPos;
if(unity_OrthoParams.w) {
#if defined(UNITY_REVERSED_Z)
depth = 1.0 - depth;
#endif
float sceneDepthVS = lerp(_ProjectionParams.y, _ProjectionParams.z, depth);
float2 rayVSEnd = float2(unity_OrthoParams.xy * (i.screenPos.xy - 0.5) * 2.0);
float4 posVS = float4(rayVSEnd, -sceneDepthVS, 1);
float3 wpos = mul(UNITY_MATRIX_I_V, posVS).xyz;
decalPos = mul(UNITY_MATRIX_I_M, float4(wpos, 1)).xyz;
} else {
float depthEye = LinearEyeDepth(depth);
decalPos = i.camPosVS + (i.rayVS.xyz / i.rayVS.w) * depthEye;
}
clip(0.5 - abs(decalPos));
// check normal
float3 normal = normalize(cross(ddx(decalPos), -ddy(decalPos)));
float slope = dot(normal, GROUND_NORMAL);
clip(slope - 0.01);
float2 uv = decalPos.xz + 0.5;
half4 col = tex2D(_MainTex, uv);
col *= _Color;
// atten with elevation
col.a /= 1.0 + pow(1.0 + max(0, decalPos.y - 0.1), FADE_POWER);
return col;
}
ENDCG
}
Pass
{
Name "Target FX Regular"
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
ZTest [_ZTest]
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
fixed4 _Color;
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return tex2D(_MainTex, i.uv) * _Color;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 54328cae8f89d442da972097ce4f23d9
timeCreated: 1544699250
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,84 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: HighlightUIMask
m_Shader: {fileID: 4800000, guid: f65ebd3db9df34222b24b0b7b2b752b2, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _ColorMask: 15
- _CutOff: 0.5
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7e86e0b9dab6441b2a8c2787c90d22aa
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,78 @@
Shader "HighlightPlus/UI/Mask" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_CutOff("CutOff", Float ) = 0.5
_StencilComp("Stencil Comparison", Float) = 8
_Stencil("Stencil ID", Float) = 0
_StencilOp("Stencil Operation", Float) = 0
_StencilWriteMask("Stencil Write Mask", Float) = 255
_StencilReadMask("Stencil Read Mask", Float) = 255
_ColorMask("Color Mask", Float) = 15
}
SubShader
{
Tags { "Queue"="Transparent" "RenderType"="Transparent" "IgnoreProjector" = "True" }
// Create mask
Pass
{
Stencil {
Ref 14 // bit 8 is used by HighlightUIMask shader to prevent Clear Stencil passes
Comp always
Pass replace
ReadMask 14
WriteMask 14
ZFail replace
}
ColorMask 0
ZWrite Off
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
sampler2D _MainTex;
float4 _MainTex_ST;
float4 _MainTex_TexelSize;
fixed _CutOff;
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
o.uv = TRANSFORM_TEX (v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
clip(col.a - _CutOff);
return 0;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f65ebd3db9df34222b24b0b7b2b752b2
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -0,0 +1,100 @@
fileFormatVersion: 2
guid: 1de3c566a6c8c405b9f6f453137273ec
timeCreated: 1555360741
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: iPhone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: WebGL
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 89ce39cd6bb34454bbaf48f1d111f236
folderAsset: yes
timeCreated: 1542876305
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 888380afc233049ce9e618f9f36c8ba8
timeCreated: 1545593776
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 900
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,86 @@
using UnityEngine;
namespace HighlightPlus {
public enum HitFxMode {
Overlay = 0,
InnerGlow = 1,
LocalHit = 2
}
public partial class HighlightEffect : MonoBehaviour {
[Range(0,1)] public float hitFxInitialIntensity;
public HitFxMode hitFxMode = HitFxMode.Overlay;
public float hitFxFadeOutDuration = 0.25f;
[ColorUsage(true, true)] public Color hitFxColor = Color.white;
public float hitFxRadius = 0.5f;
float hitInitialIntensity;
float hitStartTime;
float hitFadeOutDuration;
Color hitColor;
bool hitActive;
Vector3 hitPosition;
float hitRadius;
/// <summary>
/// Performs a hit effect using default values
/// </summary>
public void HitFX() {
HitFX(hitFxColor, hitFxFadeOutDuration, hitFxInitialIntensity);
}
/// <summary>
/// Performs a hit effect localized at hit position and radius with default values
/// </summary>
public void HitFX(Vector3 position) {
HitFX(hitFxColor, hitFxFadeOutDuration, hitFxInitialIntensity, position, hitFxRadius);
}
/// <summary>
/// Performs a hit effect using desired color, fade out duration and optionally initial intensity (0-1)
/// </summary>
public void HitFX(Color color, float fadeOutDuration, float initialIntensity = 1f) {
hitInitialIntensity = initialIntensity;
hitFadeOutDuration = fadeOutDuration;
hitColor = color;
hitStartTime = Time.time;
hitActive = true;
if (overlay == 0) {
UpdateMaterialProperties();
}
}
/// <summary>
/// Performs a hit effect using desired color, fade out duration, initial intensity (0-1), hit position and radius of effect
/// </summary>
public void HitFX(Color color, float fadeOutDuration, float initialIntensity, Vector3 position, float radius) {
hitInitialIntensity = initialIntensity;
hitFadeOutDuration = fadeOutDuration;
hitColor = color;
hitStartTime = Time.time;
hitActive = true;
hitPosition = position;
hitRadius = radius;
if (overlay == 0) {
UpdateMaterialProperties();
}
}
/// <summary>
/// Initiates the target FX on demand using predefined configuration (see targetFX... properties)
/// </summary>
public void TargetFX() {
targetFxStartTime = Time.time;
if (!targetFX) {
targetFX = true;
UpdateMaterialProperties();
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e749f80d0d29a49d49d6e0f4752065cd
timeCreated: 1542876337
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,271 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
namespace HighlightPlus {
public partial class HighlightEffect : MonoBehaviour {
static readonly List<HighlightSeeThroughOccluder> occluders = new List<HighlightSeeThroughOccluder>();
static readonly Dictionary<Camera, int> occludersFrameCount = new Dictionary<Camera, int>();
static CommandBuffer cbOccluder;
static Material fxMatSeeThroughOccluder, fxMatDepthWrite;
static RaycastHit[] hits;
/// <summary>
/// True if the see-through is cancelled by an occluder using raycast method
/// </summary>
public bool IsSeeThroughOccluded(Camera cam) {
// Compute bounds
Bounds bounds = new Bounds();
for (int r = 0; r < rms.Length; r++) {
if (rms[r].renderer != null) {
if (bounds.size.x == 0) {
bounds = rms[r].renderer.bounds;
} else {
bounds.Encapsulate(rms[r].renderer.bounds);
}
}
}
Vector3 pos = bounds.center;
Vector3 camPos = cam.transform.position;
Vector3 offset = pos - camPos;
float maxDistance = Vector3.Distance(pos, camPos);
if (hits == null || hits.Length == 0) {
hits = new RaycastHit[64];
}
int occludersCount = occluders.Count;
int hitCount = Physics.BoxCastNonAlloc(pos - offset, bounds.extents * 0.9f, offset.normalized, hits, Quaternion.identity, maxDistance);
for (int k = 0; k < hitCount; k++) {
for (int j = 0; j < occludersCount; j++) {
if (hits[k].collider.transform == occluders[j].transform) {
return true;
}
}
}
return false;
}
public static void RegisterOccluder(HighlightSeeThroughOccluder occluder) {
if (!occluders.Contains(occluder)) {
occluders.Add(occluder);
}
}
public static void UnregisterOccluder(HighlightSeeThroughOccluder occluder) {
if (occluders.Contains(occluder)) {
occluders.Remove(occluder);
}
}
/// <summary>
/// Test see-through occluders.
/// </summary>
/// <param name="cam">The camera to be tested</param>
/// <returns>Returns true if there's no raycast-based occluder cancelling the see-through effect</returns>
public bool RenderSeeThroughOccluders(Camera cam) {
int occludersCount = occluders.Count;
if (occludersCount == 0 || rmsCount == 0) return true;
bool useRayCastCheck = false;
// Check if raycast method is needed
for (int k = 0; k < occludersCount; k++) {
HighlightSeeThroughOccluder occluder = occluders[k];
if (occluder == null || !occluder.isActiveAndEnabled) continue;
if (occluder.detectionMethod == DetectionMethod.RayCast) {
useRayCastCheck = true;
break;
}
}
if (useRayCastCheck) {
if (IsSeeThroughOccluded(cam)) return false;
}
// do not render see-through occluders more than once this frame per camera (there can be many highlight effect scripts in the scene, we only need writing to stencil once)
int lastFrameCount;
occludersFrameCount.TryGetValue(cam, out lastFrameCount);
int currentFrameCount = Time.frameCount;
if (currentFrameCount == lastFrameCount) return true;
occludersFrameCount[cam] = currentFrameCount;
if (cbOccluder == null) {
cbOccluder = new CommandBuffer();
cbOccluder.name = "Occluder";
}
if (fxMatSeeThroughOccluder == null) {
InitMaterial(ref fxMatSeeThroughOccluder, "HighlightPlus/Geometry/SeeThroughOccluder");
if (fxMatSeeThroughOccluder == null) return true;
}
if (fxMatDepthWrite == null) {
InitMaterial(ref fxMatDepthWrite, "HighlightPlus/Geometry/JustDepth");
if (fxMatDepthWrite == null) return true;
}
cbOccluder.Clear();
for (int k = 0; k < occludersCount; k++) {
HighlightSeeThroughOccluder occluder = occluders[k];
if (occluder == null || !occluder.isActiveAndEnabled) continue;
if (occluder.detectionMethod == DetectionMethod.Stencil) {
if (occluder.meshData == null) continue;
int meshDataLength = occluder.meshData.Length;
// Per renderer
for (int m = 0; m < meshDataLength; m++) {
// Per submesh
Renderer renderer = occluder.meshData[m].renderer;
if (renderer.isVisible) {
for (int s = 0; s < occluder.meshData[m].subMeshCount; s++) {
cbOccluder.DrawRenderer(renderer, occluder.mode == OccluderMode.BlocksSeeThrough ? fxMatSeeThroughOccluder : fxMatDepthWrite, s);
}
}
}
}
}
Graphics.ExecuteCommandBuffer(cbOccluder);
return true;
}
bool CheckOcclusion(Camera cam) {
if (!perCameraOcclusionData.TryGetValue(cam, out PerCameraOcclusionData occlusionData)) {
occlusionData = new PerCameraOcclusionData();
perCameraOcclusionData[cam] = occlusionData;
}
float now = Time.time;
int frameCount = Time.frameCount; // ensure all cameras are checked this frame
if (now - occlusionData.checkLastTime < seeThroughOccluderCheckInterval && Application.isPlaying && occlusionData.occlusionRenderFrame != frameCount) return occlusionData.lastOcclusionTestResult;
occlusionData.checkLastTime = now;
occlusionData.occlusionRenderFrame = frameCount;
if (rms == null || rms.Length == 0 || rms[0].renderer == null) return false;
Vector3 camPos = cam.transform.position;
if (seeThroughOccluderCheckIndividualObjects) {
for (int r = 0; r < rms.Length; r++) {
if (rms[r].renderer != null) {
Bounds bounds = rms[r].renderer.bounds;
Vector3 pos = bounds.center;
float maxDistance = Vector3.Distance(pos, camPos);
if (Physics.BoxCast(pos, bounds.extents * seeThroughOccluderThreshold, (camPos - pos).normalized, Quaternion.identity, maxDistance, seeThroughOccluderMask)) {
occlusionData.lastOcclusionTestResult = true;
return true;
}
}
}
occlusionData.lastOcclusionTestResult = false;
return false;
} else {
// Compute combined bounds
Bounds bounds = rms[0].renderer.bounds;
for (int r = 1; r < rms.Length; r++) {
if (rms[r].renderer != null) {
bounds.Encapsulate(rms[r].renderer.bounds);
}
}
Vector3 pos = bounds.center;
float maxDistance = Vector3.Distance(pos, camPos);
occlusionData.lastOcclusionTestResult = Physics.BoxCast(pos, bounds.extents * seeThroughOccluderThreshold, (camPos - pos).normalized, Quaternion.identity, maxDistance, seeThroughOccluderMask);
return occlusionData.lastOcclusionTestResult;
}
}
const int MAX_OCCLUDER_HITS = 50;
static RaycastHit[] occluderHits;
void AddWithoutRepetition<T>(List<T> target, List<T> source) {
int sourceCount = source.Count;
for (int k = 0; k < sourceCount; k++) {
T entry = source[k];
if (entry != null && !target.Contains(entry)) {
target.Add(entry);
}
}
}
void CheckOcclusionAccurate(Camera cam) {
if (!perCameraOcclusionData.TryGetValue(cam, out PerCameraOcclusionData occlusionData)) {
occlusionData = new PerCameraOcclusionData();
perCameraOcclusionData[cam] = occlusionData;
}
float now = Time.time;
int frameCount = Time.frameCount; // ensure all cameras are checked this frame
bool reuse = now - occlusionData.checkLastTime < seeThroughOccluderCheckInterval && Application.isPlaying && occlusionData.occlusionRenderFrame != frameCount;
if (!reuse) {
if (rms == null || rms.Length == 0 || rms[0].renderer == null) return;
occlusionData.checkLastTime = now;
occlusionData.occlusionRenderFrame = frameCount;
Quaternion quaternionIdentity = Quaternion.identity;
Vector3 camPos = cam.transform.position;
occlusionData.cachedOccluders.Clear();
if (occluderHits == null || occluderHits.Length < MAX_OCCLUDER_HITS) {
occluderHits = new RaycastHit[MAX_OCCLUDER_HITS];
}
if (seeThroughOccluderCheckIndividualObjects) {
for (int r = 0; r < rms.Length; r++) {
if (rms[r].renderer != null) {
Bounds bounds = rms[r].renderer.bounds;
Vector3 pos = bounds.center;
float maxDistance = Vector3.Distance(pos, camPos);
int numOccluderHits = Physics.BoxCastNonAlloc(pos, bounds.extents * seeThroughOccluderThreshold, (camPos - pos).normalized, occluderHits, quaternionIdentity, maxDistance, seeThroughOccluderMask);
for (int k = 0; k < numOccluderHits; k++) {
occluderHits[k].collider.transform.root.GetComponentsInChildren(tempRR);
AddWithoutRepetition(occlusionData.cachedOccluders, tempRR);
}
}
}
} else {
// Compute combined bounds
Bounds bounds = rms[0].renderer.bounds;
for (int r = 1; r < rms.Length; r++) {
if (rms[r].renderer != null) {
bounds.Encapsulate(rms[r].renderer.bounds);
}
}
Vector3 pos = bounds.center;
float maxDistance = Vector3.Distance(pos, camPos);
int numOccluderHits = Physics.BoxCastNonAlloc(pos, bounds.extents * seeThroughOccluderThreshold, (camPos - pos).normalized, occluderHits, quaternionIdentity, maxDistance, seeThroughOccluderMask);
for (int k = 0; k < numOccluderHits; k++) {
occluderHits[k].collider.transform.root.GetComponentsInChildren(tempRR);
AddWithoutRepetition(occlusionData.cachedOccluders, tempRR);
}
}
}
// render occluders
int occluderRenderersCount = occlusionData.cachedOccluders.Count;
if (occluderRenderersCount > 0) {
cbSeeThrough.Clear();
for (int k = 0; k < occluderRenderersCount; k++) {
Renderer r = occlusionData.cachedOccluders[k];
if (r != null) {
cbSeeThrough.DrawRenderer(r, fxMatSeeThroughMask);
}
}
Graphics.ExecuteCommandBuffer(cbSeeThrough);
}
}
public List<Renderer> GetOccluders(Camera camera) {
if (perCameraOcclusionData.TryGetValue(camera, out PerCameraOcclusionData occlusionData)) {
return occlusionData.cachedOccluders;
}
return null;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d0bc1f04199a64e66ae9630062b3a6ad
timeCreated: 1542876337
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,420 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
namespace HighlightPlus {
public delegate bool OnObjectSelectionEvent(GameObject obj);
[RequireComponent(typeof(HighlightEffect))]
[DefaultExecutionOrder(100)]
[HelpURL("https://kronnect.com/guides/highlight-plus-introduction/")]
public class HighlightManager : MonoBehaviour {
[Tooltip("Enables highlight when pointer is over this object.")]
public bool highlightOnHover = true;
public LayerMask layerMask = -1;
public Camera raycastCamera;
public RayCastSource raycastSource = RayCastSource.MousePosition;
[Tooltip("Minimum distance for target.")]
public float minDistance;
[Tooltip("Maximum distance for target. 0 = infinity")]
public float maxDistance;
[Tooltip("Blocks interaction if pointer is over an UI element")]
public bool respectUI = true;
[Tooltip("If the object will be selected by clicking with mouse or tapping on it.")]
public bool selectOnClick;
[Tooltip("Optional profile for objects selected by clicking on them")]
public HighlightProfile selectedProfile;
[Tooltip("Profile to use whtn object is selected and highlighted.")]
public HighlightProfile selectedAndHighlightedProfile;
[Tooltip("Automatically deselects other previously selected objects")]
public bool singleSelection;
[Tooltip("Toggles selection on/off when clicking object")]
public bool toggle;
[Tooltip("Keeps current selection when clicking outside of any selectable object")]
public bool keepSelection = true;
HighlightEffect baseEffect, currentEffect;
Transform currentObject;
public readonly static List<HighlightEffect> selectedObjects = new List<HighlightEffect>();
public event OnObjectSelectionEvent OnObjectSelected;
public event OnObjectSelectionEvent OnObjectUnSelected;
public event OnObjectHighlightEvent OnObjectHighlightStart;
public event OnObjectHighlightEvent OnObjectHighlightEnd;
public static int lastTriggerFrame;
static HighlightManager _instance;
public static HighlightManager instance {
get {
if (_instance == null) {
_instance = FindObjectOfType<HighlightManager>();
}
return _instance;
}
}
[RuntimeInitializeOnLoadMethod]
void DomainReloadDisabledSupport() {
selectedObjects.Clear();
lastTriggerFrame = 0;
_instance = null;
}
void OnEnable() {
currentObject = null;
currentEffect = null;
if (baseEffect == null) {
baseEffect = GetComponent<HighlightEffect>();
if (baseEffect == null) {
baseEffect = gameObject.AddComponent<HighlightEffect>();
}
}
raycastCamera = GetComponent<Camera>();
if (raycastCamera == null) {
raycastCamera = GetCamera();
if (raycastCamera == null) {
Debug.LogError("Highlight Manager: no camera found!");
}
}
InputProxy.Init();
}
void OnDisable() {
SwitchesCollider(null);
internal_DeselectAll();
}
void Update() {
if (raycastCamera == null)
return;
#if ENABLE_INPUT_SYSTEM
if (respectUI) {
EventSystem es = EventSystem.current;
if (es == null) {
es = CreateEventSystem();
}
List<RaycastResult> raycastResults = new List<RaycastResult>();
PointerEventData eventData = new PointerEventData(es);
Vector3 cameraPos = raycastCamera.transform.position;
if (raycastSource == RayCastSource.MousePosition) {
eventData.position = InputProxy.mousePosition;
} else {
eventData.position = new Vector2(raycastCamera.pixelWidth * 0.5f, raycastCamera.pixelHeight * 0.5f);
}
es.RaycastAll(eventData, raycastResults);
int hitCount = raycastResults.Count;
// check UI blocker
bool blocked = false;
for (int k = 0; k < hitCount; k++) {
RaycastResult rr = raycastResults[k];
if (rr.module is UnityEngine.UI.GraphicRaycaster) {
blocked = true;
break;
}
}
if (blocked) return;
// look for our gameobject
for (int k = 0; k < hitCount; k++) {
RaycastResult rr = raycastResults[k];
float distance = Vector3.Distance(rr.worldPosition, cameraPos);
if (distance < minDistance || (maxDistance > 0 && distance > maxDistance)) continue;
GameObject theGameObject = rr.gameObject;
if ((layerMask & (1 << rr.gameObject.layer)) == 0) continue;
// is this object state controller by Highlight Trigger?
HighlightTrigger trigger = theGameObject.GetComponent<HighlightTrigger>();
if (trigger != null) return;
// Toggles selection
Transform t = theGameObject.transform;
if (InputProxy.GetMouseButtonDown(0)) {
if (selectOnClick) {
ToggleSelection(t, !toggle);
}
} else {
// Check if the object has a Highlight Effect
if (t != currentObject) {
SwitchesCollider(t);
}
}
return;
}
}
// if not blocked by UI and no hit found, fallback to raycast (required if no PhysicsRaycaster is present on the camera)
#endif
Ray ray;
if (raycastSource == RayCastSource.MousePosition) {
#if !ENABLE_INPUT_SYSTEM
if (!CanInteract()) {
return;
}
#endif
ray = raycastCamera.ScreenPointToRay(InputProxy.mousePosition);
} else {
ray = new Ray(raycastCamera.transform.position, raycastCamera.transform.forward);
}
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo, maxDistance > 0 ? maxDistance : raycastCamera.farClipPlane, layerMask) && Vector3.Distance(hitInfo.point, ray.origin) >= minDistance) {
Transform t = hitInfo.collider.transform;
// is this object state controller by Highlight Trigger?
HighlightTrigger trigger = t.GetComponent<HighlightTrigger>();
if (trigger != null) return;
// Toggles selection
if (InputProxy.GetMouseButtonDown(0)) {
if (selectOnClick) {
ToggleSelection(t, !toggle);
}
} else {
// Check if the object has a Highlight Effect
if (t != currentObject) {
SwitchesCollider(t);
}
}
return;
}
// no hit
if (selectOnClick && !keepSelection && InputProxy.GetMouseButtonDown(0) && lastTriggerFrame < Time.frameCount) {
internal_DeselectAll();
}
SwitchesCollider(null);
}
#if ENABLE_INPUT_SYSTEM
EventSystem CreateEventSystem() {
GameObject eo = new GameObject("Event System created by Highlight Plus", typeof(EventSystem), typeof(UnityEngine.InputSystem.UI.InputSystemUIInputModule));
return eo.GetComponent<EventSystem>();
}
#endif
void SwitchesCollider(Transform newObject) {
if (currentEffect != null) {
if (highlightOnHover) {
Highlight(false);
}
currentEffect = null;
}
currentObject = newObject;
if (newObject == null) return;
HighlightTrigger ht = newObject.GetComponent<HighlightTrigger>();
if (ht != null && ht.enabled)
return;
HighlightEffect otherEffect = newObject.GetComponent<HighlightEffect>();
if (otherEffect == null) {
// Check if there's a parent highlight effect that includes this object
HighlightEffect parentEffect = newObject.GetComponentInParent<HighlightEffect>();
if (parentEffect != null && parentEffect.Includes(newObject)) {
currentEffect = parentEffect;
if (highlightOnHover) {
Highlight(true);
}
return;
}
}
currentEffect = otherEffect != null ? otherEffect : baseEffect;
baseEffect.enabled = currentEffect == baseEffect;
currentEffect.SetTarget(currentObject);
if (highlightOnHover) {
Highlight(true);
}
}
bool CanInteract() {
if (!respectUI) return true;
EventSystem es = EventSystem.current;
if (es == null) return true;
if (Application.isMobilePlatform && InputProxy.touchCount > 0 && es.IsPointerOverGameObject(InputProxy.GetFingerIdFromTouch(0))) {
return false;
} else if (es.IsPointerOverGameObject(-1))
return false;
return true;
}
void ToggleSelection(Transform t, bool forceSelection) {
// We need a highlight effect on each selected object
HighlightEffect hb = t.GetComponent<HighlightEffect>();
if (hb == null) {
HighlightEffect parentEffect = t.GetComponentInParent<HighlightEffect>();
if (parentEffect != null && parentEffect.Includes(t)) {
hb = parentEffect;
if (hb.previousSettings == null) {
hb.previousSettings = ScriptableObject.CreateInstance<HighlightProfile>();
}
hb.previousSettings.Save(hb);
} else {
hb = t.gameObject.AddComponent<HighlightEffect>();
hb.previousSettings = ScriptableObject.CreateInstance<HighlightProfile>();
// copy default highlight effect settings from this manager into this highlight plus component
hb.previousSettings.Save(baseEffect);
hb.previousSettings.Load(hb);
}
}
bool currentState = hb.isSelected;
bool newState = forceSelection ? true : !currentState;
if (newState == currentState) return;
if (newState) {
if (OnObjectSelected != null && !OnObjectSelected(t.gameObject)) return;
} else {
if (OnObjectUnSelected != null && !OnObjectUnSelected(t.gameObject)) return;
}
if (singleSelection) {
internal_DeselectAll();
}
currentEffect = hb;
currentEffect.isSelected = newState;
baseEffect.enabled = false;
if (currentEffect.isSelected) {
if (currentEffect.previousSettings == null) {
currentEffect.previousSettings = ScriptableObject.CreateInstance<HighlightProfile>();
}
hb.previousSettings.Save(hb);
if (!selectedObjects.Contains(currentEffect)) {
selectedObjects.Add(currentEffect);
}
} else {
if (currentEffect.previousSettings != null) {
currentEffect.previousSettings.Load(hb);
}
if (selectedObjects.Contains(currentEffect)) {
selectedObjects.Remove(currentEffect);
}
}
Highlight(true);
}
void Highlight(bool state) {
if (state) {
if (!currentEffect.highlighted) {
if (OnObjectHighlightStart != null && currentEffect.target != null) {
if (!OnObjectHighlightStart(currentEffect.target.gameObject)) return;
}
}
} else {
if (currentEffect.highlighted) {
if (OnObjectHighlightEnd != null && currentEffect.target != null) {
OnObjectHighlightEnd(currentEffect.target.gameObject);
}
}
}
if (selectOnClick || currentEffect.isSelected) {
if (currentEffect.isSelected) {
if (state && selectedAndHighlightedProfile != null) {
selectedAndHighlightedProfile.Load(currentEffect);
} else if (selectedProfile != null) {
selectedProfile.Load(currentEffect);
} else {
currentEffect.previousSettings.Load(currentEffect);
}
if (currentEffect.highlighted) {
currentEffect.UpdateMaterialProperties();
} else {
currentEffect.SetHighlighted(true);
}
return;
} else if (!highlightOnHover) {
currentEffect.SetHighlighted(false);
return;
}
}
currentEffect.SetHighlighted(state);
}
public static Camera GetCamera() {
Camera raycastCamera = Camera.main;
if (raycastCamera == null) {
raycastCamera = FindObjectOfType<Camera>();
}
return raycastCamera;
}
void internal_DeselectAll() {
foreach (HighlightEffect hb in selectedObjects) {
if (hb != null && hb.gameObject != null) {
if (OnObjectUnSelected != null) {
if (!OnObjectUnSelected(hb.gameObject)) continue;
}
hb.RestorePreviousHighlightEffectSettings();
hb.isSelected = false;
hb.SetHighlighted(false);
}
}
selectedObjects.Clear();
}
public static void DeselectAll() {
foreach (HighlightEffect hb in selectedObjects) {
if (hb != null && hb.gameObject != null) {
hb.isSelected = false;
if (hb.highlighted && _instance != null) {
_instance.Highlight(false);
} else {
hb.SetHighlighted(false);
}
}
}
selectedObjects.Clear();
}
/// <summary>
/// Manually causes highlight manager to select an object
/// </summary>
public void SelectObject(Transform t) {
ToggleSelection(t, true);
}
/// <summary>
/// Manually causes highlight manager to toggle selection on an object
/// </summary>
public void ToggleObject(Transform t) {
ToggleSelection(t, false);
}
/// <summary>
/// Manually causes highlight manager to unselect an object
/// </summary>
public void UnselectObject(Transform t) {
if (t == null) return;
HighlightEffect hb = t.GetComponent<HighlightEffect>();
if (hb == null) return;
if (selectedObjects.Contains(hb)) {
if (OnObjectUnSelected != null) {
if (!OnObjectUnSelected(hb.gameObject)) return;
}
hb.isSelected = false;
hb.SetHighlighted(false);
selectedObjects.Remove(hb);
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: af4d46fd89b9543e5be2358ac0c9ced0
timeCreated: 1542876337
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,387 @@
using UnityEngine;
namespace HighlightPlus {
[CreateAssetMenu(menuName = "Highlight Plus Profile", fileName = "Highlight Plus Profile", order = 100)]
[HelpURL("https://www.dropbox.com/s/v9qgn68ydblqz8x/Documentation.pdf?dl=0")]
public class HighlightProfile : ScriptableObject {
[Tooltip("Different options to specify which objects are affected by this Highlight Effect component.")]
public TargetOptions effectGroup = TargetOptions.Children;
[Tooltip("The layer that contains the affected objects by this effect when effectGroup is set to LayerMask.")]
public LayerMask effectGroupLayer = -1;
[Tooltip("Only include objects whose names contains this text.")]
public string effectNameFilter;
[Tooltip("Combine meshes of all objects in this group affected by Highlight Effect reducing draw calls.")]
public bool combineMeshes;
[Tooltip("The alpha threshold for transparent cutout objects. Pixels with alpha below this value will be discarded.")]
[Range(0, 1)]
public float alphaCutOff;
[Tooltip("If back facing triangles are ignored.Backfaces triangles are not visible but you may set this property to false to force highlight effects to act on those triangles as well.")]
public bool cullBackFaces = true;
public bool depthClip;
[Tooltip("Normals handling option:\nPreserve original: use original mesh normals.\nSmooth: average normals to produce a smoother outline/glow mesh based effect.\nReorient: recomputes normals based on vertex direction to centroid.")]
public NormalsOption normalsOption;
public float fadeInDuration;
public float fadeOutDuration;
[Tooltip("Fades out effects based on distance to camera")]
public bool cameraDistanceFade;
[Tooltip("The closest distance particles can get to the camera before they fade from the cameras view.")]
public float cameraDistanceFadeNear;
[Tooltip("The farthest distance particles can get away from the camera before they fade from the cameras view.")]
public float cameraDistanceFadeFar = 1000;
[Tooltip("Keeps the outline/glow size unaffected by object distance.")]
public bool constantWidth = true;
[Range(0, 1)]
[Tooltip("Intensity of the overlay effect. A value of 0 disables the overlay completely.")]
public float overlay;
public OverlayMode overlayMode = OverlayMode.WhenHighlighted;
[ColorUsage(true, true)] public Color overlayColor = Color.yellow;
public float overlayAnimationSpeed = 1f;
[Range(0, 1)]
public float overlayMinIntensity = 0.5f;
[Range(0, 1)]
[Tooltip("Controls the blending or mix of the overlay color with the natural colors of the object.")]
public float overlayBlending = 1.0f;
[Tooltip("Optional overlay texture.")]
public Texture2D overlayTexture;
public TextureUVSpace overlayTextureUVSpace;
public float overlayTextureScale = 1f;
[Range(0, 1)]
[Tooltip("Intensity of the outline. A value of 0 disables the outline completely.")]
public float outline = 1f;
[ColorUsage(true, true)] public Color outlineColor = Color.black;
public ColorStyle outlineColorStyle = ColorStyle.SingleColor;
[GradientUsage(hdr: true, ColorSpace.Linear)] public Gradient outlineGradient;
public bool outlineGradientInLocalSpace;
public float outlineWidth = 0.45f;
public QualityLevel outlineQuality = QualityLevel.High;
[Range(1, 8)]
[Tooltip("Reduces the quality of the outline but improves performance a bit.")]
public int outlineDownsampling = 2;
public bool outlineOptimalBlit = true;
public Visibility outlineVisibility = Visibility.Normal;
[Tooltip("If enabled, this object won't combine the outline with other objects.")]
public bool outlineIndependent;
[Range(0, 5)]
[Tooltip("The intensity of the outer glow effect. A value of 0 disables the glow completely.")]
public float glow;
public float glowWidth = 0.4f;
public QualityLevel glowQuality = QualityLevel.High;
[Range(1, 8)]
[Tooltip("Reduces the quality of the glow but improves performance a bit.")]
public int glowDownsampling = 2;
[ColorUsage(true, true)] public Color glowHQColor = new Color (0.64f, 1f, 0f, 1f);
[Tooltip("When enabled, outer glow renders with dithering. When disabled, glow appears as a solid color.")]
public bool glowDithering = true;
public bool glowOptimalBlit = true;
[Tooltip("Seed for the dithering effect")]
public float glowMagicNumber1 = 0.75f;
[Tooltip("Another seed for the dithering effect that combines with first seed to create different patterns")]
public float glowMagicNumber2 = 0.5f;
public float glowAnimationSpeed = 1f;
public Visibility glowVisibility = Visibility.Normal;
public GlowBlendMode glowBlendMode = GlowBlendMode.Additive;
[Tooltip("Blends glow passes one after another. If this option is disabled, glow passes won't overlap (in this case, make sure the glow pass 1 has a smaller offset than pass 2, etc.)")]
public bool glowBlendPasses = true;
public GlowPassData[] glowPasses;
[Tooltip("If enabled, glow effect will not use a stencil mask. This can be used to render the glow effect alone.")]
public bool glowIgnoreMask;
[Range(0, 5f)]
[Tooltip("The intensity of the inner glow effect. A value of 0 disables the glow completely.")]
public float innerGlow;
[Range(0, 2)]
public float innerGlowWidth = 1f;
[ColorUsage(true, true)] public Color innerGlowColor = Color.white;
public Visibility innerGlowVisibility = Visibility.Normal;
[Tooltip("Enables the targetFX effect. This effect draws an animated sprite over the object.")]
public bool targetFX;
public Texture2D targetFXTexture;
[ColorUsage(true, true)] public Color targetFXColor = Color.white;
public float targetFXRotationSpeed = 50f;
public float targetFXInitialScale = 4f;
public float targetFXEndScale = 1.5f;
[Tooltip("Makes target scale relative to object renderer bounds.")]
public bool targetFXScaleToRenderBounds;
[Tooltip("Places target FX sprite at the bottom of the highlighted object.")]
public bool targetFXAlignToGround;
[Tooltip("Max distance from the center of the highlighted object to the ground.")]
public float targetFXGroundMaxDistance = 15f;
public LayerMask targetFXGroundLayerMask = -1;
[Tooltip("Fade out effect with altitude")]
public float targetFXFadePower = 32;
public float targetFXTransitionDuration = 0.5f;
public float targetFXStayDuration = 1.5f;
public Visibility targetFXVisibility = Visibility.AlwaysOnTop;
[Tooltip("See-through mode for this Highlight Effect component.")]
public SeeThroughMode seeThrough = SeeThroughMode.Never;
[Tooltip("This mask setting let you specify which objects will be considered as occluders and cause the see-through effect for this Highlight Effect component. For example, you assign your walls to a different layer and specify that layer here, so only walls and not other objects, like ground or ceiling, will trigger the see-through effect.")]
public LayerMask seeThroughOccluderMask = -1;
[Tooltip("Uses stencil buffers to ensure pixel-accurate occlusion test. If this option is disabled, only physics raycasting is used to test for occlusion.")]
public bool seeThroughOccluderMaskAccurate;
[Tooltip("A multiplier for the occluder volume size which can be used to reduce the actual size of occluders when Highlight Effect checks if they're occluding this object.")]
[Range(0.01f, 0.9f)] public float seeThroughOccluderThreshold = 0.4f;
[Tooltip("The interval of time between occlusion tests.")]
public float seeThroughOccluderCheckInterval = 1f;
[Tooltip("If enabled, occlusion test is performed for each children element. If disabled, the bounds of all children is combined and a single occlusion test is performed for the combined bounds.")]
public bool seeThroughOccluderCheckIndividualObjects;
[Tooltip("Shows the see-through effect only if the occluder if at this 'offset' distance from the object.")]
public float seeThroughDepthOffset;
[Tooltip("Hides the see-through effect if the occluder is further than this distance from the object (0 = infinite)")]
public float seeThroughMaxDepth;
[Range(0, 5f)] public float seeThroughIntensity = 0.8f;
[Range(0, 1)] public float seeThroughTintAlpha = 0.5f;
public Color seeThroughTintColor = Color.red;
[Range(0, 1)] public float seeThroughNoise = 1f;
[Range(0, 1)] public float seeThroughBorder;
public Color seeThroughBorderColor = Color.black;
public float seeThroughBorderWidth = 0.45f;
[Tooltip("Only display the border instead of the full see-through effect.")]
public bool seeThroughBorderOnly;
[Tooltip("Renders see-through effect on overlapping objects in a sequence that's relative to the distance to the camera")]
public bool seeThroughOrdered = true;
[Tooltip("Optional see-through mask effect texture.")]
public Texture2D seeThroughTexture;
public TextureUVSpace seeThroughTextureUVSpace;
public float seeThroughTextureScale = 1f;
[Range(0, 1)] public float hitFxInitialIntensity;
public HitFxMode hitFxMode = HitFxMode.Overlay;
public float hitFxFadeOutDuration = 0.25f;
[ColorUsage(true, true)] public Color hitFxColor = Color.white;
public float hitFxRadius = 0.5f;
public void Load(HighlightEffect effect) {
effect.effectGroup = effectGroup;
effect.effectGroupLayer = effectGroupLayer;
effect.effectNameFilter = effectNameFilter;
effect.combineMeshes = combineMeshes;
effect.alphaCutOff = alphaCutOff;
effect.cullBackFaces = cullBackFaces;
effect.depthClip = depthClip;
effect.normalsOption = normalsOption;
effect.fadeInDuration = fadeInDuration;
effect.fadeOutDuration = fadeOutDuration;
effect.cameraDistanceFade = cameraDistanceFade;
effect.cameraDistanceFadeFar = cameraDistanceFadeFar;
effect.cameraDistanceFadeNear = cameraDistanceFadeNear;
effect.constantWidth = constantWidth;
effect.overlay = overlay;
effect.overlayMode = overlayMode;
effect.overlayColor = overlayColor;
effect.overlayAnimationSpeed = overlayAnimationSpeed;
effect.overlayMinIntensity = overlayMinIntensity;
effect.overlayBlending = overlayBlending;
effect.overlayTexture = overlayTexture;
effect.overlayTextureUVSpace = overlayTextureUVSpace;
effect.overlayTextureScale = overlayTextureScale;
effect.outline = outline;
effect.outlineColor = outlineColor;
effect.outlineColorStyle = outlineColorStyle;
effect.outlineGradient = outlineGradient;
effect.outlineGradientInLocalSpace = outlineGradientInLocalSpace;
effect.outlineWidth = outlineWidth;
effect.outlineQuality = outlineQuality;
effect.outlineOptimalBlit = outlineOptimalBlit;
effect.outlineDownsampling = outlineDownsampling;
effect.outlineVisibility = outlineVisibility;
effect.outlineIndependent = outlineIndependent;
effect.glow = glow;
effect.glowWidth = glowWidth;
effect.glowQuality = glowQuality;
effect.glowOptimalBlit = glowOptimalBlit;
effect.glowDownsampling = glowDownsampling;
effect.glowHQColor = glowHQColor;
effect.glowDithering = glowDithering;
effect.glowMagicNumber1 = glowMagicNumber1;
effect.glowMagicNumber2 = glowMagicNumber2;
effect.glowAnimationSpeed = glowAnimationSpeed;
effect.glowVisibility = glowVisibility;
effect.glowBlendMode = glowBlendMode;
effect.glowBlendPasses = glowBlendPasses;
effect.glowPasses = GetGlowPassesCopy(glowPasses);
effect.glowIgnoreMask = glowIgnoreMask;
effect.innerGlow = innerGlow;
effect.innerGlowWidth = innerGlowWidth;
effect.innerGlowColor = innerGlowColor;
effect.innerGlowVisibility = innerGlowVisibility;
effect.targetFX = targetFX;
effect.targetFXColor = targetFXColor;
effect.targetFXInitialScale = targetFXInitialScale;
effect.targetFXEndScale = targetFXEndScale;
effect.targetFXScaleToRenderBounds = targetFXScaleToRenderBounds;
effect.targetFXAlignToGround = targetFXAlignToGround;
effect.targetFXGroundMaxDistance = targetFXGroundMaxDistance;
effect.targetFXGroundLayerMask = targetFXGroundLayerMask;
effect.targetFXFadePower = targetFXFadePower;
effect.targetFXRotationSpeed = targetFXRotationSpeed;
effect.targetFXStayDuration = targetFXStayDuration;
effect.targetFXTexture = targetFXTexture;
effect.targetFXTransitionDuration = targetFXTransitionDuration;
effect.targetFXVisibility = targetFXVisibility;
effect.seeThrough = seeThrough;
effect.seeThroughOccluderMask = seeThroughOccluderMask;
effect.seeThroughOccluderMaskAccurate = seeThroughOccluderMaskAccurate;
effect.seeThroughOccluderThreshold = seeThroughOccluderThreshold;
effect.seeThroughOccluderCheckInterval = seeThroughOccluderCheckInterval;
effect.seeThroughOccluderCheckIndividualObjects = seeThroughOccluderCheckIndividualObjects;
effect.seeThroughIntensity = seeThroughIntensity;
effect.seeThroughTintAlpha = seeThroughTintAlpha;
effect.seeThroughTintColor = seeThroughTintColor;
effect.seeThroughNoise = seeThroughNoise;
effect.seeThroughBorder = seeThroughBorder;
effect.seeThroughBorderColor = seeThroughBorderColor;
effect.seeThroughBorderWidth = seeThroughBorderWidth;
effect.seeThroughBorderOnly = seeThroughBorderOnly;
effect.seeThroughDepthOffset = seeThroughDepthOffset;
effect.seeThroughMaxDepth = seeThroughMaxDepth;
effect.seeThroughOrdered = seeThroughOrdered;
effect.seeThroughTexture = seeThroughTexture;
effect.seeThroughTextureScale = seeThroughTextureScale;
effect.seeThroughTextureUVSpace = seeThroughTextureUVSpace;
effect.hitFxInitialIntensity = hitFxInitialIntensity;
effect.hitFxMode = hitFxMode;
effect.hitFxFadeOutDuration = hitFxFadeOutDuration;
effect.hitFxColor = hitFxColor;
effect.hitFxRadius = hitFxRadius;
effect.UpdateMaterialProperties();
}
public void Save(HighlightEffect effect) {
effectGroup = effect.effectGroup;
effectGroupLayer = effect.effectGroupLayer;
effectNameFilter = effect.effectNameFilter;
combineMeshes = effect.combineMeshes;
alphaCutOff = effect.alphaCutOff;
cullBackFaces = effect.cullBackFaces;
depthClip = effect.depthClip;
normalsOption = effect.normalsOption;
fadeInDuration = effect.fadeInDuration;
fadeOutDuration = effect.fadeOutDuration;
cameraDistanceFade = effect.cameraDistanceFade;
cameraDistanceFadeFar = effect.cameraDistanceFadeFar;
cameraDistanceFadeNear = effect.cameraDistanceFadeNear;
constantWidth = effect.constantWidth;
overlay = effect.overlay;
overlayMode = effect.overlayMode;
overlayColor = effect.overlayColor;
overlayAnimationSpeed = effect.overlayAnimationSpeed;
overlayMinIntensity = effect.overlayMinIntensity;
overlayBlending = effect.overlayBlending;
overlayTexture = effect.overlayTexture;
overlayTextureUVSpace = effect.overlayTextureUVSpace;
overlayTextureScale = effect.overlayTextureScale;
outline = effect.outline;
outlineColor = effect.outlineColor;
outlineColorStyle = effect.outlineColorStyle;
outlineGradient = effect.outlineGradient;
outlineGradientInLocalSpace = effect.outlineGradientInLocalSpace;
outlineWidth = effect.outlineWidth;
outlineQuality = effect.outlineQuality;
outlineDownsampling = effect.outlineDownsampling;
outlineVisibility = effect.outlineVisibility;
outlineIndependent = effect.outlineIndependent;
outlineOptimalBlit = effect.outlineOptimalBlit;
glow = effect.glow;
glowWidth = effect.glowWidth;
glowQuality = effect.glowQuality;
glowOptimalBlit = effect.glowOptimalBlit;
glowDownsampling = effect.glowDownsampling;
glowHQColor = effect.glowHQColor;
glowDithering = effect.glowDithering;
glowMagicNumber1 = effect.glowMagicNumber1;
glowMagicNumber2 = effect.glowMagicNumber2;
glowAnimationSpeed = effect.glowAnimationSpeed;
glowVisibility = effect.glowVisibility;
glowBlendMode = effect.glowBlendMode;
glowBlendPasses = effect.glowBlendPasses;
glowPasses = GetGlowPassesCopy(effect.glowPasses);
glowIgnoreMask = effect.glowIgnoreMask;
innerGlow = effect.innerGlow;
innerGlowWidth = effect.innerGlowWidth;
innerGlowColor = effect.innerGlowColor;
innerGlowVisibility = effect.innerGlowVisibility;
targetFX = effect.targetFX;
targetFXColor = effect.targetFXColor;
targetFXInitialScale = effect.targetFXInitialScale;
targetFXEndScale = effect.targetFXEndScale;
targetFXScaleToRenderBounds = effect.targetFXScaleToRenderBounds;
targetFXAlignToGround = effect.targetFXAlignToGround;
targetFXGroundMaxDistance = effect.targetFXGroundMaxDistance;
targetFXGroundLayerMask = effect.targetFXGroundLayerMask;
targetFXFadePower = effect.targetFXFadePower;
targetFXRotationSpeed = effect.targetFXRotationSpeed;
targetFXStayDuration = effect.targetFXStayDuration;
targetFXTexture = effect.targetFXTexture;
targetFXTransitionDuration = effect.targetFXTransitionDuration;
targetFXVisibility = effect.targetFXVisibility;
seeThrough = effect.seeThrough;
seeThroughOccluderMask = effect.seeThroughOccluderMask;
seeThroughOccluderMaskAccurate = effect.seeThroughOccluderMaskAccurate;
seeThroughOccluderThreshold = effect.seeThroughOccluderThreshold;
seeThroughOccluderCheckInterval = effect.seeThroughOccluderCheckInterval;
seeThroughOccluderCheckIndividualObjects = effect.seeThroughOccluderCheckIndividualObjects;
seeThroughIntensity = effect.seeThroughIntensity;
seeThroughTintAlpha = effect.seeThroughTintAlpha;
seeThroughTintColor = effect.seeThroughTintColor;
seeThroughNoise = effect.seeThroughNoise;
seeThroughBorder = effect.seeThroughBorder;
seeThroughBorderColor = effect.seeThroughBorderColor;
seeThroughBorderWidth = effect.seeThroughBorderWidth;
seeThroughDepthOffset = effect.seeThroughDepthOffset;
seeThroughBorderOnly = effect.seeThroughBorderOnly;
seeThroughMaxDepth = effect.seeThroughMaxDepth;
seeThroughOrdered = effect.seeThroughOrdered;
seeThroughTexture = effect.seeThroughTexture;
seeThroughTextureScale = effect.seeThroughTextureScale;
seeThroughTextureUVSpace = effect.seeThroughTextureUVSpace;
hitFxInitialIntensity = effect.hitFxInitialIntensity;
hitFxMode = effect.hitFxMode;
hitFxFadeOutDuration = effect.hitFxFadeOutDuration;
hitFxColor = effect.hitFxColor;
hitFxRadius = effect.hitFxRadius;
}
GlowPassData[] GetGlowPassesCopy(GlowPassData[] glowPasses) {
if (glowPasses == null) {
return new GlowPassData[0];
}
GlowPassData[] pd = new GlowPassData[glowPasses.Length];
for (int k = 0; k < glowPasses.Length; k++) {
pd[k].alpha = glowPasses[k].alpha;
pd[k].color = glowPasses[k].color;
pd[k].offset = glowPasses[k].offset;
}
return pd;
}
public void OnValidate() {
seeThroughDepthOffset = Mathf.Max(0, seeThroughDepthOffset);
seeThroughMaxDepth = Mathf.Max(0, seeThroughMaxDepth);
seeThroughBorderWidth = Mathf.Max(0, seeThroughBorderWidth);
targetFXFadePower = Mathf.Max(0, targetFXFadePower);
cameraDistanceFadeNear = Mathf.Max(0, cameraDistanceFadeNear);
cameraDistanceFadeFar = Mathf.Max(0, cameraDistanceFadeFar);
if (glowPasses == null || glowPasses.Length == 0) {
glowPasses = new GlowPassData[4];
glowPasses[0] = new GlowPassData() { offset = 4, alpha = 0.1f, color = new Color(0.64f, 1f, 0f, 1f) };
glowPasses[1] = new GlowPassData() { offset = 3, alpha = 0.2f, color = new Color(0.64f, 1f, 0f, 1f) };
glowPasses[2] = new GlowPassData() { offset = 2, alpha = 0.3f, color = new Color(0.64f, 1f, 0f, 1f) };
glowPasses[3] = new GlowPassData() { offset = 1, alpha = 0.4f, color = new Color(0.64f, 1f, 0f, 1f) };
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8e9253636bf2648bd813257f451f8486
timeCreated: 1549831900
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,78 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace HighlightPlus {
public struct MeshData {
public Renderer renderer;
public int subMeshCount;
}
public enum OccluderMode {
BlocksSeeThrough,
TriggersSeeThrough
}
public enum DetectionMethod {
Stencil = 0,
RayCast = 1
}
[ExecuteInEditMode]
public class HighlightSeeThroughOccluder : MonoBehaviour {
public OccluderMode mode = OccluderMode.BlocksSeeThrough;
public DetectionMethod detectionMethod = DetectionMethod.Stencil;
[NonSerialized]
public MeshData[] meshData;
List<Renderer> rr;
void OnEnable () {
if (gameObject.activeInHierarchy) {
Init();
}
}
void Init() {
if (detectionMethod == DetectionMethod.RayCast) {
HighlightEffect.RegisterOccluder(this);
return;
}
if (rr == null) {
rr = new List<Renderer>();
} else {
rr.Clear();
}
GetComponentsInChildren(rr);
int rrCount = rr.Count;
meshData = new MeshData[rrCount];
for (int k = 0; k < rrCount; k++) {
meshData[k].renderer = rr[k];
meshData[k].subMeshCount = 1;
if (rr[k] is MeshRenderer) {
MeshFilter mf = rr[k].GetComponent<MeshFilter>();
if (mf != null && mf.sharedMesh != null) {
meshData[k].subMeshCount = mf.sharedMesh.subMeshCount;
}
} else if (rr[k] is SkinnedMeshRenderer) {
SkinnedMeshRenderer smr = (SkinnedMeshRenderer)rr[k];
meshData[k].subMeshCount = smr.sharedMesh.subMeshCount;
}
}
if (rrCount > 0) {
HighlightEffect.RegisterOccluder(this);
}
}
void OnDisable () {
HighlightEffect.UnregisterOccluder(this);
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8dd965ceab19c4729a9dabd8aeb2972a
timeCreated: 1542876337
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,409 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
namespace HighlightPlus {
public enum TriggerMode {
ColliderEventsOnlyOnThisObject = 0,
RaycastOnThisObjectAndChildren = 1,
Volume = 2
}
public enum RayCastSource {
MousePosition = 0,
CameraDirection = 1
}
[RequireComponent(typeof(HighlightEffect))]
[ExecuteInEditMode]
[HelpURL("https://kronnect.com/guides/highlight-plus-introduction/")]
public class HighlightTrigger : MonoBehaviour {
[Tooltip("Enables highlight when pointer is over this object.")]
public bool highlightOnHover = true;
[Tooltip("Used to trigger automatic highlighting including children objects.")]
#if ENABLE_INPUT_SYSTEM
public TriggerMode triggerMode = TriggerMode.RaycastOnThisObjectAndChildren;
#else
public TriggerMode triggerMode = TriggerMode.ColliderEventsOnlyOnThisObject;
#endif
public Camera raycastCamera;
public RayCastSource raycastSource = RayCastSource.MousePosition;
public LayerMask raycastLayerMask = -1;
[Tooltip("Minimum distance for target.")]
public float minDistance;
[Tooltip("Maximum distance for target. 0 = infinity")]
public float maxDistance;
[Tooltip("Blocks interaction if pointer is over an UI element")]
public bool respectUI = true;
public LayerMask volumeLayerMask;
const int MAX_RAYCAST_HITS = 100;
[Tooltip("If the object will be selected by clicking with mouse or tapping on it.")]
public bool selectOnClick;
[Tooltip("Profile to use when object is selected by clicking on it.")]
public HighlightProfile selectedProfile;
[Tooltip("Profile to use whtn object is selected and highlighted.")]
public HighlightProfile selectedAndHighlightedProfile;
[Tooltip("Automatically deselects any other selected object prior selecting this one")]
public bool singleSelection;
[Tooltip("Toggles selection on/off when clicking object")]
public bool toggle;
[Tooltip("Keeps current selection when clicking outside of any selectable object")]
public bool keepSelection = true;
[NonSerialized] public Collider[] colliders;
Collider currentCollider;
static RaycastHit[] hits;
HighlightEffect hb;
public HighlightEffect highlightEffect { get { return hb; } }
public event OnObjectSelectionEvent OnObjectSelected;
public event OnObjectSelectionEvent OnObjectUnSelected;
public event OnObjectHighlightEvent OnObjectHighlightStart;
public event OnObjectHighlightEvent OnObjectHighlightEnd;
TriggerMode currentTriggerMode;
[RuntimeInitializeOnLoadMethod]
void DomainReloadDisabledSupport() {
HighlightManager.selectedObjects.Clear();
}
void OnEnable() {
Init();
}
private void OnValidate() {
if (currentTriggerMode != triggerMode) {
currentTriggerMode = triggerMode;
if (currentTriggerMode == TriggerMode.RaycastOnThisObjectAndChildren) {
colliders = GetComponentsInChildren<Collider>();
if (hits == null || hits.Length != MAX_RAYCAST_HITS) {
hits = new RaycastHit[MAX_RAYCAST_HITS];
}
if (Application.isPlaying) {
StopAllCoroutines();
if (gameObject.activeInHierarchy) {
StartCoroutine(DoRayCast());
}
}
}
}
}
public void Init() {
if (raycastCamera == null) {
raycastCamera = HighlightManager.GetCamera();
}
currentTriggerMode = triggerMode;
if (triggerMode == TriggerMode.RaycastOnThisObjectAndChildren) {
colliders = GetComponentsInChildren<Collider>();
}
if (hb == null) {
hb = GetComponent<HighlightEffect>();
}
InputProxy.Init();
}
void Start() {
if (triggerMode == TriggerMode.RaycastOnThisObjectAndChildren) {
if (raycastCamera == null) {
raycastCamera = HighlightManager.GetCamera();
if (raycastCamera == null) {
Debug.LogError("Highlight Trigger on " + gameObject.name + ": no camera found!");
}
}
if (colliders != null && colliders.Length > 0) {
hits = new RaycastHit[MAX_RAYCAST_HITS];
if (Application.isPlaying) {
StopAllCoroutines();
StartCoroutine(DoRayCast());
}
}
} else {
Collider collider = GetComponent<Collider>();
if (collider == null) {
if (GetComponent<MeshFilter>() != null) {
gameObject.AddComponent<MeshCollider>();
}
}
}
}
IEnumerator DoRayCast() {
yield return null;
WaitForEndOfFrame w = new WaitForEndOfFrame();
while (triggerMode == TriggerMode.RaycastOnThisObjectAndChildren) {
if (raycastCamera == null) {
yield return null;
continue;
}
int hitCount;
bool hit = false;
#if ENABLE_INPUT_SYSTEM
if (respectUI) {
EventSystem es = EventSystem.current;
if (es == null) {
es = CreateEventSystem();
}
List<RaycastResult> raycastResults = new List<RaycastResult>();
PointerEventData eventData = new PointerEventData(es);
Vector3 cameraPos = raycastCamera.transform.position;
if (raycastSource == RayCastSource.MousePosition) {
eventData.position = InputProxy.mousePosition;
} else {
eventData.position = new Vector2(raycastCamera.pixelWidth * 0.5f, raycastCamera.pixelHeight * 0.5f);
}
es.RaycastAll(eventData, raycastResults);
hitCount = raycastResults.Count;
// check UI blocker
bool blocked = false;
for (int k = 0; k < hitCount; k++) {
RaycastResult rr = raycastResults[k];
if (rr.module is UnityEngine.UI.GraphicRaycaster) {
blocked = true;
break;
}
}
if (blocked) {
yield return null;
continue;
}
// look for our gameobject
for (int k = 0; k < hitCount; k++) {
RaycastResult rr = raycastResults[k];
float distance = Vector3.Distance(rr.worldPosition, cameraPos);
if (distance < minDistance || (maxDistance > 0 && distance > maxDistance)) continue;
GameObject theGameObject = rr.gameObject;
for (int c = 0; c < colliders.Length; c++) {
if (colliders[c].gameObject == theGameObject) {
Collider theCollider = colliders[c];
hit = true;
if (selectOnClick && InputProxy.GetMouseButtonDown(0)) {
ToggleSelection();
break;
} else if (theCollider != currentCollider) {
SwitchCollider(theCollider);
k = hitCount;
break;
}
}
}
}
}
// if not blocked by UI and no hit found, fallback to raycast (required if no PhysicsRaycaster is present on the camera)
#endif
Ray ray;
if (raycastSource == RayCastSource.MousePosition) {
#if !ENABLE_INPUT_SYSTEM
if (!CanInteract()) {
yield return null;
continue;
}
#endif
ray = raycastCamera.ScreenPointToRay(InputProxy.mousePosition);
} else {
ray = new Ray(raycastCamera.transform.position, raycastCamera.transform.forward);
}
if (maxDistance > 0) {
hitCount = Physics.RaycastNonAlloc(ray, hits, maxDistance, raycastLayerMask);
} else {
hitCount = Physics.RaycastNonAlloc(ray, hits, float.MaxValue, raycastLayerMask);
}
bool isMouseButonDown = InputProxy.GetMouseButtonDown(0);
for (int k = 0; k < hitCount; k++) {
if (Vector3.Distance(hits[k].point, ray.origin) < minDistance) continue;
Collider theCollider = hits[k].collider;
for (int c = 0; c < colliders.Length; c++) {
if (colliders[c] == theCollider) {
hit = true;
if (selectOnClick && isMouseButonDown) {
ToggleSelection();
break;
} else if (theCollider != currentCollider) {
SwitchCollider(theCollider);
k = hitCount;
break;
}
}
}
}
if (!hit && currentCollider != null) {
SwitchCollider(null);
}
if (selectOnClick && isMouseButonDown && !keepSelection && !hit) {
yield return w; // wait for other potential triggers to act
if (HighlightManager.lastTriggerFrame < Time.frameCount) {
HighlightManager.DeselectAll();
}
}
yield return null;
}
}
#if ENABLE_INPUT_SYSTEM
EventSystem CreateEventSystem() {
GameObject eo = new GameObject("Event System created by Highlight Plus", typeof(EventSystem), typeof(UnityEngine.InputSystem.UI.InputSystemUIInputModule));
return eo.GetComponent<EventSystem>();
}
#endif
void SwitchCollider(Collider newCollider) {
if (!highlightOnHover && !hb.isSelected) return;
currentCollider = newCollider;
if (currentCollider != null) {
Highlight(true);
} else {
Highlight(false);
}
}
bool CanInteract() {
if (!respectUI) return true;
EventSystem es = EventSystem.current;
if (es == null) return true;
if (Application.isMobilePlatform && InputProxy.touchCount > 0 && es.IsPointerOverGameObject(InputProxy.GetFingerIdFromTouch(0))) {
return false;
} else if (es.IsPointerOverGameObject(-1))
return false;
return true;
}
void OnMouseDown() {
if (isActiveAndEnabled && triggerMode == TriggerMode.ColliderEventsOnlyOnThisObject) {
if (!CanInteract()) return;
if (selectOnClick && InputProxy.GetMouseButtonDown(0)) {
ToggleSelection();
return;
}
Highlight(true);
}
}
void OnMouseEnter() {
if (isActiveAndEnabled && triggerMode == TriggerMode.ColliderEventsOnlyOnThisObject) {
if (!CanInteract()) return;
Highlight(true);
}
}
void OnMouseExit() {
if (isActiveAndEnabled && triggerMode == TriggerMode.ColliderEventsOnlyOnThisObject) {
if (!CanInteract()) return;
Highlight(false);
}
}
void Highlight(bool state) {
if (state) {
if (!hb.highlighted) {
if (OnObjectHighlightStart != null && hb.target != null) {
if (!OnObjectHighlightStart(hb.target.gameObject)) return;
}
}
} else {
if (hb.highlighted) {
if (OnObjectHighlightEnd != null && hb.target != null) {
OnObjectHighlightEnd(hb.target.gameObject);
}
}
}
if (selectOnClick || hb.isSelected) {
if (hb.isSelected) {
if (state && selectedAndHighlightedProfile != null) {
selectedAndHighlightedProfile.Load(hb);
} else if (selectedProfile != null) {
selectedProfile.Load(hb);
} else {
hb.previousSettings.Load(hb);
}
if (hb.highlighted) {
hb.UpdateMaterialProperties();
} else {
hb.SetHighlighted(true);
}
return;
} else if (!highlightOnHover) {
hb.SetHighlighted(false);
return;
}
}
hb.SetHighlighted(state);
}
void ToggleSelection() {
HighlightManager.lastTriggerFrame = Time.frameCount;
bool newState = toggle ? !hb.isSelected : true;
if (newState) {
if (OnObjectSelected != null && !OnObjectSelected(gameObject)) return;
} else {
if (OnObjectUnSelected != null && !OnObjectUnSelected(gameObject)) return;
}
if (singleSelection && newState) {
HighlightManager.DeselectAll();
}
hb.isSelected = newState;
if (newState && !HighlightManager.selectedObjects.Contains(hb)) {
HighlightManager.selectedObjects.Add(hb);
} else if (!newState && HighlightManager.selectedObjects.Contains(hb)) {
HighlightManager.selectedObjects.Remove(hb);
}
if (hb.isSelected) {
if (hb.previousSettings == null) {
hb.previousSettings = ScriptableObject.CreateInstance<HighlightProfile>();
}
hb.previousSettings.Save(hb);
} else {
hb.RestorePreviousHighlightEffectSettings();
}
Highlight(true);
}
public void OnTriggerEnter(Collider other) {
if (triggerMode == TriggerMode.Volume) {
if ((volumeLayerMask & (1 << other.gameObject.layer)) != 0) {
Highlight(true);
}
}
}
public void OnTriggerExit(Collider other) {
if (triggerMode == TriggerMode.Volume) {
if ((volumeLayerMask & (1 << other.gameObject.layer)) != 0) {
Highlight(false);
}
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5009cbb7e54994bb586cde7a70f34e6b
timeCreated: 1542876337
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,90 @@
using UnityEngine;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using EnhancedTouch = UnityEngine.InputSystem.EnhancedTouch;
#endif
namespace HighlightPlus {
public static class InputProxy {
#if ENABLE_INPUT_SYSTEM
static Vector3 lastPointerPosition;
public static void Init() {
if (!EnhancedTouch.EnhancedTouchSupport.enabled) {
EnhancedTouch.EnhancedTouchSupport.Enable();
}
}
public static Vector3 mousePosition {
get {
if (touchCount > 0) {
lastPointerPosition = EnhancedTouch.Touch.activeTouches[0].screenPosition;
} else {
Mouse m = Mouse.current;
if (m != null) {
lastPointerPosition = m.position.ReadValue();
}
}
return lastPointerPosition;
}
}
public static bool GetMouseButtonDown(int buttonIndex) {
if (touchCount > 0) {
return EnhancedTouch.Touch.activeTouches[0].phase == UnityEngine.InputSystem.TouchPhase.Began;
} else {
Mouse m = Mouse.current;
if (m == null) return false;
switch (buttonIndex) {
case 1: return m.rightButton.wasPressedThisFrame;
case 2: return m.middleButton.wasPressedThisFrame;
default: return m.leftButton.wasPressedThisFrame;
}
}
}
public static int touchCount { get { return EnhancedTouch.Touch.activeTouches.Count; } }
public static int GetFingerIdFromTouch(int touchIndex) {
EnhancedTouch.Touch touch = EnhancedTouch.Touch.activeTouches[touchIndex];
return touch.finger.index;
}
public static bool GetKeyDown(string name) {
return ((KeyControl)Keyboard.current[name]).wasPressedThisFrame;
}
#else
public static void Init() {}
public static Vector3 mousePosition {
get {
return Input.mousePosition;
}
}
public static bool GetMouseButtonDown(int buttonIndex) {
return Input.GetMouseButtonDown(buttonIndex);
}
public static int touchCount {
get { return Input.touchCount; }
}
public static int GetFingerIdFromTouch(int touchIndex) {
return Input.GetTouch(touchIndex).fingerId;
}
public static bool GetKeyDown(string name) {
return Input.GetKeyDown(name);
}
#endif
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dc62c86f3459d4fc29db51cfe5ecb977
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,84 @@
using UnityEngine;
namespace HighlightPlus {
public static class ShaderParams {
// general uniforms
public static int Cull = Shader.PropertyToID("_Cull");
public static int BlurScale = Shader.PropertyToID("_BlurScale");
public static int Speed = Shader.PropertyToID("_Speed");
public static int ConstantWidth = Shader.PropertyToID("_ConstantWidth");
public static int CutOff = Shader.PropertyToID("_CutOff");
public static int ZTest = Shader.PropertyToID("_ZTest");
public static int Flip = Shader.PropertyToID("_Flip");
public static int Debug = Shader.PropertyToID("_Debug");
public static int Color = Shader.PropertyToID("_Color");
public static int MainTex = Shader.PropertyToID("_MainTex");
public static int BlendSrc = Shader.PropertyToID("_BlendSrc");
public static int BlendDst = Shader.PropertyToID("_BlendDst");
public static int FadeFactor = Shader.PropertyToID("_HP_Fade");
// outline uniforms
public static int OutlineWidth = Shader.PropertyToID("_OutlineWidth");
public static int OutlineZTest = Shader.PropertyToID("_OutlineZTest");
public static int OutlineDirection = Shader.PropertyToID("_OutlineDirection");
public static int OutlineColor = Shader.PropertyToID("_OutlineColor");
public static int OutlineVertexWidth = Shader.PropertyToID("_OutlineVertexWidth");
public static int OutlineGradientTex = Shader.PropertyToID("_OutlineGradientTex");
public static int OutlineVertexData = Shader.PropertyToID("_OutlineVertexData");
// glow uniforms
public static int GlowZTest = Shader.PropertyToID("_GlowZTest");
public static int GlowStencilComp = Shader.PropertyToID("_GlowStencilComp");
public static int GlowStencilOp = Shader.PropertyToID("_GlowStencilOp");
public static int GlowDirection = Shader.PropertyToID("_GlowDirection");
public static int Glow = Shader.PropertyToID("_Glow");
public static int GlowColor = Shader.PropertyToID("_GlowColor");
public static int Glow2 = Shader.PropertyToID("_Glow2");
// see-through uniforms
public static int SeeThrough = Shader.PropertyToID("_SeeThrough");
public static int SeeThroughNoise = Shader.PropertyToID("_SeeThroughNoise");
public static int SeeThroughBorderWidth = Shader.PropertyToID("_SeeThroughBorderWidth");
public static int SeeThroughBorderConstantWidth = Shader.PropertyToID("_SeeThroughBorderConstantWidth");
public static int SeeThroughTintColor = Shader.PropertyToID("_SeeThroughTintColor");
public static int SeeThroughBorderColor = Shader.PropertyToID("_SeeThroughBorderColor");
public static int SeeThroughStencilRef = Shader.PropertyToID("_SeeThroughStencilRef");
public static int SeeThroughStencilComp = Shader.PropertyToID("_SeeThroughStencilComp");
public static int SeeThroughStencilPassOp = Shader.PropertyToID("_SeeThroughStencilPassOp");
public static int SeeThroughDepthOffset = Shader.PropertyToID("_SeeThroughDepthOffset");
public static int SeeThroughMaxDepth = Shader.PropertyToID("_SeeThroughMaxDepth");
public static int SeeThroughOrdered = Shader.PropertyToID("_SeeThroughOrdered");
public static int SeeThroughTexture = Shader.PropertyToID("_SeeThroughTexture");
public static int SeeThroughTextureScale = Shader.PropertyToID("_SeeThroughTextureScale");
// inner glow uniforms
public static int InnerGlowWidth = Shader.PropertyToID("_InnerGlowWidth");
public static int InnerGlowZTest = Shader.PropertyToID("_InnerGlowZTest");
public static int InnerGlowColor = Shader.PropertyToID("_InnerGlowColor");
// overlay uniforms
public static int OverlayData = Shader.PropertyToID("_OverlayData");
public static int OverlayBackColor = Shader.PropertyToID("_OverlayBackColor");
public static int OverlayColor = Shader.PropertyToID("_OverlayColor");
public static int OverlayHitPosData = Shader.PropertyToID("_OverlayHitPosData");
public static int OverlayHitStartTime = Shader.PropertyToID("_OverlayHitStartTime");
public static int OverlayTexture = Shader.PropertyToID("_OverlayTexture");
// target uniforms
public static int TargetFXRenderData = Shader.PropertyToID("_TargetFXRenderData");
// keywords
public const string SKW_ALPHACLIP = "HP_ALPHACLIP";
public const string SKW_OUTLINE_GRADIENT_WS = "HP_OUTLINE_GRADIENT_WS";
public const string SKW_OUTLINE_GRADIENT_LS = "HP_OUTLINE_GRADIENT_LS";
public const string SKW_DEPTHCLIP = "HP_DEPTHCLIP";
public const string SKW_DEPTH_OFFSET = "HP_DEPTH_OFFSET";
public const string SKW_TEXTURE_TRIPLANAR = "HP_TEXTURE_TRIPLANAR";
public const string SKW_TEXTURE_SCREENSPACE = "HP_TEXTURE_SCREENSPACE";
public const string SKW_TEXTURE_OBJECTSPACE = "HP_TEXTURE_OBJECTSPACE";
public const string SKW_SEETHROUGH_ONLY_BORDER = "HP_SEETHROUGH_ONLY_BORDER";
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 43d6485e67bc3460fabef0a5962f8e42
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Scripts/Tsq.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 18ac8ddb43ab6754aa502191a1fbb3a7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,36 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(RectTransform))]
public class AutoResizeImage : MonoBehaviour
{
public TMP_Text contentText;
private RectTransform backgroundImageRect;
void Start()
{
backgroundImageRect = GetComponent<RectTransform>();
AdjustImageWidth();
}
void Update()
{
AdjustImageWidth();
}
void AdjustImageWidth()
{
// 获取 Text 组件的首选宽度
float preferredWidth = contentText.preferredWidth;
// 设置 Image 的宽度为 Text 的首选宽度,加上一些 padding假设为 20
backgroundImageRect.sizeDelta = new Vector2(preferredWidth + (contentText.text == "" ? 0 : 30), backgroundImageRect.sizeDelta.y);
contentText.GetComponent<RectTransform>().sizeDelta = new Vector2(preferredWidth + (contentText.text == "" ? 0 : 30), 52);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d601e98274ca3e140b00c5b91cc8d51b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: