//===================================================== private static void AddDoorOfType(eDoorType type) { var pfb = ResourcesDoors.GetPrefab(); var mdl = ResourcesDoors.GetModel(type, 0); if (pfb == null) { return; } var prefab = PrefabUtility.InstantiatePrefab(pfb) as GameObject; if (prefab == null) { return; } var script = prefab.GetComponent <Door>(); switch (type) { case eDoorType.BASIC: prefab.name = "BasicDoor"; break; case eDoorType.BASIC_DOUBLE: prefab.name = "DoubleDoor"; break; case eDoorType.CRAWL: prefab.name = "CrawlDoor"; break; case eDoorType.OBLIVION_PORTAL: prefab.name = "OblivionPortal"; break; case eDoorType.PUZZLE_LOCKED: prefab.name = "LockedPuzzleDoor"; break; case eDoorType.PUZZLE_ENTRANCE: prefab.name = "PuzzleRoomDoor"; break; case eDoorType.PLAYER_HUB: prefab.name = "MainHallDoor"; break; case eDoorType.BOSS: prefab.name = "BossRoomDoor"; break; } if (script != null) { script.Type = type; if (mdl != null) { //var model = PrefabUtility.InstantiatePrefab( mdl ) as GameObject; //script.Init( model ); script.Init(); } } PositionObjectAndSelect(prefab); }
//===================================================== private void CreateDoubleDoor() { // Get content from resources var mdlDoor = ResourcesDoors.GetModel(_type, _model); if (mdlDoor == null) { return; } if (_doubleDoor != null && _currentModelName == mdlDoor.name) { // Do nothing } else { // Get content from resources var pfbDoor = ResourcesDoors.GetPrefab(); if (pfbDoor == null) { return; } if (_doubleDoor != null) { DestroyImmediate(_doubleDoor); } // Add second door _doubleDoor = Instantiate(pfbDoor) as GameObject; if (_doubleDoor == null) { return; } // Rename door _doubleDoor.name = "Door 2"; // Get script _doubleDoorScript = _doubleDoor.GetComponent <Door>(); if (_doubleDoorScript == null) { return; } // Init door _doubleDoorScript.Type = _type; //var doorModel = Instantiate( mdlDoor ) as GameObject; _doubleDoorScript.HingePosition = eHingePosition.RIGHT; } // Init door _doubleDoorScript.Model = _model; _doubleDoorScript.Init(true); // Match other door parameters _doubleDoorScript.RotateOpenBy = _rotateOpenBy; _doubleDoorScript.RotateDuration = _rotateDuration; _doubleDoorScript.AutoClose = _autoClose; _doubleDoorScript.AutoCloseDelay = _autoCloseDelay; _doubleDoorScript.OpenInAndOut = _openInAndOut; _doubleDoorScript.KeyLevel = _keyLevel; _doubleDoorScript.FairyRequired = _fairyRequired; }