Esempio n. 1
0
    //-----------------------------------------------------------------------------------------------
    public override void OnInspectorGUI()
    {
        m_selectedManager.m_agentPrefab = (GameObject)EditorGUILayout.ObjectField("Agent Prefab", m_selectedManager.m_agentPrefab, typeof(GameObject), false);

        // Active agent listing
        GUILayout.Label("Active Agents", EditorStyles.boldLabel);
        List <Agent> activeAgents = m_selectedManager.ActiveAgents;

        for (int agentIndex = 0; agentIndex < activeAgents.Count; ++agentIndex)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(agentIndex.ToString());

            if (GUILayout.Button("-", GUILayout.Width(20f)))
            {
                m_selectedManager.RemoveAgentAtIndex(agentIndex);
            }
            else
            {
                EditorGUILayout.ObjectField(activeAgents[agentIndex], typeof(Agent), true);
            }

            GUILayout.EndHorizontal();
        }

        // Proper way to add agents
        if (GUILayout.Button("Add Agent"))
        {
            m_selectedManager.AddAgent();
        }

        // If anything changed, we redraw the scene
        if (GUI.changed)
        {
            SceneView.RepaintAll();
        }

        // Useful to just have around while developing
        // Feel free to comment out anything below this
        DrawDefaultInspector();
    }
Esempio n. 2
0
    // General functions
    public void Travel(AISpawner from, AISpawner to)
    {
        manager.AddAgent(this);

        _target  = to;
        _spawner = from;

        UpdateDestination();

        _moveMultiplier  = 1.0f;
        _steerMultiplier = 1.0f;

        if (pedestrianRenderer)
        {
            pedestrianRenderer.material.SetFloat("_Offset", UnityEngine.Random.value);
        }
        if (umbrellaRenderer)
        {
            umbrellaRenderer.material.SetFloat("_Offset", UnityEngine.Random.value);
        }
    }