Ejemplo n.º 1
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }
#if (UNITY_EDITOR)
        Cleanup();
#endif
        disableHexTypes = new List <HexTypeHolder>();
    }
Ejemplo n.º 2
0
    void LoadHexTiles()
    {
        mapSpawner = ((MonoBehaviour)target).gameObject.GetComponent <MapSpawner>();
        if (mapSpawner != null)
        {
            GameObject[] loadedHexes = Resources.LoadAll <GameObject>(directoryToLoad.ToString());
            GameObject[] outHexes    = new GameObject[loadedHexes.Length];
            for (int i = 0; i < loadedHexes.Length; i++)
            {
                if (loadedHexes[i].layer == LayerMask.NameToLayer("Hex"))
                {
                    // if (loadedHexes[i].GetComponent<Hex>())
                    // {
                    outHexes[i] = loadedHexes[i];
                    // }
                }
            }

            Debug.Log("Loaded Hex Object count = " + loadedHexes.Length);

            Debug.Log("Accepted Hex Object count = " + outHexes.Length);
            //mapSpawner.PopulateSoundEffectsArray(loadedClips, Application.isEditor);

            HexBank hexBank = ((MonoBehaviour)target).gameObject.GetComponent <HexBank>();
            if (hexBank != null)
            {
                Undo.RecordObject(hexBank, " Changed HexBank Array");


                hexBank.hexPrefabs = outHexes;

                GenerateHexTypeEnum(outHexes, "HexTypeEnum");


                EditorUtility.SetDirty(hexBank);
                serializedObject.ApplyModifiedProperties();
            }
        }
        else
        {
            Debug.LogWarning("Failed to load hex prefabs. mapSpawner instance is null.");
        }
    }