Esempio n. 1
0
    void Awake()
    {
        NavManagerProvider provider = (NavManagerProvider)FindObjectOfType(typeof(NavManagerProvider));

        if (provider == null)
        {
            Debug.LogError(string.Format("{0}: There is no {1} in the scene."
                                         , name, typeof(NavManagerProvider).Name));

            return;
        }


        NavManager manager = provider.CreateManager();

        if (manager == null)
        {
            Debug.LogError(string.Format("{0}: Could not get the navigation manager.", name));

            return;
        }

        mHelper = manager.NavGroup;

        //mPath = new BufferHandler<uint>();

        isInit = true;
    }
Esempio n. 2
0
    private bool Initialize()
    {
        if (mState != null)
        {
            mState.Exit();
        }

        mState = null;

        NavManagerProvider provider =
            (NavManagerProvider)FindObjectOfType(typeof(NavManagerProvider));

        if (provider == null)
        {
            Debug.LogError(string.Format("{0}: There is no {1} in the scene."
                                         , name, typeof(NavManagerProvider).Name));

            return(false);
        }

        NavManager manager = provider.CreateManager();

        if (manager == null)
        {
            Debug.LogError(string.Format("{0}: Could not get the navigation manager.", name));

            return(false);
        }

        mHelper = manager.NavGroup;

        return(true);
    }
Esempio n. 3
0
    void Start()
    {
        NavManagerProvider provider = (NavManagerProvider)FindObjectOfType(typeof(NavManagerProvider));

        if (provider == null)
        {
            Debug.LogError(string.Format("{0}: There is no {1} in the scene."
                                         , name, typeof(NavManagerProvider).Name));

            enabled = false;
            return;
        }

        NavManager.ActiveManager = provider.CreateManager();  // Provides error reporting.

        if (NavManager.ActiveManager == null)
        {
            enabled = false;
            return;
        }

        mManager = NavManager.ActiveManager;
        mNav     = mManager.NavGroup;

        SimGUIUtil.contextHelpText = string.Format(
            "Agent: Add: [{0}], Select: [{1}], Move Selected: [{2}]"
            , StdButtons.SetA, StdButtons.SelectB, StdButtons.SelectA);

        SimGUIUtil.contextControlZone.height = SimGUIUtil.LineHeight + SimGUIUtil.Margin;
        SimGUIUtil.contextActive             = true;
    }
Esempio n. 4
0
    void Start()
    {
        if (agentA == null || agentB == null || agentC == null)
        {
            Debug.LogError(name + ": One or more agents are not assigned.");
            enabled = false;
            return;
        }

        NavManagerProvider provider =
            (NavManagerProvider)FindObjectOfType(typeof(NavManagerProvider));

        if (provider == null)
        {
            Debug.LogError(string.Format("{0}: There is no {1} in the scene."
                                         , name, typeof(NavManagerProvider).Name));

            enabled = false;
            return;
        }

        NavManager.ActiveManager = provider.CreateManager();  // Provides error reporting.

        if (NavManager.ActiveManager == null)
        {
            enabled = false;
            return;
        }

        mManager = NavManager.ActiveManager;
        mNav     = mManager.NavGroup;

        SimGUIUtil.contextHelpText = string.Format(
            "Agent: Add: [{0}], Select: [{1}], Move Selected: [{2}]"
            , StdButtons.SetA, StdButtons.SelectB, StdButtons.SelectA);

        SimGUIUtil.contextControlZone.height = SimGUIUtil.LineHeight + SimGUIUtil.Margin;
        SimGUIUtil.contextActive             = true;

        mCam = Camera.main;

        agentNames = GetComponent <StringList>().values;
    }
Esempio n. 5
0
    private bool InitializeNav()
    {
        NavManagerProvider provider =
            (NavManagerProvider)FindObjectOfType(typeof(NavManagerProvider));

        if (provider == null)
        {
            Debug.LogError(string.Format("{0}: There is no {1} in the scene."
                                         , name, typeof(NavManagerProvider).Name));

            return(false);
        }

        NavManager manager = provider.CreateManager();

        if (manager == null)
        {
            Debug.LogError(string.Format("{0}: Could not get the navigation manager.", name));

            return(false);
        }

        mGroup = manager.NavGroup;

        maxPathSize = Mathf.Max(1, maxPathSize);

        mPath = new BufferHandler <uint>(
            "Max Path Size", 1, maxPathSize, 1, Mathf.Max(100, maxPathSize));

        mPathStart = new NavmeshPoint();
        mPathEnd   = new NavmeshPoint();

        maxCorners = Mathf.Max(1, maxCorners);

        mCornerPolys =
            new BufferHandler <uint>("Max Corner Size", 1, maxCorners, 1, Mathf.Max(maxCorners, 20));

        HandlePathBufferResize();

        return(true);
    }