Exemple #1
0
    void Update()
    {
        if (Time.frameCount % 30 == 0)
        {
            System.GC.Collect();
        }

        SimGUIUtil.Update();

        if (!SimGUIUtil.hasHit)
        {
            mHitAgent = null;
            return;
        }

        mHitAgent = SimGUIUtil.hit.collider.gameObject.GetComponent <Agent>();

        // Handle Keyboard Input

        // The second input isn't shown in the help text.  But it is a logical
        // usability input.
        if (Input.GetKeyDown(StdButtons.SelectB) ||
            (mActiveAgent == null && Input.GetKeyDown(StdButtons.SelectA)))
        {
            SetActiveAgent(mHitAgent);
            return;
        }

        if (Input.GetKeyDown(StdButtons.SetA) && mManager.GetAgentCount() < mManager.MaxAgents)
        {
            AddWanderAgent(SimGUIUtil.hit.point);
            return;
        }
    }
Exemple #2
0
    void OnGUI()
    {
        if (mHitAgent != null)
        {
            Vector3 pos = mHitAgent.transform.position;
            pos.y += 2;

            pos = mCam.WorldToScreenPoint(pos);

            Rect rect = new Rect(pos.x - 10, Screen.height - pos.y - 15, 100, 22);

            GUI.Label(rect, mHitAgent.name);
        }

        GUILayout.BeginArea(SimGUIUtil.contextControlZone, GUI.skin.box);
        GUILayout.BeginHorizontal();

        GUILayout.Label("Agent Count: " + mNav.crowd.AgentCount);

        if (GUILayout.Button("Clear Agents"))
        {
            Agent[] agents = (Agent[])FindSceneObjectsOfType(typeof(Agent));
            foreach (Agent agent in agents)
            {
                Destroy(agent.gameObject);
            }
            mActiveAgent = null;
        }

        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        SimGUIUtil.OnGUI();
    }
Exemple #3
0
        public void Enter(NavGroup helper)
        {
            mHelper = helper;
            SimGUIUtil.BuildLabelRegion(false);

            mPolyRefs = new BufferHandler <uint>("Search Buffer Size"
                                                 , 1, QEUtil.SmallBufferInit, 1, QEUtil.SmallBufferMax);

            int size = mPolyRefs.MaxElementCount;

            mParentRefs = new uint[size];
            mCosts      = new float[size];
            mCentroids  = new Vector3[size];

            mResultCount = 0;
            mHasPosition = false;

            SimGUIUtil.contextHelpText = string.Format(
                "Scale Search: [{0}] [{1}], Translate Search Y: [{2}] [{3}]"
                , StdButtons.AdjustXZMinus, StdButtons.AdjustXZPlus
                , StdButtons.AdjustYMinus, StdButtons.AdjustYPlus);

            SimGUIUtil.contextControlZone.height = SimGUIUtil.LineHeight * 2.5f;
            SimGUIUtil.contextActive             = true;
        }
Exemple #4
0
 void Update()
 {
     if (Time.frameCount % 30 == 0)
     {
         System.GC.Collect();
     }
     SimGUIUtil.Update();
 }
Exemple #5
0
        public void Enter(NavGroup helper)
        {
            mHelper = helper;
            SimGUIUtil.BuildLabelRegion(false);

            mHasPosition = false;
            mHasHeight   = false;

            SimGUIUtil.contextHelpText           = string.Format("Select Poly: [{0}]", StdButtons.SelectA);
            SimGUIUtil.contextControlZone.height = 0;
            SimGUIUtil.contextActive             = true;
        }
Exemple #6
0
        public void Enter(NavGroup helper)
        {
            mHelper = helper;
            SimGUIUtil.BuildLabelRegion(false);

            mSelectedPoly[0] = 0;
            mSegmentCount    = 0;

            SimGUIUtil.contextHelpText           = "";
            SimGUIUtil.contextControlZone.height = 0;
            SimGUIUtil.contextActive             = true;
        }
Exemple #7
0
        public void Enter(NavGroup helper)
        {
            mHelper = helper;
            SimGUIUtil.BuildLabelRegion(false);

            mHasPosition = false;
            mHasWallHit  = false;

            SimGUIUtil.contextHelpText = string.Format("Scale Search Radius: [{0}] [{1}]"
                                                       , StdButtons.AdjustXZMinus, StdButtons.AdjustXZPlus);

            SimGUIUtil.contextActive = true;
        }
Exemple #8
0
 public static bool InControlZone(Vector3 position)
 {
     if (SimGUIUtil.hideGUI)
     {
         return(false);
     }
     if (SimGUIUtil.InControlZone(position))
     {
         return(true);
     }
     position.y = Screen.height - position.y;
     return(buttonZone.Contains(position));
 }
Exemple #9
0
        public void Enter(NavGroup helper)
        {
            mHelper = helper;
            SimGUIUtil.BuildLabelRegion(false);

            mHasSearchPoint = false;
            mFoundPoly      = false;

            SimGUIUtil.contextHelpText = string.Format("Scale Search: [{0}] [{1}] [{2}] [{3}]"
                                                       , StdButtons.AdjustXZMinus, StdButtons.AdjustXZPlus
                                                       , StdButtons.AdjustYMinus, StdButtons.AdjustYPlus);

            SimGUIUtil.contextActive = true;
        }
Exemple #10
0
        public void Enter(NavGroup helper)
        {
            mHelper = helper;
            SimGUIUtil.BuildLabelRegion(false);

            mHasPosition     = false;
            mHasNearestPoint = false;

            SimGUIUtil.contextHelpText = string.Format(
                "Select Poly: [{0}], Translate Y: [{1}] [{2}]"
                , StdButtons.SelectA, StdButtons.AdjustYMinus, StdButtons.AdjustYPlus);

            SimGUIUtil.contextControlZone.height = 0;
            SimGUIUtil.contextActive             = true;
        }
Exemple #11
0
        public void Enter(NavGroup helper)
        {
            this.mHelper      = helper;
            mPosition.polyRef = 0;
            mGoal.polyRef     = 0;

            SimGUIUtil.BuildLabelRegion(false);

            mPolyRefs = new BufferHandler <uint>("Visited Buffer Size"
                                                 , 1, QEUtil.SmallBufferInit, 1, QEUtil.SmallBufferMax);

            mStraightPath = new Vector3[mPolyRefs.MaxElementCount];

            SimGUIUtil.contextControlZone.height = SimGUIUtil.LineHeight * 2.5f;
            SimGUIUtil.contextActive             = true;
        }
Exemple #12
0
        public void Enter(NavGroup helper)
        {
            mHelper           = helper;
            mPosition.polyRef = 0;
            mGoal.polyRef     = 0;

            SimGUIUtil.BuildLabelRegion(false);

            mPolyRefs = new BufferHandler <uint>("Buffer size"
                                                 , 1, QEUtil.SmallBufferInit, 1, QEUtil.SmallBufferMax);

            mResultCount = 0;

            SimGUIUtil.contextControlZone.height = SimGUIUtil.LineHeight * 2.5f;
            SimGUIUtil.contextActive             = true;
        }
Exemple #13
0
        public void Enter(NavGroup helper)
        {
            mHelper = helper;

            SimGUIUtil.BuildLabelRegion(false);

            mPolyRefs = new BufferHandler <uint>("Search Buffer"
                                                 , 1, QEUtil.SmallBufferInit, 1, QEUtil.SmallBufferMax);

            mResultCount = 0;

            SimGUIUtil.contextHelpText = string.Format("Scale Search: [{0}] [{1}] [{2}] [{3}]"
                                                       , StdButtons.AdjustXZMinus, StdButtons.AdjustXZPlus
                                                       , StdButtons.AdjustYMinus, StdButtons.AdjustYPlus);

            SimGUIUtil.contextControlZone.height = SimGUIUtil.LineHeight * 2.5f;
            SimGUIUtil.contextActive             = true;
        }
Exemple #14
0
        public virtual void Enter(NavGroup helper)
        {
            this.helper = helper;

            pathCount        = 0;
            position.polyRef = 0;
            goal.polyRef     = 0;

            SimGUIUtil.BuildLabelRegion(false);

            path =
                new BufferHandler <uint>("Path Buffer", 1, QEUtil.SmallBufferInit, 1, MaxPathBuffer);

            mLocalMessage = "No path";
            SimGUIUtil.contextHelpText           = "";
            SimGUIUtil.contextControlZone.height = SimGUIUtil.LineHeight * 5.5f;
            SimGUIUtil.contextActive             = true;
        }
    void Update()
    {
        if (Time.timeScale == 0)
        {
            return;
        }

        mOptimizeTimer -= Time.deltaTime;

        if (!SimGUIUtil.InControlZone(Input.mousePosition))
        {
            Ray        ray = mCam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, raycastLength))
            {
                HandleHit(hit);
            }
        }

        SimGUIUtil.contextHelpText = HelpText;
    }
Exemple #16
0
    void OnGUI()
    {
        if (Time.timeScale == 0 || SimGUIUtil.hideGUI)
        {
            return;
        }

        if (State == QEStateType.Inactive)
        {
            // Something broke.
            return;
        }

        QEUtil.buttonZone = new Rect(SimGUIUtil.sysControlZone.xMin
                                     , SimGUIUtil.sysControlZone.yMax + SimGUIUtil.Margin
                                     , SimGUIUtil.sysControlZone.width
                                     , toolBarText.Length * SimGUIUtil.LineHeight + SimGUIUtil.Margin);

        GUILayout.BeginArea(QEUtil.buttonZone, GUI.skin.box);

        QEStateType sn = (QEStateType)GUILayout.SelectionGrid((int)State
                                                              , toolBarText
                                                              , 1
                                                              , GUI.skin.toggle);

        GUILayout.EndArea();

        if (sn != State)
        {
            SetState(sn);
        }

        if (mState != null)
        {
            mState.OnGUI();
        }

        SimGUIUtil.OnGUI();
    }
 private void InitializeGUI()
 {
     SimGUIUtil.BuildLabelRegion(true);
     SimGUIUtil.contextControlZone.height = ControlAreaHeight;
     SimGUIUtil.contextActive             = true;
 }
Exemple #18
0
 void Awake()
 {
     SimGUIUtil.Initialize();
     SimGUIUtil.sysHelpText = MainHelpText;
 }
 void Awake()
 {
     SimGUIUtil.Initialize();
 }
    void OnGUI()
    {
        if (SimGUIUtil.hideGUI || mGroup.mesh == null)
        {
            return;
        }

        LabelRegion labels = SimGUIUtil.labels;

        labels.Clear();

        if (mPathCount == 0)
        {
            labels.Last = "No path.";
            SimGUIUtil.OnGUI();
            return;
        }

        GUILayout.BeginArea(SimGUIUtil.contextControlZone, GUI.skin.box);

        if (GUILayout.Button("Optimize Topology"))
        {
            mCorridor.OptimizePathTopology(true);
        }

        GUI.enabled = (mPathEnd.polyRef != 0);
        if (GUILayout.Button("Replan Path"))
        {
            FindPath();
        }

        GUI.enabled = true;

        mPath.OnGUI();
        if (mPath.HandleResize())
        {
            HandlePathBufferResize();
        }

        mCornerPolys.OnGUI();
        if (mCornerPolys.HandleResize())
        {
            mCorridor.ResizeCornerBuffer(mCornerPolys.MaxElementCount);
        }

        GUILayout.Label("Optimiation Range");

        GUILayout.BeginHorizontal();

        optimizationRange = (int)GUILayout.HorizontalSlider(optimizationRange, 1, 30);

        GUILayout.Label(optimizationRange.ToString());

        GUILayout.EndHorizontal();

        GUILayout.EndArea();

        const int LabelCount = 2;
        int       slotIndex  = labels.SlotCount - LabelCount;

        string msg = mCorridor.Corners.cornerCount + " of " + (mCorridor.Corners.MaxCorners - 1);

        labels.Set(slotIndex++, "Detected Corners", msg);

        msg = mPathCount + " of " + mCorridor.MaxPathSize;
        labels.Set(slotIndex++, "Corridor Polygons", msg);

        SimGUIUtil.OnGUI();
    }