void OnGUI() { GUILayout.Space(5); if (buildingEditor == null) // close the window if we dont have a reference to our building editor window, can happens due to unity compiling scripts. { Close(); } GUILayout.BeginVertical("Property Creator Editor Window", boxStyle); GUILayout.Space(20); propertyName = EditorGUILayout.TextField(new GUIContent("Name :", "What is the name of this property ?, can be used for knowing what that property is being used for."), propertyName); positionAnchor = (SocketPositionAnchor)EditorGUILayout.EnumPopup(new GUIContent("Starting Position Anchor :", "Where will it spawn the object in the building local position ? use this to help you position your property faster, it doesnt influence any further features."), positionAnchor); if (creatingType == ModifierType.Socket) { previewGameObject = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Socket Gizmos Preview GameObject :", "This GameObject will be used for preview on gizmos, it will grab the parameters from it into the collider to hlep you easily get your scale right."), previewGameObject, typeof(GameObject), false); receivesBuildings = (BuildingType)EditorGUILayout.EnumMaskPopup(new GUIContent("Receive Buildings :", "What building will be snapped into this socket ?"), receivesBuildings); socketPlacingType = (PlacingRestrictionType)EditorGUILayout.EnumMaskPopup(new GUIContent("Placing Type :", "What the placing method will be on this socket ?"), socketPlacingType); } else if (creatingType == ModifierType.Condition) { condition = EditorGUILayout.ObjectField(new GUIContent("Condition Script :", "What condition script will this condition use ? you can always edit it later. if you leave this blank it will use the BaseCondition script. "), condition, typeof(MonoScript), false) as MonoScript; if (condition != null && !condition.GetClass().BaseType.Equals(typeof(BaseCondition))) // reset condition if its type isnt what we need ( a condition ). { condition = null; } } else // snap points { targetType = (BuildingType)EditorGUILayout.EnumMaskField("Target type :", targetType); } if (GUILayout.Button("Create " + creatingType.ToString())) { if (creatingType == ModifierType.Socket) { buildingEditor.script.CreateSocket(propertyName, positionAnchor, previewGameObject, receivesBuildings, socketPlacingType); } else if (creatingType == ModifierType.Condition) { buildingEditor.script.CreateCondition(propertyName, positionAnchor, condition == null ? typeof(BaseCondition) : condition.GetClass()); } else if (creatingType == ModifierType.SnapPoint) { buildingEditor.script.CreateSnapPoint(propertyName, positionAnchor, targetType); } Close(); } else { EditorGUILayout.EndVertical(); } }
public SocketBuildingData(BaseSocket socket) { this.name = socket.transform.name; this.position = socket.transform.localPosition; this.rotation = socket.transform.localRotation; this.scale = socket.transform.localScale; this.receiveType = socket.receiveType; this.placingType = socket.placingType; this.center = socket.center; this.size = socket.size; this.isHoverTarget = socket.isHoverTarget; }
/// <summary> /// Handle the building that is hovering on the socket. /// </summary> /// <param name="building">The building that is hovering on the socket now</param> /// <param name="buildingPlaceType">What is the building type ?</param> /// <returns></returns> public virtual bool IsFit(BaseBuilding building, PlacingRestrictionType buildingPlaceType) { return(FlagsHelper.IsBitSet(receiveType, building.buildingType) && FlagsHelper.IsBitSet <PlacingRestrictionType>(placingType, buildingPlaceType) && isActive); }