public void AddData(TidyFunctionalObject data) { Vector3 mapCoords = new Vector3(data.x,data.y,data.depth); if(!isInitialised){ for(int i = 0; i < mapData.Count; i++){ if(mapData[i].x == mapCoords.x && mapData[i].y == mapCoords.y && mapData[i].depth == mapCoords.z){ Debug.LogWarning("Already contained functional overlay data at: " + mapCoords.ToString() + ": removing."); mapData.RemoveAt(i); } } mapData.Add(data); } else{ if(mapDataTable.ContainsKey(mapCoords)){ mapDataTable.Remove(mapCoords); Debug.LogWarning("Already contained functional overlay data at: " + mapCoords.ToString() + ": removing."); } mapDataTable.Add(mapCoords,data); } }
public void AddData(TidyFunctionalObject data) { Vector3 mapCoords = new Vector3(data.x, data.y, data.depth); if (!isInitialised) { for (int i = 0; i < mapData.Count; i++) { if (mapData[i].x == mapCoords.x && mapData[i].y == mapCoords.y && mapData[i].depth == mapCoords.z) { Debug.LogWarning("Already contained functional overlay data at: " + mapCoords.ToString() + ": removing."); mapData.RemoveAt(i); } } mapData.Add(data); } else { if (mapDataTable.ContainsKey(mapCoords)) { mapDataTable.Remove(mapCoords); Debug.LogWarning("Already contained functional overlay data at: " + mapCoords.ToString() + ": removing."); } mapDataTable.Add(mapCoords, data); } }
public TidyFunctionalObject RemoveDataAt(int x, int y, int depth) { Vector3 mapCoords = new Vector3(x, y, depth); if (!HasDataAt(x, y, depth)) { return(null); } if (!isInitialised) { for (int i = 0; i < mapData.Count; i++) { if (mapData[i].x == x && mapData[i].y == y && mapData[i].depth == depth) { TidyFunctionalObject o = mapData[i]; mapData.RemoveAt(i); return(o); } } } else { if (mapDataTable.ContainsKey(mapCoords)) { TidyFunctionalObject o = mapDataTable[mapCoords]; mapDataTable.Remove(mapCoords); return(o); } } return(null); }
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 SetFunctionBlock(Block functionBlock){ this.functionBlock = functionBlock; if(functionBlock.blockMap.functionalOverlay == null){ functionBlock.blockMap.AddFunctionalOverlay(false); SetEntireMapDirty(functionBlock.blockMap); } this.functionData = functionBlock.blockMap.functionalOverlay.GetDataAt(this.functionBlock.x,this.functionBlock.y,this.functionBlock.depth); if(this.functionData != null){ this.functionSObj = new SerializedObject(this.functionData); this.prop = this.functionSObj.GetIterator(); } }
public void SetPaintBehaviour(MapPaintBehaviour behaviour) { leftMouseDown = false; if(currentBehaviour == behaviour){ return; } if(currentBehaviour == MapPaintBehaviour.Edit_Functions){ functionData = null; functionBlock = null; prop = null; } if(behaviour == MapPaintBehaviour.Edit_Functions){ RefreshFunctionalObjects(); RefreshExistentBlockMaps(); } if(currentBehaviour == MapPaintBehaviour.DrawPath){ drawingPath = false; pathBlocks.Clear(); } currentBehaviour = behaviour; if(currentBehaviour == MapPaintBehaviour.Block_Move){ if(selectedBlock != null){ Selection.activeGameObject = selectedBlock.gameObject; } } SceneView.RepaintAll(); if(currentBehaviour == MapPaintBehaviour.Disabled){ /*if(plugins != null){ for(int i = 0; i < plugins.Length; i++){ plugins[i].obj.DeactivateTool(); } }*/ } }