示例#1
0
    public override void OnInspectorGUI()
    {
        GUILayout.BeginHorizontal();

        if (GUILayout.Button("RemoveAll"))
        {
            database.ClearDatabase();
        }
        if (GUILayout.Button("Remove"))
        {
            database.RemoveCurrentElement();
        }
        if (GUILayout.Button("Add"))
        {
            database.AddElement();
        }
        if (GUILayout.Button("<="))
        {
            database.GetPrev();
        }
        if (GUILayout.Button("=>"))
        {
            database.GetNext();
        }

        GUILayout.EndHorizontal();
        base.OnInspectorGUI();
    }
示例#2
0
    /// <summary>
    /// Spawn the keys and send data to their classes to Initialize them
    /// </summary>
    private void SpawnKeys()
    {
        keysDataBase.ResetCurrentIndex();

        keysNumber = rand.Next(1, Mathf.Min(keysDataBase.GetLength() + 1, 4));
        Debug.Log(keysNumber);
        for (int i = 0; i < keysNumber; i++)
        {
            if (i >= KeysSpawned.Count)
            {
                var obj = Instantiate(KeysPrefab, GetRandomPositionOnNavMesh(), Quaternion.Euler(90, 0, 0));
                KeysSpawned.Add(obj.GetComponentInChildren <KeyObject>());
                Keys.Add(KeysSpawned[i], obj);
            }
            else
            {
                Keys[KeysSpawned[i]].SetActive(true);
                Keys[KeysSpawned[i]].transform.position = GetRandomPositionOnNavMesh();
                Keys[KeysSpawned[i]].transform.rotation = Quaternion.Euler(Camera.main.transform.rotation.eulerAngles.x, 0, 0);
            }
            Keys[KeysSpawned[i]].SetActive(true);
            KeysData keyData;
            if (i == 0)
            {
                keyData = keysDataBase.GetPrev();
            }
            else
            {
                keyData = keysDataBase.GetNext();
            }

            KeysSpawned[i].Init(keyData);
        }
    }