void OnEnable() { GetAllPipestyls(); segmentPrefabCollector = (PrefabCollector)CreateInstance("PrefabCollector"); bendSegmentPrefabCollector = (PrefabCollector)CreateInstance("PrefabCollector"); interjacentPrefabCollector = (PrefabCollector)CreateInstance("PrefabCollector"); endPointPrefabCollector = (PrefabCollector)CreateInstance("PrefabCollector"); snappablePrefabCollector = (PrefabCollector)CreateInstance("PrefabCollector"); controlPointPrefabCollector = (PrefabCollector)CreateInstance("PrefabCollector"); if (pipesystem != null) { segmentPrefabCollector.Setup(pipesystem.segmentPrefab, pipesystem.segmentProbability, usedStyle.segmentPrefab, usedStyle.segmentProbability); segmentPrefabCollector.SetupOldProbability(); bendSegmentPrefabCollector.Setup(pipesystem.bendSegmentPrefab, pipesystem.bendSegmentProbability, usedStyle.bendSegmentPrefab, usedStyle.bendSegmentProbability); bendSegmentPrefabCollector.SetupOldProbability(); interjacentPrefabCollector.Setup(pipesystem.interjacentPrefab, pipesystem.interjacentProbability, usedStyle.interjacentPrefab, usedStyle.interjacentProbability); interjacentPrefabCollector.SetupOldProbability(); endPointPrefabCollector.Setup(pipesystem.endPointPrefab, pipesystem.endPointProbability, usedStyle.endPointPrefab, usedStyle.endPointProbability); endPointPrefabCollector.SetupOldProbability(); snappablePrefabCollector.Setup(pipesystem.snappablePrefab, pipesystem.snappableProbability, usedStyle.snappablePrefab, usedStyle.snappableProbability); snappablePrefabCollector.SetupOldProbability(); controlPointPrefabCollector.Setup(pipesystem.controlPointPrefab, pipesystem.controlPointProbability, usedStyle.controlPointPrefab, usedStyle.controlPointProbability); controlPointPrefabCollector.SetupOldProbability(); } }
public void StyleChoser() { //initial set if (positionStyleChoser < 0) { for (int i = 0; i < styleArray.Length; i++) { if (styleArray[i] == pipesystem.pipeStyle) { positionStyleChoser = i; break; } } segmentPrefabCollector.Setup(pipesystem.segmentPrefab, pipesystem.segmentProbability, usedStyle.segmentPrefab, usedStyle.segmentProbability); segmentPrefabCollector.SetupOldProbability(); bendSegmentPrefabCollector.Setup(pipesystem.bendSegmentPrefab, pipesystem.bendSegmentProbability, usedStyle.bendSegmentPrefab, usedStyle.bendSegmentProbability); bendSegmentPrefabCollector.SetupOldProbability(); interjacentPrefabCollector.Setup(pipesystem.interjacentPrefab, pipesystem.interjacentProbability, usedStyle.interjacentPrefab, usedStyle.interjacentProbability); interjacentPrefabCollector.SetupOldProbability(); endPointPrefabCollector.Setup(pipesystem.endPointPrefab, pipesystem.endPointProbability, usedStyle.endPointPrefab, usedStyle.endPointProbability); endPointPrefabCollector.SetupOldProbability(); snappablePrefabCollector.Setup(pipesystem.snappablePrefab, pipesystem.snappableProbability, usedStyle.snappablePrefab, usedStyle.snappableProbability); snappablePrefabCollector.SetupOldProbability(); controlPointPrefabCollector.Setup(pipesystem.controlPointPrefab, pipesystem.controlPointProbability, usedStyle.controlPointPrefab, usedStyle.controlPointProbability); controlPointPrefabCollector.SetupOldProbability(); } //if scrollbar is moved replace usedStyle EditorGUI.BeginChangeCheck(); positionStyleChoser = (int)GUILayout.HorizontalScrollbar(positionStyleChoser, 1, 0, styleArray.Length); if (EditorGUI.EndChangeCheck()) { usedStyle = styleArray[positionStyleChoser]; pipesystem.pipeStyle = styleArray[positionStyleChoser]; segmentPrefabCollector.Setup(pipesystem.segmentPrefab, pipesystem.segmentProbability, usedStyle.segmentPrefab, usedStyle.segmentProbability); segmentPrefabCollector.RevertChanges(); segmentPrefabCollector.SetupOldProbability(); bendSegmentPrefabCollector.Setup(pipesystem.bendSegmentPrefab, pipesystem.bendSegmentProbability, usedStyle.bendSegmentPrefab, usedStyle.bendSegmentProbability); bendSegmentPrefabCollector.RevertChanges(); bendSegmentPrefabCollector.SetupOldProbability(); interjacentPrefabCollector.Setup(pipesystem.interjacentPrefab, pipesystem.interjacentProbability, usedStyle.interjacentPrefab, usedStyle.interjacentProbability); interjacentPrefabCollector.RevertChanges(); interjacentPrefabCollector.SetupOldProbability(); endPointPrefabCollector.Setup(pipesystem.endPointPrefab, pipesystem.endPointProbability, usedStyle.endPointPrefab, usedStyle.endPointProbability); endPointPrefabCollector.RevertChanges(); endPointPrefabCollector.SetupOldProbability(); snappablePrefabCollector.Setup(pipesystem.snappablePrefab, pipesystem.snappableProbability, usedStyle.snappablePrefab, usedStyle.snappableProbability); snappablePrefabCollector.RevertChanges(); snappablePrefabCollector.SetupOldProbability(); controlPointPrefabCollector.Setup(pipesystem.controlPointPrefab, pipesystem.controlPointProbability, usedStyle.controlPointPrefab, usedStyle.controlPointProbability); controlPointPrefabCollector.RevertChanges(); controlPointPrefabCollector.SetupOldProbability(); } }