浏览代码

[Feature] Panel Raycast Filter

/main
iizzaya 5 年前
当前提交
539b94c6
共有 18 个文件被更改,包括 2351 次插入0 次删除
  1. 8
      Runtime/Plugins/Raycast.meta
  2. 82
      Runtime/Plugins/Raycast/RaycastManager.cs
  3. 11
      Runtime/Plugins/Raycast/RaycastManager.cs.meta
  4. 118
      Runtime/Plugins/Raycast/RaycastableConatiner.cs
  5. 11
      Runtime/Plugins/Raycast/RaycastableConatiner.cs.meta
  6. 8
      Runtime/Plugins/Raycast/Sample.meta
  7. 1001
      Runtime/Plugins/Raycast/Sample/Raycast Simple Testbed.unity
  8. 7
      Runtime/Plugins/Raycast/Sample/Raycast Simple Testbed.unity.meta
  9. 757
      Runtime/Plugins/Raycast/Sample/Raycast Testbed.unity
  10. 7
      Runtime/Plugins/Raycast/Sample/Raycast Testbed.unity.meta
  11. 49
      Runtime/Plugins/Raycast/Sample/RaycastSimpleTestbedPanel.cs
  12. 11
      Runtime/Plugins/Raycast/Sample/RaycastSimpleTestbedPanel.cs.meta
  13. 213
      Runtime/Plugins/Raycast/Sample/RaycastTestbedPanel.cs
  14. 11
      Runtime/Plugins/Raycast/Sample/RaycastTestbedPanel.cs.meta
  15. 46
      Runtime/Plugins/Raycast/UIWidgetsPanelRaycastFilter.cs
  16. 11
      Runtime/Plugins/Raycast/UIWidgetsPanelRaycastFilter.cs.meta

8
Runtime/Plugins/Raycast.meta


fileFormatVersion: 2
guid: 536a3d78629ef4c00adb8dc15d9988df
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

82
Runtime/Plugins/Raycast/RaycastManager.cs


using System.Collections.Generic;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.plugins.raycast {
public class RaycastableRect {
public bool isDirty;
public Rect rect;
public RaycastableRect(bool isDirty) {
this.isDirty = isDirty;
}
}
public class RaycastManager {
static RaycastManager _instance;
public static RaycastManager instance {
get {
if (_instance == null) {
_instance = new RaycastManager();
}
return _instance;
}
}
public Dictionary<int, Dictionary<int, RaycastableRect>> hashCodeList =
new Dictionary<int, Dictionary<int, RaycastableRect>>();
public static void VerifyWindow(int windowHashCode) {
if (!instance.hashCodeList.ContainsKey(windowHashCode)) {
// Debug.Log($"New Window: @[{windowHashCode}] ({instance.hashCodeList.Count})");
instance.hashCodeList.Add(windowHashCode, new Dictionary<int, RaycastableRect>());
}
}
public static void AddToList(int key, int windowHashCode) {
VerifyWindow(windowHashCode);
// Debug.Log($"Add To List: [{key}]@[{windowHashCode}]");
if (!instance.hashCodeList[windowHashCode].ContainsKey(key)) {
instance.hashCodeList[windowHashCode][key] = new RaycastableRect(true);
}
}
public static void MarkDirty(int key, int windowHashCode) {
// Debug.Log($"Mark Dirty: [{key}]@[{windowHashCode}]");
if (instance.hashCodeList[windowHashCode].ContainsKey(key)) {
instance.hashCodeList[windowHashCode][key].isDirty = true;
}
}
public static void UpdateSizeOffset(int key, int windowHashCode, Size size, Offset offset) {
// Debug.Log($"Update Size Offset: [{key}]@[{windowHashCode}]");
if (instance.hashCodeList[windowHashCode].ContainsKey(key)) {
if (instance.hashCodeList[windowHashCode][key].isDirty) {
instance.hashCodeList[windowHashCode][key].rect =
Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height);
instance.hashCodeList[windowHashCode][key].isDirty = false;
}
}
}
public static void RemoveFromList(int key, int windowHashCode) {
// Debug.Log($"Remove From List: [{key}]@[{windowHashCode}]");
if (instance.hashCodeList[windowHashCode].ContainsKey(key)) {
instance.hashCodeList[windowHashCode].Remove(key);
}
}
public static bool CheckCastThrough(int windowHashCode, Vector2 pos) {
foreach (var item in instance.hashCodeList[windowHashCode]) {
if (item.Value.rect.contains(new Offset(pos.x, pos.y))) {
return false;
}
}
return true;
}
}
}

11
Runtime/Plugins/Raycast/RaycastManager.cs.meta


fileFormatVersion: 2
guid: 9574f12b230354e6f87fc5fc0c98c96e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

118
Runtime/Plugins/Raycast/RaycastableConatiner.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.plugins.raycast {
class RaycastableBox : SingleChildRenderObjectWidget {
public RaycastableBox(
Key key = null,
Widget child = null
) : base(key, child) {
this.windowHashCode = Window.instance.GetHashCode();
}
readonly int windowHashCode;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderRaycastableBox(
windowHashCode: this.windowHashCode,
widget: this
);
}
public override Element createElement() {
return new _RaycastableBoxRenderElement(this.windowHashCode, this);
}
}
class RenderRaycastableBox : RenderProxyBox {
public RenderRaycastableBox(
int windowHashCode,
RenderBox child = null,
RaycastableBox widget = null
) : base(child) {
this.widget = widget;
this.windowHashCode = windowHashCode;
}
readonly int windowHashCode;
RaycastableBox widget;
public override void detach() {
base.detach();
this.markNeedsPaint();
}
public override void paint(PaintingContext context, Offset offset) {
// Debug.Log($"[RenderRaycastableBox] Paint {this.widget.GetHashCode()}: {this.size}@{offset}");
RaycastManager.UpdateSizeOffset(this.widget.GetHashCode(), (int) this.windowHashCode, this.size, offset);
base.paint(context, offset);
}
}
class _RaycastableBoxRenderElement : SingleChildRenderObjectElement {
public _RaycastableBoxRenderElement(
int windowHashCode,
RaycastableBox widget
) : base(widget) {
this.windowHashCode = windowHashCode;
}
public new RaycastableBox widget {
get { return base.widget as RaycastableBox; }
}
int widgetHashCode;
int windowHashCode;
public override void mount(Element parent, object newSlot) {
this.widgetHashCode = this.widget.GetHashCode();
// Debug.Log($"[RaycastableBox] Mount: {this.initHashCode}");
RaycastManager.AddToList(this.widgetHashCode, this.windowHashCode);
base.mount(parent, newSlot);
}
public override void update(Widget newWidget) {
// Debug.Log($"[RaycastableBox] Update: {this.initHashCode}");
RaycastManager.MarkDirty(this.widgetHashCode, this.windowHashCode);
base.update(newWidget);
}
public override void unmount() {
// Debug.Log($"[RaycastableBox] Unmount: {this.initHashCode}");
RaycastManager.RemoveFromList(this.widgetHashCode, this.windowHashCode);
base.unmount();
}
}
public class RaycastableContainer : StatelessWidget {
public RaycastableContainer(
Widget child = null,
Key key = null
) : base(key) {
this.child = child;
}
public readonly Widget child;
public override Widget build(BuildContext context) {
Widget current = this.child;
if (this.child == null) {
current = new LimitedBox(
maxWidth: 0.0f,
maxHeight: 0.0f,
child: new ConstrainedBox(constraints: BoxConstraints.expand())
);
}
current = new RaycastableBox(child: current);
return current;
}
}
}

11
Runtime/Plugins/Raycast/RaycastableConatiner.cs.meta


fileFormatVersion: 2
guid: 9af0c7d6aab134f5ba187ff34acf2377
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Runtime/Plugins/Raycast/Sample.meta


fileFormatVersion: 2
guid: a722cfcd498904dd68cd954f2a5a1892
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1001
Runtime/Plugins/Raycast/Sample/Raycast Simple Testbed.unity
文件差异内容过多而无法显示
查看文件

7
Runtime/Plugins/Raycast/Sample/Raycast Simple Testbed.unity.meta


fileFormatVersion: 2
guid: 83e4542c541b84d80ad625e366e30839
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

757
Runtime/Plugins/Raycast/Sample/Raycast Testbed.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 3
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 0
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 0
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 500
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 2
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 0
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ShowResolutionOverlay: 1
m_ExportTrainingData: 0
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &354633976
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 354633980}
- component: {fileID: 354633979}
- component: {fileID: 354633978}
- component: {fileID: 354633977}
- component: {fileID: 354633981}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &354633977
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 354633976}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &354633978
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 354633976}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!223 &354633979
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 354633976}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 1
m_Camera: {fileID: 519420031}
m_PlaneDistance: 1
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &354633980
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 354633976}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 789225035}
- {fileID: 657653790}
- {fileID: 1942439624}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!222 &354633981
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 354633976}
m_CullTransparentMesh: 0
--- !u!1 &519420028
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 519420032}
- component: {fileID: 519420031}
- component: {fileID: 519420029}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &519420029
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 519420028}
m_Enabled: 1
--- !u!20 &519420031
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 519420028}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 0
m_HDR: 1
m_AllowMSAA: 0
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 0
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &519420032
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 519420028}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &657653789
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 657653790}
- component: {fileID: 657653792}
- component: {fileID: 657653791}
- component: {fileID: 657653793}
m_Layer: 5
m_Name: Raycast Testbed Panel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &657653790
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 657653789}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 354633980}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -203, y: 81.79999}
m_SizeDelta: {x: 1290.3, y: 471.4}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &657653791
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 657653789}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1b02d547623984986a44973c4ba2bca0, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
devicePixelRatioOverride: 0
hardwareAntiAliasing: 0
--- !u!222 &657653792
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 657653789}
m_CullTransparentMesh: 0
--- !u!114 &657653793
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 657653789}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2455841904ff14258bae1b28c1363dc0, type: 3}
m_Name:
m_EditorClassIdentifier:
reversed: 0
--- !u!1 &789225034
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 789225035}
- component: {fileID: 789225038}
- component: {fileID: 789225037}
- component: {fileID: 789225036}
m_Layer: 5
m_Name: Button
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &789225035
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 789225034}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 3, y: 3, z: 1}
m_Children:
- {fileID: 812945430}
m_Father: {fileID: 354633980}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0.000030518, y: -0.000011444}
m_SizeDelta: {x: 436.8, y: 81.8}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &789225036
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 789225034}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 789225037}
m_OnClick:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!114 &789225037
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 789225034}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
--- !u!222 &789225038
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 789225034}
m_CullTransparentMesh: 0
--- !u!1 &812945429
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 812945430}
- component: {fileID: 812945432}
- component: {fileID: 812945431}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &812945430
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 812945429}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 789225035}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &812945431
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 812945429}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Button
--- !u!222 &812945432
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 812945429}
m_CullTransparentMesh: 0
--- !u!1 &1742152755
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1742152758}
- component: {fileID: 1742152757}
- component: {fileID: 1742152756}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1742152756
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1742152755}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &1742152757
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1742152755}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -619905303, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 1742152755}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &1742152758
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1742152755}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1942439623
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1942439624}
- component: {fileID: 1942439627}
- component: {fileID: 1942439626}
- component: {fileID: 1942439625}
m_Layer: 5
m_Name: Raycast Testbed Panel (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1942439624
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1942439623}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 354633980}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 180.85, y: 42}
m_SizeDelta: {x: 1290.3, y: 471.4}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1942439625
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1942439623}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2455841904ff14258bae1b28c1363dc0, type: 3}
m_Name:
m_EditorClassIdentifier:
reversed: 0
--- !u!114 &1942439626
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1942439623}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1b02d547623984986a44973c4ba2bca0, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
devicePixelRatioOverride: 0
hardwareAntiAliasing: 0
--- !u!222 &1942439627
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1942439623}
m_CullTransparentMesh: 0

7
Runtime/Plugins/Raycast/Sample/Raycast Testbed.unity.meta


fileFormatVersion: 2
guid: e1bac3be89f2644f6ad3a6ed1ff00617
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

49
Runtime/Plugins/Raycast/Sample/RaycastSimpleTestbedPanel.cs


using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.plugins.raycast;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Material = Unity.UIWidgets.material.Material;
namespace Unity.UIWidgets.Sample {
public class RaycastSimpleTestbedPanel : UIWidgetsPanel {
protected override void OnEnable() {
FontManager.instance.addFont(Resources.Load<Font>("fonts/MaterialIcons-Regular"), "Material Icons");
base.OnEnable();
}
protected override Widget createWidget() {
return new MaterialApp(
home: new RaycastSimpleTestbedWidget()
);
}
}
public class RaycastSimpleTestbedWidget : StatefulWidget {
public RaycastSimpleTestbedWidget(Key key = null) : base(key) { }
public override State createState() {
return new RaycastSimpleTestbedWidgetState();
}
}
public class RaycastSimpleTestbedWidgetState : State<RaycastSimpleTestbedWidget> {
public override Widget build(BuildContext context) {
return new Material(
color: new Color(0x44FFFF00),
child: new Center(
child: new RaycastableContainer(
new MaterialButton(
child: new Text("Material Button"),
onPressed: () => { },
color: Colors.lightBlue
)
)
)
);
}
}
}

11
Runtime/Plugins/Raycast/Sample/RaycastSimpleTestbedPanel.cs.meta


fileFormatVersion: 2
guid: 4fc8b0d34b82c4c63a41e0cde280075a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

213
Runtime/Plugins/Raycast/Sample/RaycastTestbedPanel.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.plugins.raycast;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Material = Unity.UIWidgets.material.Material;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.Sample {
public class RaycastTestbedPanel : UIWidgetsPanel {
protected override void OnEnable() {
FontManager.instance.addFont(Resources.Load<Font>("fonts/MaterialIcons-Regular"), "Material Icons");
base.OnEnable();
}
protected override Widget createWidget() {
return new MaterialApp(
home: new RaycastTestbedWidget()
);
}
}
public class RaycastTestbedWidget : StatefulWidget {
public RaycastTestbedWidget(Key key = null) : base(key) { }
public override State createState() {
return new RaycastTestbedWidgetState();
}
}
public class RaycastTestbedWidgetState : State<RaycastTestbedWidget> {
public bool enableState = false;
public int switchState = 0;
public int switchPosState = 0;
public bool enableState2 = false;
public int switchState2 = 0;
public int switchPosState2 = 2;
public override Widget build(BuildContext context) {
return new Material(
color: Colors.transparent,
child: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: new List<Widget> {
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: new List<Widget> {
new RaycastableContainer(child: new MaterialButton(
child: new Text($"Enable State: {this.enableState.ToString()}"),
onPressed: () => {
this.setState(
() => { this.enableState = !this.enableState; });
},
color: Colors.lightBlue
)
),
new Padding(padding: EdgeInsets.symmetric(horizontal: 5f)),
new RaycastableContainer(child: new MaterialButton(
child: new Text($"Switch State: {this.switchState.ToString()}"),
onPressed: () => {
this.setState(
() => { this.switchState = (this.switchState + 1) % 3; });
},
color: Colors.lightBlue
)),
new Padding(padding: EdgeInsets.symmetric(horizontal: 5f)),
new RaycastableContainer(child: new MaterialButton(
child: new Text($"Switch Pos State: {this.switchPosState.ToString()}"),
onPressed: () => {
this.setState(
() => { this.switchPosState = (this.switchPosState + 1) % 2; });
},
color: Colors.lightBlue
))
}
),
new Padding(padding: EdgeInsets.symmetric(5f)),
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: new List<Widget> {
new RaycastableContainer(child: new MaterialButton(
child: new Text($"Enable State: {this.enableState2.ToString()}"),
onPressed: () => {
this.setState(
() => { this.enableState2 = !this.enableState2; });
},
color: Colors.lightBlue
)),
new Padding(padding: EdgeInsets.symmetric(horizontal: 5f)),
new RaycastableContainer(child: new MaterialButton(
child: new Text($"Switch State: {this.switchState2.ToString()}"),
onPressed: () => {
this.setState(
() => { this.switchState2 = (this.switchState2 + 1) % 3; });
},
color: Colors.lightBlue
)),
new Padding(padding: EdgeInsets.symmetric(horizontal: 5f)),
new RaycastableContainer(child: new MaterialButton(
child: new Text($"Switch Pos State: {this.switchPosState2.ToString()}"),
onPressed: () => {
this.setState(
() => { this.switchPosState2 = (this.switchPosState2) % 2 + 1; });
},
color: Colors.lightBlue
))
}
),
new Padding(padding: EdgeInsets.symmetric(5f)),
new Stack(
children: new List<Widget> {
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: new List<Widget> {
new Container(
padding: EdgeInsets.only(top: 25f * this.switchPosState,
bottom: 25f * (3 - this.switchPosState)),
child: this.enableState
? (Widget) new RaycastableContainer(
new Container(
child: new Text(
data: this.switchState == 0
? "特殊字符串"
: this.switchState == 1
? "特殊字符串串"
: "特殊字符串串串",
style: new TextStyle(
fontSize: 48,
fontWeight: FontWeight.bold,
decoration: TextDecoration.none,
color: Colors.red
)
),
decoration: new BoxDecoration(
color: new Color(0x44FFFF00)
)
)
)
: new Text(
data: this.switchState == 0
? "普通字符串"
: this.switchState == 1
? "普通字符串串"
: "普通字符串串串",
style: new TextStyle(
fontSize: 48,
fontWeight: FontWeight.bold,
decoration: TextDecoration.none,
color: Colors.red
)
)
)
}
),
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: new List<Widget> {
new Container(
padding: EdgeInsets.only(top: 25f * this.switchPosState2,
bottom: 25f * (3 - this.switchPosState2)),
child: this.enableState2
? (Widget) new RaycastableContainer(
new Container(
child: new Text(
data: this.switchState2 == 0
? "特殊字符串"
: this.switchState2 == 1
? "特殊字符串串"
: "特殊字符串串串",
style: new TextStyle(
fontSize: 48,
fontWeight: FontWeight.bold,
decoration: TextDecoration.none,
color: Colors.red
)
),
decoration: new BoxDecoration(
color: new Color(0x44FFFF00)
)
)
)
: (Widget) new Text(
data: this.switchState2 == 0
? "普通字符串"
: this.switchState2 == 1
? "普通字符串串"
: "普通字符串串串",
style: new TextStyle(
fontSize: 48,
fontWeight: FontWeight.bold,
decoration: TextDecoration.none,
color: Colors.red
)
)
)
}
)
}
)
}
)
)
);
}
}
}

11
Runtime/Plugins/Raycast/Sample/RaycastTestbedPanel.cs.meta


fileFormatVersion: 2
guid: 1b02d547623984986a44973c4ba2bca0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

46
Runtime/Plugins/Raycast/UIWidgetsPanelRaycastFilter.cs


using Unity.UIWidgets.engine;
using UnityEngine;
namespace Unity.UIWidgets.plugins.raycast {
[DisallowMultipleComponent]
[RequireComponent(typeof(UIWidgetsPanel))]
[DefaultExecutionOrder(1)]
public class UIWidgetsPanelRaycastFilter : MonoBehaviour, ICanvasRaycastFilter {
public bool reversed;
UIWidgetsPanel panel;
int windowHashCode;
void OnEnable() {
this.panel = this.GetComponent<UIWidgetsPanel>();
this.windowHashCode = this.panel.window.GetHashCode();
RaycastManager.VerifyWindow(this.windowHashCode);
}
public bool IsRaycastLocationValid(Vector2 screenPoint, Camera eventCamera) {
if (!this.enabled) {
return true;
}
Vector2 local;
RectTransformUtility.ScreenPointToLocalPointInRectangle(this.panel.rectTransform, screenPoint, eventCamera,
out local);
Rect rect = this.panel.rectTransform.rect;
// Convert top left corner as reference origin point.
local.x += this.panel.rectTransform.pivot.x * rect.width;
local.y -= this.panel.rectTransform.pivot.y * rect.height;
local.x = local.x / this.panel.devicePixelRatio;
local.y = -local.y / this.panel.devicePixelRatio;
if (this.reversed) {
return RaycastManager.CheckCastThrough(this.windowHashCode, local);
}
else {
return !RaycastManager.CheckCastThrough(this.windowHashCode, local);
}
}
}
}

11
Runtime/Plugins/Raycast/UIWidgetsPanelRaycastFilter.cs.meta


fileFormatVersion: 2
guid: 2455841904ff14258bae1b28c1363dc0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存