siyao
3 年前
当前提交
8445d21e
共有 15 个文件被更改,包括 619 次插入 和 80 次删除
-
134AwesomeUIWidgets/Assets/Scenes/RaycastablePickerRoom.unity
-
8AwesomeUIWidgets/Assets/Scripts/RaycastableScene/LeftUIPanel.cs
-
86AwesomeUIWidgets/Assets/Scripts/RaycastableScene/SceneBoard.cs
-
8AwesomeUIWidgets/Assets/Prefabs.meta
-
120AwesomeUIWidgets/Assets/Scripts/RaycastableScene/GameObjectManager.cs
-
3AwesomeUIWidgets/Assets/Scripts/RaycastableScene/GameObjectManager.cs.meta
-
30AwesomeUIWidgets/Assets/Scripts/RaycastableScene/RaycastableSceneConfig.cs
-
3AwesomeUIWidgets/Assets/Scripts/RaycastableScene/RaycastableSceneConfig.cs.meta
-
95AwesomeUIWidgets/Assets/Prefabs/Cube.prefab
-
7AwesomeUIWidgets/Assets/Prefabs/Cube.prefab.meta
-
96AwesomeUIWidgets/Assets/Prefabs/Cylinder.prefab
-
7AwesomeUIWidgets/Assets/Prefabs/Cylinder.prefab.meta
-
95AwesomeUIWidgets/Assets/Prefabs/Sphere.prefab
-
7AwesomeUIWidgets/Assets/Prefabs/Sphere.prefab.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 2dbf9b1acf958b048824e4445dfe49f2 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using UnityEngine; |
|||
|
|||
namespace UIWidgetsSample.RaycastableScene |
|||
{ |
|||
public class ObjectItem |
|||
{ |
|||
public GameObject obj; |
|||
public Vector3 position; |
|||
public string name; |
|||
} |
|||
public class GameObjectManager : MonoBehaviour |
|||
{ |
|||
public GameObject cube; |
|||
public GameObject ball; |
|||
public GameObject cylinder; |
|||
|
|||
public Transform center; |
|||
public static Transform centerInstance; |
|||
|
|||
public static Dictionary<string, ObjectItem> objects = new Dictionary<string, ObjectItem>(); |
|||
|
|||
|
|||
// public static List<GameObject> closeObjects = new List<GameObject>();
|
|||
|
|||
public Vector3 NewPosition() |
|||
{ |
|||
int count = objects.Count; |
|||
int sq = (int) Mathf.Sqrt(count); |
|||
int remain = count - sq * sq; |
|||
int r = 0; |
|||
int c = 0; |
|||
if (remain <= sq) |
|||
{ |
|||
r = sq; |
|||
c = remain; |
|||
} |
|||
else |
|||
{ |
|||
r = 2 * sq - remain; |
|||
c = sq; |
|||
} |
|||
|
|||
var s = 2; |
|||
return center.position + new Vector3(r * s, c * s, 0); |
|||
} |
|||
|
|||
public void CreateGameObject(GameObject obj, int count, string name) |
|||
{ |
|||
int sq = (int)Mathf.Sqrt(count); |
|||
if (obj) |
|||
{ |
|||
for (int i = 0; i <count; i++) |
|||
{ |
|||
int r = i % sq; |
|||
int c = i / sq; |
|||
int s = 1; |
|||
var position = NewPosition(); |
|||
var newObj = Instantiate(obj, position, Quaternion.identity); |
|||
newObj.name = $"{name}{i + 1}"; |
|||
objects.Add(newObj.name, new ObjectItem() |
|||
{ |
|||
obj = newObj, |
|||
name = newObj.name, |
|||
position = newObj.transform.position |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
private void Start() |
|||
{ |
|||
centerInstance = center; |
|||
CreateGameObject(cube, RaycastableSceneConfig.cubeCount, RaycastableSceneConfig.cubeName); |
|||
CreateGameObject(ball, RaycastableSceneConfig.ballCount, RaycastableSceneConfig.ballName); |
|||
CreateGameObject(cylinder, RaycastableSceneConfig.cylinderCount, RaycastableSceneConfig.cylinderName); |
|||
} |
|||
|
|||
|
|||
void Update() |
|||
{ |
|||
// int count = closeObjects.Count;
|
|||
// transform.Rotate(new Vector3(0,1,0), Time.deltaTime);
|
|||
// for (int i = 0; i < count; i++)
|
|||
// {
|
|||
// closeObjects[i].transform.position()
|
|||
// }
|
|||
|
|||
} |
|||
|
|||
void OnDestroy() |
|||
{ |
|||
foreach (var obj in objects) |
|||
{ |
|||
Destroy(obj.Value.obj); |
|||
} |
|||
} |
|||
|
|||
public static void MoveCenter(string name) |
|||
{ |
|||
var obj = objects.getOrDefault(name); |
|||
if (obj != null) |
|||
{ |
|||
obj.obj.transform.position = obj.position;// centerInstance.position;
|
|||
// closeObjects.Add(obj);
|
|||
} |
|||
} |
|||
|
|||
public static void MoveFar(string name) |
|||
{ |
|||
var obj = objects.getOrDefault(name); |
|||
if (obj != null) |
|||
{ |
|||
obj.obj.transform.position = RaycastableSceneConfig.far; |
|||
// closeObjects.Remove(obj);
|
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fa69e2d9892346bfac8ad4dfc88af371 |
|||
timeCreated: 1627459746 |
|
|||
using uiwidgets; |
|||
using UnityEngine; |
|||
using Color = Unity.UIWidgets.ui.Color; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace UIWidgetsSample.RaycastableScene |
|||
{ |
|||
public static class RaycastableSceneConfig |
|||
{ |
|||
public const int fontSize = 20; |
|||
public static readonly TextStyle fontStyle = new TextStyle( |
|||
color: Colors.white, |
|||
fontSize: fontSize |
|||
); |
|||
public const int transparent = 100; |
|||
public const int height = 50; |
|||
public static readonly Color mainColor = Color.fromARGB(transparent, 100, 100, 100); |
|||
public const string LightSwitchName = "Light Switcher"; |
|||
public const string LightSliderName = "Color Slider"; |
|||
|
|||
public const string cubeName = "cube"; |
|||
public const int cubeCount = 15; |
|||
public const string ballName = "ball"; |
|||
public const int ballCount = 2; |
|||
public const string cylinderName = "cylinder"; |
|||
public const int cylinderCount = 2; |
|||
|
|||
public static readonly Vector3 far = new Vector3(1000, 0, 0); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7aae02d271514be58c0ca1bae4e772eb |
|||
timeCreated: 1627459923 |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1 &8961943036043786051 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 9200140335519435826} |
|||
- component: {fileID: 217986789939320856} |
|||
- component: {fileID: 576961217026804357} |
|||
- component: {fileID: 3906594783066886855} |
|||
m_Layer: 0 |
|||
m_Name: Cube |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &9200140335519435826 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8961943036043786051} |
|||
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!33 &217986789939320856 |
|||
MeshFilter: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8961943036043786051} |
|||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} |
|||
--- !u!23 &576961217026804357 |
|||
MeshRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8961943036043786051} |
|||
m_Enabled: 1 |
|||
m_CastShadows: 1 |
|||
m_ReceiveShadows: 1 |
|||
m_DynamicOccludee: 1 |
|||
m_MotionVectors: 1 |
|||
m_LightProbeUsage: 1 |
|||
m_ReflectionProbeUsage: 1 |
|||
m_RayTracingMode: 2 |
|||
m_RenderingLayerMask: 1 |
|||
m_RendererPriority: 0 |
|||
m_Materials: |
|||
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_StaticBatchInfo: |
|||
firstSubMesh: 0 |
|||
subMeshCount: 0 |
|||
m_StaticBatchRoot: {fileID: 0} |
|||
m_ProbeAnchor: {fileID: 0} |
|||
m_LightProbeVolumeOverride: {fileID: 0} |
|||
m_ScaleInLightmap: 1 |
|||
m_ReceiveGI: 1 |
|||
m_PreserveUVs: 0 |
|||
m_IgnoreNormalsForChartDetection: 0 |
|||
m_ImportantGI: 0 |
|||
m_StitchLightmapSeams: 1 |
|||
m_SelectedEditorRenderState: 3 |
|||
m_MinimumChartSize: 4 |
|||
m_AutoUVMaxDistance: 0.5 |
|||
m_AutoUVMaxAngle: 89 |
|||
m_LightmapParameters: {fileID: 0} |
|||
m_SortingLayerID: 0 |
|||
m_SortingLayer: 0 |
|||
m_SortingOrder: 0 |
|||
--- !u!65 &3906594783066886855 |
|||
BoxCollider: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8961943036043786051} |
|||
m_Material: {fileID: 0} |
|||
m_IsTrigger: 0 |
|||
m_Enabled: 1 |
|||
serializedVersion: 2 |
|||
m_Size: {x: 1, y: 1, z: 1} |
|||
m_Center: {x: 0, y: 0, z: 0} |
|
|||
fileFormatVersion: 2 |
|||
guid: 90c7dde08862b9945bab6d5c1ff8473c |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1 &2581742516055541185 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 7612766893867473678} |
|||
- component: {fileID: 6957062373009968899} |
|||
- component: {fileID: 8774268852477691989} |
|||
- component: {fileID: 9163324703857710} |
|||
m_Layer: 0 |
|||
m_Name: Cylinder |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &7612766893867473678 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2581742516055541185} |
|||
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!33 &6957062373009968899 |
|||
MeshFilter: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2581742516055541185} |
|||
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} |
|||
--- !u!23 &8774268852477691989 |
|||
MeshRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2581742516055541185} |
|||
m_Enabled: 1 |
|||
m_CastShadows: 1 |
|||
m_ReceiveShadows: 1 |
|||
m_DynamicOccludee: 1 |
|||
m_MotionVectors: 1 |
|||
m_LightProbeUsage: 1 |
|||
m_ReflectionProbeUsage: 1 |
|||
m_RayTracingMode: 2 |
|||
m_RenderingLayerMask: 1 |
|||
m_RendererPriority: 0 |
|||
m_Materials: |
|||
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_StaticBatchInfo: |
|||
firstSubMesh: 0 |
|||
subMeshCount: 0 |
|||
m_StaticBatchRoot: {fileID: 0} |
|||
m_ProbeAnchor: {fileID: 0} |
|||
m_LightProbeVolumeOverride: {fileID: 0} |
|||
m_ScaleInLightmap: 1 |
|||
m_ReceiveGI: 1 |
|||
m_PreserveUVs: 0 |
|||
m_IgnoreNormalsForChartDetection: 0 |
|||
m_ImportantGI: 0 |
|||
m_StitchLightmapSeams: 1 |
|||
m_SelectedEditorRenderState: 3 |
|||
m_MinimumChartSize: 4 |
|||
m_AutoUVMaxDistance: 0.5 |
|||
m_AutoUVMaxAngle: 89 |
|||
m_LightmapParameters: {fileID: 0} |
|||
m_SortingLayerID: 0 |
|||
m_SortingLayer: 0 |
|||
m_SortingOrder: 0 |
|||
--- !u!136 &9163324703857710 |
|||
CapsuleCollider: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2581742516055541185} |
|||
m_Material: {fileID: 0} |
|||
m_IsTrigger: 0 |
|||
m_Enabled: 1 |
|||
m_Radius: 0.5000001 |
|||
m_Height: 2 |
|||
m_Direction: 1 |
|||
m_Center: {x: 0.000000059604645, y: 0, z: -0.00000008940697} |
|
|||
fileFormatVersion: 2 |
|||
guid: 26a44dfb8d31fa74b89ff502c058df6b |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1 &3259445113941571833 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 8540420582559671601} |
|||
- component: {fileID: 4444717868203319654} |
|||
- component: {fileID: 5085546952128025868} |
|||
- component: {fileID: 8770364505366370893} |
|||
m_Layer: 0 |
|||
m_Name: Sphere |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &8540420582559671601 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 3259445113941571833} |
|||
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!33 &4444717868203319654 |
|||
MeshFilter: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 3259445113941571833} |
|||
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} |
|||
--- !u!23 &5085546952128025868 |
|||
MeshRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 3259445113941571833} |
|||
m_Enabled: 1 |
|||
m_CastShadows: 1 |
|||
m_ReceiveShadows: 1 |
|||
m_DynamicOccludee: 1 |
|||
m_MotionVectors: 1 |
|||
m_LightProbeUsage: 1 |
|||
m_ReflectionProbeUsage: 1 |
|||
m_RayTracingMode: 2 |
|||
m_RenderingLayerMask: 1 |
|||
m_RendererPriority: 0 |
|||
m_Materials: |
|||
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_StaticBatchInfo: |
|||
firstSubMesh: 0 |
|||
subMeshCount: 0 |
|||
m_StaticBatchRoot: {fileID: 0} |
|||
m_ProbeAnchor: {fileID: 0} |
|||
m_LightProbeVolumeOverride: {fileID: 0} |
|||
m_ScaleInLightmap: 1 |
|||
m_ReceiveGI: 1 |
|||
m_PreserveUVs: 0 |
|||
m_IgnoreNormalsForChartDetection: 0 |
|||
m_ImportantGI: 0 |
|||
m_StitchLightmapSeams: 1 |
|||
m_SelectedEditorRenderState: 3 |
|||
m_MinimumChartSize: 4 |
|||
m_AutoUVMaxDistance: 0.5 |
|||
m_AutoUVMaxAngle: 89 |
|||
m_LightmapParameters: {fileID: 0} |
|||
m_SortingLayerID: 0 |
|||
m_SortingLayer: 0 |
|||
m_SortingOrder: 0 |
|||
--- !u!135 &8770364505366370893 |
|||
SphereCollider: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 3259445113941571833} |
|||
m_Material: {fileID: 0} |
|||
m_IsTrigger: 0 |
|||
m_Enabled: 1 |
|||
serializedVersion: 2 |
|||
m_Radius: 0.5 |
|||
m_Center: {x: 0, y: 0, z: 0} |
|
|||
fileFormatVersion: 2 |
|||
guid: 9152c5b499e52544eafe077bc7048fbf |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue