dynamic loading of gate prefabs
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VectorGraphics;
|
||||
using UnityEngine;
|
||||
using UntitledLogicGame.Workspace;
|
||||
|
||||
@@ -26,6 +27,9 @@ namespace UntitledLogicGame
|
||||
|
||||
[Header("Prefabs")]
|
||||
public Cable CablePrefab;
|
||||
public Gate GatePrefab;
|
||||
public Anchor AnchorPrefab;
|
||||
public Anchor BigAnchorPrefab;
|
||||
|
||||
[Header("Groups")]
|
||||
public Transform GatesGroup;
|
||||
@@ -36,12 +40,14 @@ namespace UntitledLogicGame
|
||||
public Color ActivatedColor;
|
||||
|
||||
[Header("Gates")]
|
||||
public List<Gate> GatePrefabs;
|
||||
public TextAsset GateBook;
|
||||
public List<Sprite> GateSprites;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
|
||||
|
||||
public List<Gate> GatePrefabs { get; set; }
|
||||
public Anchor CurrentAnchor { get; set; }
|
||||
public Gate CurrentGate { get; set; }
|
||||
public PointerManager PointerManager
|
||||
@@ -64,6 +70,13 @@ namespace UntitledLogicGame
|
||||
|
||||
#region Unity Methods
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var factory = gameObject.AddComponent<GatePrefabFactory>();
|
||||
factory.Init(GatePrefab, AnchorPrefab, BigAnchorPrefab, GateSprites);
|
||||
GatePrefabs = factory.GeneratePrefabs(GateBook);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
@@ -71,6 +84,7 @@ namespace UntitledLogicGame
|
||||
public void CreateGate(Gate gatePrefab)
|
||||
{
|
||||
var gate = Instantiate(gatePrefab, GatesGroup);
|
||||
gate.gameObject.SetActive(true);
|
||||
gate.transform.position = PointerManager.MousePos - gate.Box.transform.position;
|
||||
PointerManager.DragGate(gate, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user