void DrawFunctionBlockUI(){ Color c = Handles.color; Handles.color = Color.yellow; float radius = functionBlock.blockMap.tileScale.y * 0.4f; Handles.DrawWireDisc(functionBlock.transform.position,functionBlock.transform.forward,radius); Handles.color = c; Vector2 pos = HandleUtility.WorldToGUIPoint(functionBlock.transform.position); Handles.BeginGUI(); Rect r = new Rect(pos.x - 150.0f,pos.y + 25.0f,300.0f,175.0f); //GUI.skin = TidyEditorUtility.GetEditorGUISkin(); //GUI.Box(r,""); //GUI.skin = null; GUI.DrawTexture(r,GetIcon(TidyFileNames.AREA_BACKGROUND)); GUILayout.BeginArea(r); GUILayout.BeginVertical(); GUILayout.Space(10.0f); if(functionData == null){ //draw the 'add data' UI //draw the close UI GUILayout.BeginHorizontal(); GUILayout.Label("Add object:"); GUILayout.FlexibleSpace(); if(GUILayout.Button("X")){ SetEntireMapDirty(functionBlock.blockMap); functionBlock = null; functionData = null; prop = null; } GUILayout.EndHorizontal(); if(functionalComponents != null && functionalComponents.Length > 0){ for(int i = 0; i < functionalComponents.Length; i++){ if(GUILayout.Button(functionalComponents[i].name)){ TidyFunctionalObject o = UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(functionBlock.blockMap.gameObject, "Assets/Tidy Tile Mapper/Editor/Editor Logic/TidyMapCreator.cs (1502,33)", functionalComponents[i].name) as TidyFunctionalObject; o.SetParentBlock(functionBlock); functionBlock.blockMap.functionalOverlay.AddData(o); SetEntireMapDirty(functionBlock.blockMap); SetFunctionBlock(functionBlock); } } } else{ GUILayout.Label("None"); } } else{ GUILayout.Label(functionData.parentBlock.name + " at " +"["+functionData.parentBlock.x + "," + functionData.parentBlock.y + "," + functionData.parentBlock.depth+"]"); //draw the close UI GUILayout.BeginHorizontal(); GUILayout.Label(functionData.GetType().Name); GUILayout.FlexibleSpace(); if(GUILayout.Button("X")){ SetEntireMapDirty(functionBlock.blockMap); functionBlock = null; functionData = null; prop= null; } GUILayout.EndHorizontal(); GUILayout.Space(10.0f); fScrollPos = GUILayout.BeginScrollView(fScrollPos); try{ prop = functionSObj.GetIterator(); if(prop != null && functionSObj != null && functionData != null){ prop.NextVisible(true); bool searchDeep = true; do{ searchDeep = true; if(prop.propertyPath == "m_Script"){ continue; } if(prop.name == "parentBlock"){ continue; } if(prop.type == "Vector3f"){ searchDeep = false; } if(prop.type == "Vector3f" && prop.name == "targetDifference" && currentTidyTarget != null){ prop.vector3Value = currentTidyTarget.targetDifference; currentTidyTarget = null; } if(prop.name == "TidyTarget_parentBlock" && currentTidyTarget != null){ prop.objectReferenceValue = currentTidyTarget.TidyTarget_parentBlock; } if(prop.type == "TidyTarget"){ EditorGUILayout.BeginHorizontal(); GUILayout.Label(prop.name + ":"); GUILayout.FlexibleSpace(); Color gc = GUI.color; if(setTidyTarget == true){ GUI.color = Color.green; } if(GUILayout.Button("Set")){ setTidyTarget = true; //tidyTargetName = prop.name; currentTidyTarget = null; } GUI.color = gc; EditorGUILayout.EndHorizontal(); continue; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(prop); EditorGUILayout.EndHorizontal(); }while(prop.NextVisible(searchDeep)); prop.Reset(); functionSObj.ApplyModifiedProperties(); functionSObj.Update(); } else{ GUILayout.Label("Data null."); } }catch(Exception e){Debug.LogWarning(e.ToString());} GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if(GUILayout.Button("Delete")){ TidyFunctionalObject o = functionBlock.blockMap.functionalOverlay.RemoveDataAt(functionBlock.x,functionBlock.y,functionBlock.depth); GameObject.DestroyImmediate(o); functionData = null; prop = null; SetEntireMapDirty(functionBlock.blockMap); functionBlock = null; } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndArea(); Handles.EndGUI(); }
void ArrayGUI (SerializedProperty sp, string name) { EditorGUIUtility.LookLikeControls (100.0f, 40.0f); GUILayout.Space (4.0f); EditorGUILayout.BeginVertical ("box", GUILayout.MaxWidth(Screen.width)); int i = 0; int del = -1; SerializedProperty array = sp.Copy (); SerializedProperty size = null; bool first = true; while (true) { if (sp.propertyPath != name && !sp.propertyPath.StartsWith (name + ".")) break; bool child; EditorGUI.indentLevel = sp.depth; if (sp.depth == 1 && !first) { EditorGUILayout.BeginHorizontal (); if (GUILayout.Button ("", "OL Minus", GUILayout.Width (24.0f))) del = i; //GUILayout.Label ("" + i); child = EditorGUILayout.PropertyField (sp); GUI.enabled = i > 0; if (GUILayout.Button (manager.arrowUp, "ButtonLeft", GUILayout.Width (22.0f), GUILayout.Height(18.0f))) array.MoveArrayElement (i - 1, i); GUI.enabled = i < array.arraySize - 1; if (GUILayout.Button(manager.arrowDown, "ButtonRight", GUILayout.Width(22.0f), GUILayout.Height(18.0f))) array.MoveArrayElement (i + 1, i); ++i; GUI.enabled = true; EditorGUILayout.EndHorizontal (); } else if (sp.depth == 1) { first = false; size = sp.Copy (); EditorGUILayout.BeginHorizontal (); if (!size.hasMultipleDifferentValues && GUILayout.Button("", "OL Plus", GUILayout.Width(24.0f))) array.arraySize += 1; child = EditorGUILayout.PropertyField (sp); EditorGUILayout.EndHorizontal (); } else { child = EditorGUILayout.PropertyField(sp); } if (!sp.NextVisible (child)) break; } sp.Reset (); if (del != -1) array.DeleteArrayElementAtIndex (del); if (array.isExpanded && !size.hasMultipleDifferentValues) { EditorGUILayout.BeginHorizontal (); if (GUILayout.Button("", "OL Plus", GUILayout.Width(24.0f))) array.arraySize += 1; GUI.enabled = false; EditorGUILayout.PropertyField (array.GetArrayElementAtIndex (array.arraySize - 1), new GUIContent ("" + array.arraySize)); GUI.enabled = true; EditorGUILayout.EndHorizontal (); } EditorGUI.indentLevel = 0; EditorGUILayout.EndVertical (); EditorGUIUtility.LookLikeControls (170.0f, 80.0f); }