//===================================================== public void Refresh() { CheckReferences(); // Update platform-model var model = ResourcesPlatforms.GetModel(_model); var instance = Instantiate(model) as GameObject; Init(instance); if (_pathNodes.Length <= 0 || _pathNodes[0] == null) { return; } if (_nodesContainer == null) { _nodesContainer = _type == ePlatformType.ON_PATH ? new GameObject("PlatformPathContainer") : new GameObject("PlatformSplineContainer"); // Move this platform into container _thisTransform.parent = _nodesContainer.transform; _nodesContainer.transform.position = Vector3.zero; } // Update path node names to math their path index for (var i = 0; i < _pathNodes.Length; i++) { if (_pathNodes[i] == null) { continue; } _pathNodes[i].name = "PathNode" + i.ToString("00"); // Move node into container _pathNodes[i].parent = _nodesContainer.transform; } if (_type == ePlatformType.ON_PATH) { InitPlatformPath(); } else { InitPlatformSpline(); } // Update switch indexes for (var i = 0; i < _switches.Length; i++) { if (_switches[i] == null) { continue; } _switches[i].Index = i; Debug.Log("Switch " + _switches[i].Index + " found: activated: " + _switches[i].IsActivated); } }
public static void AddPathNode() { var pfb = ResourcesPlatforms.GetPathNodePrefab(); if (pfb == null) { return; } var prefab = PrefabUtility.InstantiatePrefab(pfb) as GameObject; if (prefab == null) { return; } PositionObjectAndSelect(prefab); }
//===================================================== private static void AddPlatformOfType(ePlatformType type) { var pfb = ResourcesPlatforms.GetPrefab(); var mdl = ResourcesPlatforms.GetModel(0); if (pfb == null) { return; } var prefab = PrefabUtility.InstantiatePrefab(pfb) as GameObject; if (prefab == null) { return; } var script = prefab.GetComponent <Platform>(); switch (type) { case ePlatformType.ON_PATH: prefab.name = "PlatformOnPath"; break; case ePlatformType.ON_SPLINE: prefab.name = "PlatformOnSpline"; break; } if (script != null) { script.Type = type; if (mdl != null) { var model = PrefabUtility.InstantiatePrefab(mdl) as GameObject; script.Init(model); } } PositionObjectAndSelect(prefab); }