Beispiel #1
0
    //=====================================================

    private static void AddSwitchOfType(eSwitchType type)
    {
        Object pfb = null;

        switch (type)
        {
        default:
            pfb = ResourcesSwitches.GetPrefab();
            break;

        case eSwitchType.PRESSURE:
            pfb = ResourcesSwitches.GetPrefab(eSwitchType.PRESSURE);
            break;
        }

        if (pfb == null)
        {
            return;
        }

        var mdl = ResourcesSwitches.GetModel(type, 0);

        var prefab = PrefabUtility.InstantiatePrefab(pfb) as GameObject;

        if (prefab == null)
        {
            return;
        }

        var script = prefab.GetComponent <Switch>();

        switch (type)
        {
        case eSwitchType.FLOOR_LEVER:
            prefab.name = "Switch-Floor-0";
            break;

        case eSwitchType.WALL_SWITCH:
            prefab.name = "Switch-Wall-0";
            break;

        case eSwitchType.PRESSURE:
            prefab.name = "Switch-Pressure-0";
            break;
        }

        if (script != null)
        {
            script.Type = type;

            if (mdl != null)
            {
                var model = PrefabUtility.InstantiatePrefab(mdl) as GameObject;

                script.Init(model);
            }
        }

        PositionObjectAndSelect(prefab);
    }
Beispiel #2
0
    //=====================================================

    public void Refresh()
    {
        CheckReferences();

        // Update switch name with index e.g. Switch-Floor-0, Switch-Wall-1
        ResetName();

        // Update switch-model
        //Debug.Log( "Model type: " + _type + " : " + _model );
        var mdlSwitch   = ResourcesSwitches.GetModel(_type, _model);
        var switchModel = Instantiate(mdlSwitch) as GameObject;

        Init(switchModel);
    }