public override void OnEnter() { Done = false; _doneNextFrame = false; HUDDisplay.Instance.ToggleVisibility(false); if (Blackboard.IsDebug) { return; } // the parameter int remainingParamCount = Blackboard.ParametersDescriptions.Length - Blackboard.ResultParameters.Count; GameAction.ParameterDescription[] remainingParams = ArrayX.SubArray(Blackboard.ParametersDescriptions, Blackboard.ResultParameters.Count, remainingParamCount); if (remainingParams.Length < 1) { OnSurveyCancel(); return; } SurveyBaseController surveyPrefab = Blackboard.ActionAuth.FindCustomSurveyPrefabForParameters(remainingParams); if (surveyPrefab != null) { SurveyManager.Instance.BeginSurvey(Blackboard.Cache.LocalPawnPositionFloat, Blackboard.UseContext, Blackboard.ResultParameters, remainingParams, surveyPrefab, OnSurveyComplete, OnSurveyCancel); } else { // default case Blackboard.ResultParameters.Add(null); _doneNextFrame = true; //GameAction.ParameterDescription parameterToHandle = remainingParams[0]; //SurveyManager.Instance.BeginDefaultSurvey(Blackboard.Cache.LocalPawnPositionFloat, Blackboard.UseContext, Blackboard.ResultParameters, parameterToHandle, OnSurveyComplete, OnSurveyCancel); } }
/// <summary> /// Raises the scene GUI event. /// </summary> void OnSceneGUI() { if (!s_HitboxTogglePreference.CurrentValue) { return; } Matrix4x4 oldMatrix = Handles.matrix; Color oldColor = Handles.color; Handles.color = s_HitboxColorPreference.CurrentValue; int[] wrap = new int[] { 1, 2, 3, 0 }; HyperText hyperText; foreach (GameObject go in Selection.gameObjects) { hyperText = go.GetComponent <HyperText>(); if (hyperText == null) { continue; } Handles.matrix = hyperText.transform.localToWorldMatrix; hyperText.GetLinkHitboxes(ref m_LinkHitboxes); foreach (KeyValuePair <HyperText.LinkInfo, List <Rect> > linkHitboxes in m_LinkHitboxes) { Vector2 center = Vector2.zero; foreach (Rect hitbox in linkHitboxes.Value) { Vector3[] vertices = new Vector3[] { Vector3.right *hitbox.xMin + Vector3.up *hitbox.yMax, Vector3.right *hitbox.xMax + Vector3.up *hitbox.yMax, Vector3.right *hitbox.xMax + Vector3.up *hitbox.yMin, Vector3.right *hitbox.xMin + Vector3.up *hitbox.yMin, }; // draw a box around each hitbox for (int i = 0; i < vertices.Length; ++i) { Handles.DrawLine(vertices[i], vertices[wrap[i]]); } center += hitbox.center; } center /= linkHitboxes.Value.Count; // indicate the name for each link Handles.Label( center, string.Format( "{0}{1}", linkHitboxes.Key.Name, string.IsNullOrEmpty(linkHitboxes.Key.ClassName) ? "" : string.Format(" ({0})", linkHitboxes.Key.ClassName) ) ); } int scrollAmt = 0; m_CurrentlyHighlightedVertexIndex = Mathf.Clamp(m_CurrentlyHighlightedVertexIndex, 0, s_DebugSceneModeVertices.Count); if (s_DebugSceneModePreference.CurrentValue == DebugSceneMode.VertexIndices) { scrollAmt = 1; s_DebugSceneModeVertices.Clear(); #if IS_VBO_UI_VERTEX s_DebugSceneModeVertices.AddRange( from v in hyperText.GetFieldValue <List <UIVertex> >("m_UIVertices") select v.position ); #else s_DebugSceneModeVertices.AddRange(hyperText.GetFieldValue <Mesh>("m_GlyphMesh").vertices); #endif for (int i = 0; i < s_DebugSceneModeVertices.Count; ++i) { Handles.Label(s_DebugSceneModeVertices[i], i.ToString()); if (i == m_CurrentlyHighlightedVertexIndex) { HighlightIndex(s_DebugSceneModeVertices[i], i); } } if (Event.current.isKey && Event.current.type == EventType.KeyDown) { switch (Event.current.keyCode) { case KeyCode.Comma: case KeyCode.Less: scrollAmt *= -1 * (Event.current.shift ? 12 : 1); break; case KeyCode.Period: case KeyCode.Greater: scrollAmt *= 1 * (Event.current.shift ? 12 : 1); break; default: scrollAmt = 0; break; } Event.current.Use(); m_CurrentlyHighlightedVertexIndex = ArrayX.ScrollArrayIndex( m_CurrentlyHighlightedVertexIndex, s_DebugSceneModeVertices.Count, scrollAmt ); } } } Handles.color = oldColor; Handles.matrix = oldMatrix; }
/// <summary> /// Displays the scene GUI handles. /// </summary> protected override void DisplaySceneGUIHandles() { base.DisplaySceneGUIHandles(); if (s_HitboxTogglePreference.CurrentValue) { Color oldColor = Handles.color; Handles.color = s_HitboxColorPreference.CurrentValue; this.Target.GetLinkHitboxes(m_LinkHitboxes); foreach (KeyValuePair <HyperText.LinkInfo, List <Rect> > linkHitboxes in m_LinkHitboxes) { Vector2 center = Vector2.zero; foreach (Rect hitbox in linkHitboxes.Value) { s_HitboxVertices[0] = Vector3.right * hitbox.xMin + Vector3.up * hitbox.yMax; s_HitboxVertices[1] = Vector3.right * hitbox.xMax + Vector3.up * hitbox.yMax; s_HitboxVertices[2] = Vector3.right * hitbox.xMax + Vector3.up * hitbox.yMin; s_HitboxVertices[3] = Vector3.right * hitbox.xMin + Vector3.up * hitbox.yMin; // draw a box around each hitbox for (int i = 0; i < s_HitboxVertices.Length; ++i) { Handles.DrawLine(s_HitboxVertices[i], s_HitboxVertices[s_QuadIndexWrap[i]]); } center += hitbox.center; } center /= linkHitboxes.Value.Count; // indicate the name for each link Handles.Label( center, string.Format( "{0}{1}", linkHitboxes.Key.Name, string.IsNullOrEmpty(linkHitboxes.Key.ClassName) ? "" : string.Format(" ({0})", linkHitboxes.Key.ClassName) ) ); } Handles.color = oldColor; } if (s_DebugSceneModePreference.CurrentValue == DebugSceneMode.VertexIndices) { int scrollAmt = 1; m_CurrentlyHighlightedVertexIndex = Mathf.Clamp(m_CurrentlyHighlightedVertexIndex, 0, s_DebugSceneModeVertices.Count); s_DebugSceneModeVertices.Clear(); #if IS_VBO_UI_VERTEX s_DebugSceneModeVertices.AddRange( from v in this.Target.GetFieldValue <List <UIVertex> >("m_UIVertices") select v.position ); #else s_DebugSceneModeVertices.AddRange(this.Target.GetFieldValue <Mesh>("m_GlyphMesh").vertices); #endif for (int i = 0; i < s_DebugSceneModeVertices.Count; ++i) { Handles.Label(s_DebugSceneModeVertices[i], i.ToString()); if (i == m_CurrentlyHighlightedVertexIndex) { HighlightIndex(s_DebugSceneModeVertices[i], i); } } if (Event.current.isKey && Event.current.type == EventType.KeyDown) { switch (Event.current.keyCode) { case KeyCode.Comma: case KeyCode.Less: scrollAmt *= -1 * (Event.current.shift ? 12 : 1); break; case KeyCode.Period: case KeyCode.Greater: scrollAmt *= 1 * (Event.current.shift ? 12 : 1); break; default: scrollAmt = 0; break; } Event.current.Use(); m_CurrentlyHighlightedVertexIndex = ArrayX.ScrollArrayIndex( m_CurrentlyHighlightedVertexIndex, s_DebugSceneModeVertices.Count, scrollAmt ); } } }