diff options
| author | chai <215380520@qq.com> | 2023-10-19 15:36:59 +0800 | 
|---|---|---|
| committer | chai <215380520@qq.com> | 2023-10-19 15:36:59 +0800 | 
| commit | f4a633ea5125025216cc1d260d5dbac66f6ed194 (patch) | |
| tree | 2c1d70c22b712dd895afcdc41bda158b1e2ee2ae | |
| parent | bc77bc7bc8b1a9b04ff598ff45eec0a1df5c6d8c (diff) | |
*doc
| -rw-r--r-- | ActiveRagdoll/Assets/MaxCamera.cs | 149 | ||||
| -rw-r--r-- | ActiveRagdoll/Assets/MaxCamera.cs.meta | 11 | ||||
| -rw-r--r-- | ActiveRagdoll/Assets/New Scene.unity | 303 | ||||
| -rw-r--r-- | ActiveRagdoll/Assets/New Scene.unity.meta | 7 | ||||
| -rw-r--r-- | Docs/TAB_AddCamera.txt | 11 | ||||
| -rw-r--r-- | Docs/TAB_AddDebugRigidBody.txt | 143 | ||||
| -rw-r--r-- | Docs/TAB_Camera.txt | 140 | ||||
| -rw-r--r-- | Docs/TAB_DebugRigidBody.txt | 135 | ||||
| -rw-r--r-- | Docs/TAB_UnityExploerer.txt | 28 | ||||
| -rw-r--r-- | Docs/资料.xlsx | bin | 4611242 -> 5842601 bytes | 
10 files changed, 927 insertions, 0 deletions
diff --git a/ActiveRagdoll/Assets/MaxCamera.cs b/ActiveRagdoll/Assets/MaxCamera.cs new file mode 100644 index 0000000..3da1ad3 --- /dev/null +++ b/ActiveRagdoll/Assets/MaxCamera.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +/// <summary> +/// A simple free camera to be added to a Unity game object. +///  +/// Keys: +///	wasd / arrows	- movement +///	q/e 			- up/down (local space) +///	r/f 			- up/down (world space) +///	pageup/pagedown	- up/down (world space) +///	hold shift		- enable fast movement mode +///	right mouse  	- enable free look +///	mouse			- free look / rotation +///      +/// </summary> +public class MaxCamera : MonoBehaviour +{ +    /// <summary> +    /// Normal speed of camera movement. +    /// </summary> +    public float movementSpeed = 10f; + +    /// <summary> +    /// Speed of camera movement when shift is held down, +    /// </summary> +    public float fastMovementSpeed = 100f; + +    /// <summary> +    /// Sensitivity for free look. +    /// </summary> +    public float freeLookSensitivity = 3f; + +    /// <summary> +    /// Amount to zoom the camera when using the mouse wheel. +    /// </summary> +    public float zoomSensitivity = 10f; + +    /// <summary> +    /// Amount to zoom the camera when using the mouse wheel (fast mode). +    /// </summary> +    public float fastZoomSensitivity = 50f; + +    /// <summary> +    /// Set to true when free looking (on right mouse button). +    /// </summary> +    private bool looking = false; + +    private void Awake() +    { +    } + +    void Update() +    { +        var fastMode = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift); +        var movementSpeed = fastMode ? this.fastMovementSpeed : this.movementSpeed; + +        if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) +        { +            transform.position = transform.position + (-transform.right * movementSpeed * Time.deltaTime); +        } + +        if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) +        { +            transform.position = transform.position + (transform.right * movementSpeed * Time.deltaTime); +        } + +        if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)) +        { +            transform.position = transform.position + (transform.forward * movementSpeed * Time.deltaTime); +        } + +        if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow)) +        { +            transform.position = transform.position + (-transform.forward * movementSpeed * Time.deltaTime); +        } + +        if (Input.GetKey(KeyCode.Q)) +        { +            transform.position = transform.position + (transform.up * movementSpeed * Time.deltaTime); +        } + +        if (Input.GetKey(KeyCode.E)) +        { +            transform.position = transform.position + (-transform.up * movementSpeed * Time.deltaTime); +        } + +        if (Input.GetKey(KeyCode.R) || Input.GetKey(KeyCode.PageUp)) +        { +            transform.position = transform.position + (Vector3.up * movementSpeed * Time.deltaTime); +        } + +        if (Input.GetKey(KeyCode.F) || Input.GetKey(KeyCode.PageDown)) +        { +            transform.position = transform.position + (-Vector3.up * movementSpeed * Time.deltaTime); +        } + +        if (looking) +        { +            float newRotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * freeLookSensitivity; +            float newRotationY = transform.localEulerAngles.x - Input.GetAxis("Mouse Y") * freeLookSensitivity; +            transform.localEulerAngles = new Vector3(newRotationY, newRotationX, 0f); +        } + +        float axis = Input.GetAxis("Mouse ScrollWheel"); +        if (axis != 0) +        { +            var zoomSensitivity = fastMode ? this.fastZoomSensitivity : this.zoomSensitivity; +            transform.position = transform.position + transform.forward * axis * zoomSensitivity; +        } + +        if (Input.GetKeyDown(KeyCode.Mouse1)) +        { +            StartLooking(); +        } +        else if (Input.GetKeyUp(KeyCode.Mouse1)) +        { +            StopLooking(); +        } +    } + +    void OnDisable() +    { +        StopLooking(); +    } + +    /// <summary> +    /// Enable free looking. +    /// </summary> +    public void StartLooking() +    { +        looking = true; +        Cursor.visible = false; +        Cursor.lockState = CursorLockMode.Locked; +    } + +    /// <summary> +    /// Disable free looking. +    /// </summary> +    public void StopLooking() +    { +        looking = false; +        Cursor.visible = true; +        Cursor.lockState = CursorLockMode.None; +    } +}
\ No newline at end of file diff --git a/ActiveRagdoll/Assets/MaxCamera.cs.meta b/ActiveRagdoll/Assets/MaxCamera.cs.meta new file mode 100644 index 0000000..50b6edf --- /dev/null +++ b/ActiveRagdoll/Assets/MaxCamera.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 795911e4559bdc649bea6a391e6aef71 +MonoImporter: +  externalObjects: {} +  serializedVersion: 2 +  defaultReferences: [] +  executionOrder: 0 +  icon: {instanceID: 0} +  userData:  +  assetBundleName:  +  assetBundleVariant:  diff --git a/ActiveRagdoll/Assets/New Scene.unity b/ActiveRagdoll/Assets/New Scene.unity new file mode 100644 index 0000000..8c8209a --- /dev/null +++ b/ActiveRagdoll/Assets/New Scene.unity @@ -0,0 +1,303 @@ +%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: 0 +  m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} +  m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 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: 12 +  m_GIWorkflowMode: 1 +  m_GISettings: +    serializedVersion: 2 +    m_BounceScale: 1 +    m_IndirectOutputScale: 1 +    m_AlbedoBoost: 1 +    m_EnvironmentLightingMode: 0 +    m_EnableBakedLightmaps: 1 +    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: 1 +    m_PVRSampling: 1 +    m_PVRDirectSampleCount: 32 +    m_PVRSampleCount: 512 +    m_PVRBounces: 2 +    m_PVREnvironmentSampleCount: 256 +    m_PVREnvironmentReferencePointCount: 2048 +    m_PVRFilteringMode: 1 +    m_PVRDenoiserTypeDirect: 1 +    m_PVRDenoiserTypeIndirect: 1 +    m_PVRDenoiserTypeAO: 1 +    m_PVRFilterTypeDirect: 0 +    m_PVRFilterTypeIndirect: 0 +    m_PVRFilterTypeAO: 0 +    m_PVREnvironmentMIS: 1 +    m_PVRCulling: 1 +    m_PVRFilteringGaussRadiusDirect: 1 +    m_PVRFilteringGaussRadiusIndirect: 5 +    m_PVRFilteringGaussRadiusAO: 2 +    m_PVRFilteringAtrousPositionSigmaDirect: 0.5 +    m_PVRFilteringAtrousPositionSigmaIndirect: 2 +    m_PVRFilteringAtrousPositionSigmaAO: 1 +    m_ExportTrainingData: 0 +    m_TrainingDataDestination: TrainingData +    m_LightProbeSampleCountMultiplier: 4 +  m_LightingDataAsset: {fileID: 0} +  m_LightingSettings: {fileID: 0} +--- !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 +    maxJobWorkers: 0 +    preserveTilesOutsideBounds: 0 +    debug: +      m_Flags: 0 +  m_NavMeshData: {fileID: 0} +--- !u!1 &981251352 +GameObject: +  m_ObjectHideFlags: 0 +  m_CorrespondingSourceObject: {fileID: 0} +  m_PrefabInstance: {fileID: 0} +  m_PrefabAsset: {fileID: 0} +  serializedVersion: 6 +  m_Component: +  - component: {fileID: 981251354} +  - component: {fileID: 981251353} +  m_Layer: 0 +  m_Name: Directional Light +  m_TagString: Untagged +  m_Icon: {fileID: 0} +  m_NavMeshLayer: 0 +  m_StaticEditorFlags: 0 +  m_IsActive: 1 +--- !u!108 &981251353 +Light: +  m_ObjectHideFlags: 0 +  m_CorrespondingSourceObject: {fileID: 0} +  m_PrefabInstance: {fileID: 0} +  m_PrefabAsset: {fileID: 0} +  m_GameObject: {fileID: 981251352} +  m_Enabled: 1 +  serializedVersion: 10 +  m_Type: 1 +  m_Shape: 0 +  m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} +  m_Intensity: 1 +  m_Range: 10 +  m_SpotAngle: 30 +  m_InnerSpotAngle: 21.80208 +  m_CookieSize: 10 +  m_Shadows: +    m_Type: 2 +    m_Resolution: -1 +    m_CustomResolution: -1 +    m_Strength: 1 +    m_Bias: 0.05 +    m_NormalBias: 0.4 +    m_NearPlane: 0.2 +    m_CullingMatrixOverride: +      e00: 1 +      e01: 0 +      e02: 0 +      e03: 0 +      e10: 0 +      e11: 1 +      e12: 0 +      e13: 0 +      e20: 0 +      e21: 0 +      e22: 1 +      e23: 0 +      e30: 0 +      e31: 0 +      e32: 0 +      e33: 1 +    m_UseCullingMatrixOverride: 0 +  m_Cookie: {fileID: 0} +  m_DrawHalo: 0 +  m_Flare: {fileID: 0} +  m_RenderMode: 0 +  m_CullingMask: +    serializedVersion: 2 +    m_Bits: 4294967295 +  m_RenderingLayerMask: 1 +  m_Lightmapping: 4 +  m_LightShadowCasterMode: 0 +  m_AreaSize: {x: 1, y: 1} +  m_BounceIntensity: 1 +  m_ColorTemperature: 6570 +  m_UseColorTemperature: 0 +  m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} +  m_UseBoundingSphereOverride: 0 +  m_UseViewFrustumForShadowCasterCull: 1 +  m_ShadowRadius: 0 +  m_ShadowAngle: 0 +--- !u!4 &981251354 +Transform: +  m_ObjectHideFlags: 0 +  m_CorrespondingSourceObject: {fileID: 0} +  m_PrefabInstance: {fileID: 0} +  m_PrefabAsset: {fileID: 0} +  m_GameObject: {fileID: 981251352} +  m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} +  m_LocalPosition: {x: 0, y: 3, z: 0} +  m_LocalScale: {x: 1, y: 1, z: 1} +  m_ConstrainProportionsScale: 0 +  m_Children: [] +  m_Father: {fileID: 0} +  m_RootOrder: 1 +  m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &1848931106 +GameObject: +  m_ObjectHideFlags: 0 +  m_CorrespondingSourceObject: {fileID: 0} +  m_PrefabInstance: {fileID: 0} +  m_PrefabAsset: {fileID: 0} +  serializedVersion: 6 +  m_Component: +  - component: {fileID: 1848931109} +  - component: {fileID: 1848931108} +  - component: {fileID: 1848931107} +  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 &1848931107 +AudioListener: +  m_ObjectHideFlags: 0 +  m_CorrespondingSourceObject: {fileID: 0} +  m_PrefabInstance: {fileID: 0} +  m_PrefabAsset: {fileID: 0} +  m_GameObject: {fileID: 1848931106} +  m_Enabled: 1 +--- !u!20 &1848931108 +Camera: +  m_ObjectHideFlags: 0 +  m_CorrespondingSourceObject: {fileID: 0} +  m_PrefabInstance: {fileID: 0} +  m_PrefabAsset: {fileID: 0} +  m_GameObject: {fileID: 1848931106} +  m_Enabled: 1 +  serializedVersion: 2 +  m_ClearFlags: 1 +  m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, 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: 3 +  m_HDR: 1 +  m_AllowMSAA: 1 +  m_AllowDynamicResolution: 0 +  m_ForceIntoRT: 0 +  m_OcclusionCulling: 1 +  m_StereoConvergence: 10 +  m_StereoSeparation: 0.022 +--- !u!4 &1848931109 +Transform: +  m_ObjectHideFlags: 0 +  m_CorrespondingSourceObject: {fileID: 0} +  m_PrefabInstance: {fileID: 0} +  m_PrefabAsset: {fileID: 0} +  m_GameObject: {fileID: 1848931106} +  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} +  m_LocalPosition: {x: 0, y: 1, z: -10} +  m_LocalScale: {x: 1, y: 1, z: 1} +  m_ConstrainProportionsScale: 0 +  m_Children: [] +  m_Father: {fileID: 0} +  m_RootOrder: 0 +  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/ActiveRagdoll/Assets/New Scene.unity.meta b/ActiveRagdoll/Assets/New Scene.unity.meta new file mode 100644 index 0000000..ee026cd --- /dev/null +++ b/ActiveRagdoll/Assets/New Scene.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1942a6d8982dd124088a31d3bdb55d59 +DefaultImporter: +  externalObjects: {} +  userData:  +  assetBundleName:  +  assetBundleVariant:  diff --git a/Docs/TAB_AddCamera.txt b/Docs/TAB_AddCamera.txt new file mode 100644 index 0000000..d456f6d --- /dev/null +++ b/Docs/TAB_AddCamera.txt @@ -0,0 +1,11 @@ + +        GameObject camera = GameObject.Find("WanderCamera"); +        if(camera != null) +        { +            GameObject.DestroyImmediate(camera);     +        } + +        camera = new GameObject(); +        camera.name = "WanderCamera"; +        camera.AddComponent<Camera>(); +        camera.AddComponent<SimpleMoveCamera>(); diff --git a/Docs/TAB_AddDebugRigidBody.txt b/Docs/TAB_AddDebugRigidBody.txt new file mode 100644 index 0000000..0af5869 --- /dev/null +++ b/Docs/TAB_AddDebugRigidBody.txt @@ -0,0 +1,143 @@ + +GameObject go = GameObject.Find("Player_Target"); +if (go != null) +{ + +	Rigidbody[] rigs = go.transform.GetComponentsInChildren<Rigidbody>(); +	for (int i = 0; i < rigs.Length; i++) +	{ +		var rig = rigs[i]; +		var comps = rig.gameObject.GetComponents<MonoBehaviour>(); +		if (comps != null) +		{ +			for (int j = 0; j < comps.Length; j++) +			{ +				if (comps[j].GetType().Name == "DebugRigidBody" || comps[j].GetType().Name == "DebugRigidBody2") +				{ +					UnityEngine.Object.DestroyImmediate(comps[j]); +				} +			} +		} +		Debug.Log(rig.gameObject.name); +		rig.gameObject.AddComponent<DebugRigidBody>();   +	} +} + + +GameObject mainCam = GameObject.Find("Main Camera"); +if (mainCam != null) +{ +	var comps = mainCam.gameObject.GetComponents<MonoBehaviour>(); +	if (comps != null) +	{ +		for (int j = 0; j < comps.Length; j++) +		{ +			if (comps[j].GetType().Name == "DebugRigidBody" || comps[j].GetType().Name == "DebugRigidBody2") +			{ +				UnityEngine.Object.DestroyImmediate(comps[j]); +			} +		} +	} +	Debug.Log(mainCam.name); +	mainCam.AddComponent<DebugRigidBody>(); +} + + +string name = "RotationTarget"; +GameObject go = GameObject.Find(name); +if (go != null) +{ +    var comps = go.gameObject.GetComponents<MonoBehaviour>(); +    if (comps != null) +    { +        for (int j = 0; j < comps.Length; j++) +        { +            if (comps[j].GetType().Name == "DebugRigidBody" || comps[j].GetType().Name == "DebugRigidBody2") +            { +                UnityEngine.Object.DestroyImmediate(comps[j]); +            } +        } +    } +    Debug.Log(go.name); +    go.AddComponent<DebugRigidBody>(); +} + +string name = "AvaragePosition"; +GameObject go = GameObject.Find(name); +if (go != null) +{ +    var comps = go.gameObject.GetComponents<MonoBehaviour>(); +    if (comps != null) +    { +        for (int j = 0; j < comps.Length; j++) +        { +            if (comps[j].GetType().Name == "DebugRigidBody" || comps[j].GetType().Name == "DebugRigidBody2") +            { +                UnityEngine.Object.DestroyImmediate(comps[j]); +            } +        } +    } +    Debug.Log(go.name); +    go.AddComponent<DebugRigidBody>(); +} + +string name = "CameraRotationY"; +GameObject go = GameObject.Find(name); +if (go != null) +{ +    var comps = go.gameObject.GetComponents<MonoBehaviour>(); +    if (comps != null) +    { +        for (int j = 0; j < comps.Length; j++) +        { +            if (comps[j].GetType().Name == "DebugRigidBody" || comps[j].GetType().Name == "DebugRigidBody2") +            { +                UnityEngine.Object.DestroyImmediate(comps[j]); +            } +        } +    } +    Debug.Log(go.name); +    go.AddComponent<DebugRigidBody>(); +} + + +string name = "CameraRotationX"; +GameObject go = GameObject.Find(name); +if (go != null) +{ +    var comps = go.gameObject.GetComponents<MonoBehaviour>(); +    if (comps != null) +    { +        for (int j = 0; j < comps.Length; j++) +        { +            if (comps[j].GetType().Name == "DebugRigidBody" || comps[j].GetType().Name == "DebugRigidBody2") +            { +                UnityEngine.Object.DestroyImmediate(comps[j]); +            } +        } +    } +    Debug.Log(go.name); +    go.AddComponent<DebugRigidBody>(); +} + + + +string name = "CameraMovement"; +GameObject go = GameObject.Find(name); +if (go != null) +{ +    var comps = go.gameObject.GetComponents<MonoBehaviour>(); +    if (comps != null) +    { +        for (int j = 0; j < comps.Length; j++) +        { +            if (comps[j].GetType().Name == "DebugRigidBody" || comps[j].GetType().Name == "DebugRigidBody2") +            { +                UnityEngine.Object.DestroyImmediate(comps[j]); +            } +        } +    } +    Debug.Log(go.name); +    var drb = go.AddComponent<DebugRigidBody>(); +    drb.mode = DebugRigidBody.EMode.Cube; +}
\ No newline at end of file diff --git a/Docs/TAB_Camera.txt b/Docs/TAB_Camera.txt new file mode 100644 index 0000000..aa09665 --- /dev/null +++ b/Docs/TAB_Camera.txt @@ -0,0 +1,140 @@ + +/// <summary> +/// A simple free camera to be added to a Unity game object. +///  +/// Keys: +///	wasd / arrows	- movement +///	q/e 			- up/down (local space) +///	r/f 			- up/down (world space) +///	pageup/pagedown	- up/down (world space) +///	hold shift		- enable fast movement mode +///	right mouse  	- enable free look +///	mouse			- free look / rotation +///      +/// </summary> +public class SimpleMoveCamera : MonoBehaviour +{ +    /// <summary> +    /// Normal speed of camera movement. +    /// </summary> +    public float movementSpeed = 10f; + +    /// <summary> +    /// Speed of camera movement when shift is held down, +    /// </summary> +    public float fastMovementSpeed = 100f; + +    /// <summary> +    /// Sensitivity for free look. +    /// </summary> +    public float freeLookSensitivity = 3f; + +    /// <summary> +    /// Amount to zoom the camera when using the mouse wheel. +    /// </summary> +    public float zoomSensitivity = 10f; + +    /// <summary> +    /// Amount to zoom the camera when using the mouse wheel (fast mode). +    /// </summary> +    public float fastZoomSensitivity = 50f; + +    /// <summary> +    /// Set to true when free looking (on right mouse button). +    /// </summary> +    private bool looking = false; + +    void Update() +    { +        var fastMode = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift); +        var movementSpeed = fastMode ? this.fastMovementSpeed : this.movementSpeed; + +        if (Input.GetKey(KeyCode.H) || Input.GetKey(KeyCode.LeftArrow)) +        { +            transform.position = transform.position + (-transform.right * movementSpeed * Time.deltaTime); +        } + +        if (Input.GetKey(KeyCode.K) || Input.GetKey(KeyCode.RightArrow)) +        { +            transform.position = transform.position + (transform.right * movementSpeed * Time.deltaTime); +        } + +        if (Input.GetKey(KeyCode.U) || Input.GetKey(KeyCode.UpArrow)) +        { +            transform.position = transform.position + (transform.forward * movementSpeed * Time.deltaTime); +        } + +        if (Input.GetKey(KeyCode.J) || Input.GetKey(KeyCode.DownArrow)) +        { +            transform.position = transform.position + (-transform.forward * movementSpeed * Time.deltaTime); +        } + +        if (Input.GetKey(KeyCode.Q)) +        { +            transform.position = transform.position + (transform.up * movementSpeed * Time.deltaTime); +        } + +        if (Input.GetKey(KeyCode.E)) +        { +            transform.position = transform.position + (-transform.up * movementSpeed * Time.deltaTime); +        } + +        if (Input.GetKey(KeyCode.R) || Input.GetKey(KeyCode.PageUp)) +        { +            transform.position = transform.position + (Vector3.up * movementSpeed * Time.deltaTime); +        } + +        if (Input.GetKey(KeyCode.F) || Input.GetKey(KeyCode.PageDown)) +        { +            transform.position = transform.position + (-Vector3.up * movementSpeed * Time.deltaTime); +        } + +        if (looking) +        { +            float newRotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * freeLookSensitivity; +            float newRotationY = transform.localEulerAngles.x - Input.GetAxis("Mouse Y") * freeLookSensitivity; +            transform.localEulerAngles = new Vector3(newRotationY, newRotationX, 0f); +        } + +        float axis = Input.GetAxis("Mouse ScrollWheel"); +        if (axis != 0) +        { +            var zoomSensitivity = fastMode ? this.fastZoomSensitivity : this.zoomSensitivity; +            transform.position = transform.position + transform.forward * axis * zoomSensitivity; +        } + +        if (Input.GetKeyDown(KeyCode.Mouse1)) +        { +            StartLooking(); +        } +        else if (Input.GetKeyUp(KeyCode.Mouse1)) +        { +            StopLooking(); +        } +    } + +    void OnDisable() +    { +        StopLooking(); +    } + +    /// <summary> +    /// Enable free looking. +    /// </summary> +    public void StartLooking() +    { +        looking = true; +        Cursor.visible = false; +        Cursor.lockState = CursorLockMode.Locked; +    } + +    /// <summary> +    /// Disable free looking. +    /// </summary> +    public void StopLooking() +    { +        looking = false; +        Cursor.visible = true; +        Cursor.lockState = CursorLockMode.None; +    } +}
\ No newline at end of file diff --git a/Docs/TAB_DebugRigidBody.txt b/Docs/TAB_DebugRigidBody.txt new file mode 100644 index 0000000..095c105 --- /dev/null +++ b/Docs/TAB_DebugRigidBody.txt @@ -0,0 +1,135 @@ + +using UnityEngine; + +public class DebugRigidBody : MonoBehaviour +{ + +    public enum EMode +    { +        Axis, +        Cube, +    } +    public EMode mode = EMode.Axis; + +    // When added to an object, draws colored rays from the +    // transform position. +    public int lineCount = 100; +    public float radius = 3.0f; + +    static Material lineMaterial; +    static void CreateLineMaterial() +    { +        if (!lineMaterial) +        { +            // Unity has a built-in shader that is useful for drawing +            // simple colored things. +            Shader shader = Shader.Find("Hidden/Internal-Colored"); +            lineMaterial = new Material(shader); +            lineMaterial.hideFlags = HideFlags.HideAndDontSave; +            // Turn on alpha blending +            lineMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); +            lineMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); +            // Turn backface culling off +            lineMaterial.SetInt("_Cull", (int)UnityEngine.Rendering.CullMode.Off); +            // Turn off depth writes +            lineMaterial.SetInt("_ZWrite", 0); +        } +    } + +    private void PutVertex(Vector3 vert) +    { +        GL.Vertex3(vert.x, vert.y, vert.z); +    } + +    // Will be called after all regular rendering is done +    public void OnRenderObject() +    { +        CreateLineMaterial(); +        // Apply the line material +        lineMaterial.SetPass(0); + +        if (mode == EMode.Axis) +        { +            GL.PushMatrix(); +            // Set transformation matrix for drawing to +            // match our transform +            GL.MultMatrix(transform.localToWorldMatrix); + +            // Draw lines +            GL.Begin(GL.LINES); + +            float len = 0.3f; + +            GL.Color(Color.red); +            PutVertex(Vector3.zero); +            PutVertex(Vector3.right * len); + +            GL.Color(Color.green); +            PutVertex(Vector3.zero); +            PutVertex(Vector3.up * len); + +            GL.Color(Color.blue); +            PutVertex(Vector3.zero); +            PutVertex(Vector3.forward * len); + +            GL.End(); +            GL.PopMatrix(); +        } +        else if (mode == EMode.Cube) +        { +            GL.PushMatrix(); +            // Set transformation matrix for drawing to +            // match our transform +            GL.MultMatrix(transform.localToWorldMatrix); + +            float len = 0.05f; + +            GL.wireframe = true; + +            GL.Begin(GL.QUADS); + +            GL.Color(Color.white); + +            GL.Vertex3(len, len, -len); +            GL.Vertex3(-len, len, -len); +            GL.Vertex3(-len, len, len); +            GL.Vertex3(len, len, len); + +            // Bottom face (y = -len) +            GL.Vertex3(len, -len, len); +            GL.Vertex3(-len, -len, len); +            GL.Vertex3(-len, -len, -len); +            GL.Vertex3(len, -len, -len); + +            // Front face  (z = len) +            GL.Vertex3(len, len, len); +            GL.Vertex3(-len, len, len); +            GL.Vertex3(-len, -len, len); +            GL.Vertex3(len, -len, len); + +            // Back face (z = -len) +            GL.Vertex3(len, -len, -len); +            GL.Vertex3(-len, -len, -len); +            GL.Vertex3(-len, len, -len); +            GL.Vertex3(len, len, -len); + +            // Left face (x = -len) +            GL.Vertex3(-len, len, len); +            GL.Vertex3(-len, len, -len); +            GL.Vertex3(-len, -len, -len); +            GL.Vertex3(-len, -len, len); + +            // Right face (x = len) +            GL.Vertex3(len, len, -len); +            GL.Vertex3(len, len, len); +            GL.Vertex3(len, -len, len); +            GL.Vertex3(len, -len, -len); +            GL.End();  // End of drawing color-cube + +            GL.wireframe = false; + +            GL.PopMatrix(); +        } +    } + +} diff --git a/Docs/TAB_UnityExploerer.txt b/Docs/TAB_UnityExploerer.txt new file mode 100644 index 0000000..ed028a6 --- /dev/null +++ b/Docs/TAB_UnityExploerer.txt @@ -0,0 +1,28 @@ +// To start a Coroutine directly, use "Start(SomeCoroutine());" in REPL mode. + +// To declare a coroutine, you will need to compile it separately. For example: +public class MyCoro +{ +    public static IEnumerator Main() +    { +		while(true){ +			GameObject go = GameObject.Find("Player_Target"); +			if(go != null ) { +				Rigidbody[] rigs = go.transform.GetComponentsInChildren<Rigidbody>(); +				for(int i = 0; i < rigs.Length; i++) {  +					var rig = rigs[i]; +					//Debug.Log(rig.gameObject.name); +					Debug.DrawLine(rig.transform.position, rig.transform.position + 10*rig.transform.forward); +				} +			} +			yield return null; +	    } +    } +} +// To run this Coroutine in REPL, it would look like "Start(MyCoro.Main());" + + + + + +Start(MyCoro.Main());
\ No newline at end of file diff --git a/Docs/资料.xlsx b/Docs/资料.xlsx Binary files differindex 0d25766..cd5fd1f 100644 --- a/Docs/资料.xlsx +++ b/Docs/资料.xlsx  | 
