//Dictionary<string,Rect> outlineRects = new Dictionary<string, Rect>(); void DrawBlockSet(BlockSet blocks, BlockOrientation orientation){ string orientationName = orientation.ToString(); if(!scrollPositions.ContainsKey(orientationName)){ scrollPositions.Add(orientationName,Vector2.zero); } EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); EditorGUILayout.BeginVertical(GUILayout.Width(150)); EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); Texture2D icon = GetIcon(orientation.ToString()); GUILayout.Label(new GUIContent("",orientationName),GUILayout.ExpandWidth(false), GUILayout.MinWidth(100),GUILayout.MinHeight(100)); GUI.DrawTexture(GUILayoutUtility.GetLastRect(),icon,ScaleMode.ScaleAndCrop,false); bool isDefault = GUILayout.Toggle(blocks.IsDefault(),new GUIContent("",TidyMessages.BLOCK_EDITOR_BLOCKSET_IS_DEFAULT_TOOLTIP),GUILayout.Height(25)); if(isDefault && !blocks.IsDefault()){ workingBlock.ClearDefault(); blocks.SetIsDefault(true); SetBlockDirty(workingBlock); hasWorkingBlockChanged = true; if(!initialPreviewGenerated){ //there will be no other opportunity to refresh GetPreviewForGameObject(workingBlock.GetDefaultBlock(),true); initialPreviewGenerated = true; } } if(!isDefault && blocks.IsDefault()){ workingBlock.ClearDefault(); hasWorkingBlockChanged = true; SetBlockDirty(workingBlock); if(!initialPreviewGenerated){ //there will be no other opportunity to refresh GetPreviewForGameObject(workingBlock.GetDefaultBlock(),true); initialPreviewGenerated = true; } } EditorGUILayout.EndHorizontal(); if(!newObjects.ContainsKey(orientationName)){ newObjects.Add(orientationName,null); } newObjects[orientationName] = EditorGUILayout.ObjectField(newObjects[orientationName],typeof(GameObject),false,GUILayout.Width(150)) as GameObject; //Change as at 30/12/2011: No more button, automatic addition if(GUILayout.Button(new GUIContent(TidyMessages.BLOCK_EDITOR_BLOCKSET_ADD_VARIANT, TidyMessages.BLOCK_EDITOR_BLOCKSET_ADD_VARIANT_TOOLTIP)) && (newObjects[orientationName] != null && !newObjects[orientationName].Equals(workingBlock.gameObject))){ //GameObject newBlock = EditorUtility.InstantiatePrefab(newObjects[orientationName]) as GameObject; //PREFAB //GameObject newBlock = PrefabUtility.InstantiatePrefab(newObjects[orientationName]) as GameObject; //newBlock.name = newObjects[orientationName].name; //newBlock.SetActiveRecursively(false); workingBlock.Editor_AddToBlockSet(orientation,newObjects[orientationName]); if(workingBlock.GetDefaultSet() == null){ blocks.SetIsDefault(true); } hasWorkingBlockChanged = true; if(!initialPreviewGenerated){ //there will be no other opportunity to refresh GetPreviewForGameObject(workingBlock.GetDefaultBlock(),true); initialPreviewGenerated = true; } SetBlockDirty(workingBlock); newObjects[orientationName] = null; mapCreator.RefreshAllMaps(); } EditorGUILayout.EndVertical(); Vector2 scrollPos = scrollPositions[orientationName]; //scrollPos = GUILayout.BeginScrollView(scrollPos,GUILayout.MinHeight(130),GUILayout.ExpandWidth(true)); Rect r = EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true),GUILayout.MinHeight(130)); GUI.Box(r,""); if(blocks != null && blocks.blockSet != null){ for(int i = 0; i < blocks.blockSet.Length; i++){ DrawObjectPreview(blocks.blockSet[i],orientation); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); //GUILayout.EndScrollView(); //GUI.Box(GUILayoutUtility.GetLastRect(),""); scrollPositions[orientationName] = scrollPos; EditorGUILayout.EndHorizontal(); }
//Dictionary<string,Rect> outlineRects = new Dictionary<string, Rect>(); void DrawBlockSet(BlockSet blocks, BlockOrientation orientation) { string orientationName = orientation.ToString(); if (!scrollPositions.ContainsKey(orientationName)) { scrollPositions.Add(orientationName, Vector2.zero); } EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); EditorGUILayout.BeginVertical(GUILayout.Width(150)); EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); Texture2D icon = GetIcon(orientation.ToString()); GUILayout.Label(new GUIContent("", orientationName), GUILayout.ExpandWidth(false), GUILayout.MinWidth(100), GUILayout.MinHeight(100)); GUI.DrawTexture(GUILayoutUtility.GetLastRect(), icon, ScaleMode.ScaleAndCrop, false); bool isDefault = GUILayout.Toggle(blocks.IsDefault(), new GUIContent("", TidyMessages.BLOCK_EDITOR_BLOCKSET_IS_DEFAULT_TOOLTIP), GUILayout.Height(25)); if (isDefault && !blocks.IsDefault()) { workingBlock.ClearDefault(); blocks.SetIsDefault(true); SetBlockDirty(workingBlock); hasWorkingBlockChanged = true; if (!initialPreviewGenerated) { //there will be no other opportunity to refresh GetPreviewForGameObject(workingBlock.GetDefaultBlock(), true); initialPreviewGenerated = true; } } if (!isDefault && blocks.IsDefault()) { workingBlock.ClearDefault(); hasWorkingBlockChanged = true; SetBlockDirty(workingBlock); if (!initialPreviewGenerated) { //there will be no other opportunity to refresh GetPreviewForGameObject(workingBlock.GetDefaultBlock(), true); initialPreviewGenerated = true; } } EditorGUILayout.EndHorizontal(); if (!newObjects.ContainsKey(orientationName)) { newObjects.Add(orientationName, null); } newObjects[orientationName] = EditorGUILayout.ObjectField(newObjects[orientationName], typeof(GameObject), false, GUILayout.Width(150)) as GameObject; //Change as at 30/12/2011: No more button, automatic addition if (GUILayout.Button(new GUIContent(TidyMessages.BLOCK_EDITOR_BLOCKSET_ADD_VARIANT, TidyMessages.BLOCK_EDITOR_BLOCKSET_ADD_VARIANT_TOOLTIP)) && (newObjects[orientationName] != null && !newObjects[orientationName].Equals(workingBlock.gameObject))) { //GameObject newBlock = EditorUtility.InstantiatePrefab(newObjects[orientationName]) as GameObject; //PREFAB //GameObject newBlock = PrefabUtility.InstantiatePrefab(newObjects[orientationName]) as GameObject; //newBlock.name = newObjects[orientationName].name; //newBlock.SetActiveRecursively(false); workingBlock.Editor_AddToBlockSet(orientation, newObjects[orientationName]); if (workingBlock.GetDefaultSet() == null) { blocks.SetIsDefault(true); } hasWorkingBlockChanged = true; if (!initialPreviewGenerated) { //there will be no other opportunity to refresh GetPreviewForGameObject(workingBlock.GetDefaultBlock(), true); initialPreviewGenerated = true; } SetBlockDirty(workingBlock); newObjects[orientationName] = null; mapCreator.RefreshAllMaps(); } EditorGUILayout.EndVertical(); Vector2 scrollPos = scrollPositions[orientationName]; //scrollPos = GUILayout.BeginScrollView(scrollPos,GUILayout.MinHeight(130),GUILayout.ExpandWidth(true)); Rect r = EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true), GUILayout.MinHeight(130)); GUI.Box(r, ""); if (blocks != null && blocks.blockSet != null) { for (int i = 0; i < blocks.blockSet.Length; i++) { DrawObjectPreview(blocks.blockSet[i], orientation); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); //GUILayout.EndScrollView(); //GUI.Box(GUILayoutUtility.GetLastRect(),""); scrollPositions[orientationName] = scrollPos; EditorGUILayout.EndHorizontal(); }