private void OnEnable() { this.CommonGameConfigurations = new CommonGameConfigurations(); EditorInformationsHelper.InitProperties(ref this.CommonGameConfigurations); this.RootElement = new VisualElement(); this.ContextBar = new ContextBar(this.RootElement); this.ContextBar.SetupRefreshButton(this.Refresh); this.ContextBar.SetupSelectedAllButton(this.SelectAllGizmo); this.ContextBar.SetupUnselectedAllButton(this.UnSelectAllGizmo); this.SearchTextField = new TextField(); this.SearchTextField.RegisterCallback <ChangeEvent <string> >(this.OnSearchStringChange); this.RootElement.Add(this.SearchTextField); this.InteractiveObjectSelectionScroll = new ScrollView(ScrollViewMode.Vertical); this.RootElement.Add(this.InteractiveObjectSelectionScroll); rootVisualElement.Add(this.RootElement); // rootVisualElement.RegisterCallback<MouseUpEvent>(this.RootMouseDown); SceneView.duringSceneGui += this.SceneTick; }
private void OnEnable() { CommonGameConfigurations = new CommonGameConfigurations(); EditorInformationsHelper.InitProperties(ref CommonGameConfigurations); RootElement = new VisualElement(); RootElement.style.flexDirection = FlexDirection.Row; LeftPanel = new VisualElement(); LeftPanel.style.flexDirection = FlexDirection.Column; LeftPanel.style.alignSelf = Align.FlexStart; SeachTextElement = new TextField(); SeachTextElement.RegisterCallback <ChangeEvent <string> >(OnSearchTextChange); LeftPanel.Add(SeachTextElement); ObjectFieldParent = new ScrollView(ScrollViewMode.Vertical); LeftPanel.Add(ObjectFieldParent); RootElement.Add(LeftPanel); SelectedInteractiveObjectDetail = new SelectedInteractiveObjectDetail(RootElement); rootVisualElement.Add(RootElement); EditorApplication.playModeStateChanged += OnPlayModeStateChanged; EditorApplication.update += Tick; SceneView.duringSceneGui += SceneTick; }
public void SceneTick(CommonGameConfigurations CommonGameConfigurations) { if (ObjectFieldIconBar.IsSceneHandleEnabled() && ObjectReference != null) { SceneHandlerDrawer.Draw(ListenedObjectRef, ObjectReference.transform, CommonGameConfigurations); } }
public static void Draw(object drawableObject, Transform objectTransform, CommonGameConfigurations CommonGameConfigurations) { if (drawableObject.GetType().GetCustomAttribute <SceneHandleDrawAttribute>(true) != null) { var fields = ReflectionHelper.GetAllFields(drawableObject.GetType()); foreach (var field in fields) { var DrawConfigurationAttribute = field.GetCustomAttribute <DrawConfigurationAttribute>() as DrawConfigurationAttribute; if (DrawConfigurationAttribute != null) { var configurationAsset = CommonGameConfigurations.GetConfiguration(DrawConfigurationAttribute.ConfigurationType); if (configurationAsset != null) { configurationAsset.GetEntryTry((Enum)field.GetValue(drawableObject), out var configurationDataObject); if (configurationDataObject != null) { Draw(configurationDataObject, objectTransform, CommonGameConfigurations); } } } var DrawNestedAttribute = field.GetCustomAttribute <DrawNestedAttribute>() as DrawNestedAttribute; if (DrawNestedAttribute != null) { Draw(field.GetValue(drawableObject), objectTransform, CommonGameConfigurations); } var AbstractSceneHandleAttributes = field.GetCustomAttributes <AbstractSceneHandleAttribute>(true); if (AbstractSceneHandleAttributes != null) { foreach (var AbstractSceneHandleAttribute in AbstractSceneHandleAttributes) { if (AbstractSceneHandleAttribute.GetType() == typeof(WireArcAttribute)) { var WireArcAttribute = (WireArcAttribute)AbstractSceneHandleAttribute; var semiAngle = GetFieldValue <float>(drawableObject, field); SetupColors(WireArcAttribute.GetColor()); DrawLabel(field.Name, WireArcAttribute.Radius, objectTransform); Handles.DrawWireArc(objectTransform.position, Vector3.up, objectTransform.forward, semiAngle, WireArcAttribute.Radius); Handles.DrawWireArc(objectTransform.position, Vector3.up, objectTransform.forward, -semiAngle, WireArcAttribute.Radius); } else if (AbstractSceneHandleAttribute.GetType() == typeof(WireCircleAttribute)) { var WireCircleAttribute = (WireCircleAttribute)AbstractSceneHandleAttribute; var radius = GetFieldValue <float>(drawableObject, field); SetupColors(WireCircleAttribute.GetColor()); DrawLabel(field.Name, radius, objectTransform); DrawLabel(field.Name, radius, objectTransform); Handles.DrawWireDisc(objectTransform.position, objectTransform.up, radius); } else if (AbstractSceneHandleAttribute.GetType() == typeof(WireCircleWorldAttribute)) { var WireCircleWorldAttribute = (WireCircleWorldAttribute)AbstractSceneHandleAttribute; Vector3 worldPositionCenter = Vector3.zero; float radius; if (WireCircleWorldAttribute.UseTransform) { worldPositionCenter = objectTransform.position; } else { worldPositionCenter = GetPositionFromObject(drawableObject.GetType().GetField(WireCircleWorldAttribute.PositionFieldName).GetValue(drawableObject)); } if (!string.IsNullOrEmpty(WireCircleWorldAttribute.RadiusFieldName)) { radius = (float)drawableObject.GetType().GetField(WireCircleWorldAttribute.RadiusFieldName).GetValue(drawableObject); } else { radius = WireCircleWorldAttribute.Radius; } SetupColors(WireCircleWorldAttribute.GetColor()); DrawLabel(field.Name, radius, worldPositionCenter); DrawLabel(field.Name, radius, worldPositionCenter); Handles.DrawWireDisc(worldPositionCenter, Vector3.up, radius); } else if (AbstractSceneHandleAttribute.GetType() == typeof(WireBoxAttribute)) { var WireBoxAttribute = (WireBoxAttribute)AbstractSceneHandleAttribute; var center = (Vector3)drawableObject.GetType().GetField(WireBoxAttribute.CenterFieldName).GetValue(drawableObject); var size = (Vector3)drawableObject.GetType().GetField(WireBoxAttribute.SizeFieldName).GetValue(drawableObject); SetupColors(WireBoxAttribute.GetColor()); HandlesHelper.DrawBox(center, size, objectTransform, WireBoxAttribute.GetColor(), drawableObject.GetType().Name, MyEditorStyles.SceneDrawDynamicLabelStyle); } else if (AbstractSceneHandleAttribute.GetType() == typeof(WireFrustumAttribute)) { var WireFrustumAttribute = (WireFrustumAttribute)AbstractSceneHandleAttribute; var frustum = (FrustumV2)field.GetValue(drawableObject); SetupColors(WireFrustumAttribute.GetColor()); DrawFrustum(frustum, objectTransform, false); } else if (AbstractSceneHandleAttribute.GetType() == typeof(WireRoundedFrustumAttribute)) { var WireRoundedFrustumAttribute = (WireRoundedFrustumAttribute)AbstractSceneHandleAttribute; var frustum = (FrustumV2)field.GetValue(drawableObject); SetupColors(WireRoundedFrustumAttribute.GetColor()); DrawFrustum(frustum, objectTransform, true); } else if (AbstractSceneHandleAttribute.GetType() == typeof(WireDirectionalLineAttribute)) { var WireLineAttribute = (WireDirectionalLineAttribute)AbstractSceneHandleAttribute; var lineLength = (float)field.GetValue(drawableObject); SetupColors(WireLineAttribute.GetColor()); Handles.DrawLine(objectTransform.transform.position, objectTransform.transform.position + new Vector3(WireLineAttribute.dX, WireLineAttribute.dY, WireLineAttribute.dZ) * lineLength); } else if (AbstractSceneHandleAttribute.GetType() == typeof(WireArrowAttribute)) { var WireArrowAttribute = (WireArrowAttribute)AbstractSceneHandleAttribute; Vector3 Source = WireArrowAttribute.Source; Vector3 Target = WireArrowAttribute.Target; if (!string.IsNullOrEmpty(WireArrowAttribute.SourceFieldName)) { Source = GetPositionFromObject(drawableObject.GetType().GetField(WireArrowAttribute.SourceFieldName).GetValue(drawableObject)); } if (!string.IsNullOrEmpty(WireArrowAttribute.TargetFieldName)) { Target = GetPositionFromObject(drawableObject.GetType().GetField(WireArrowAttribute.TargetFieldName).GetValue(drawableObject)); } SetupColors(WireArrowAttribute.GetColor()); HandlesHelper.DrawArrow(Source, Target, WireArrowAttribute.GetColor(), WireArrowAttribute.ArrowSemiAngle, WireArrowAttribute.ArrowLength); } } } } } }
public void GUITick(ref GameDesignerEditorProfile GameDesignerEditorProfile) { if (CommonGameConfigurations == null) { CommonGameConfigurations = new CommonGameConfigurations(); EditorInformationsHelper.InitProperties(ref CommonGameConfigurations); } if (this.GameDesignerEditorProfile == null) { this.GameDesignerEditorProfile = GameDesignerEditorProfile; } if (GameDesignerEditorProfileSO == null) { GameDesignerEditorProfileSO = new SerializedObject(this.GameDesignerEditorProfile); } currentSelectedObjet = GameDesignerHelper.GetCurrentSceneSelectedObject(); selectedModuleIndex = EditorGUILayout.Popup(selectedModuleIndex, AvailableModules.ConvertAll(t => t.Name).ToArray()); EditorGUILayout.HelpBox(POIModuleDescription(AvailableModules[selectedModuleIndex]), MessageType.None); T selectedPointOfIterestType = null; if (currentSelectedObjet != null) { selectedPointOfIterestType = currentSelectedObjet.GetComponent <T>(); } var additionalEditAllowed = AdditionalEditCondition(AvailableModules[selectedModuleIndex]); EditorGUILayout.BeginHorizontal(); var newAdd = GUILayout.Toggle(add, "ADD", EditorStyles.miniButtonLeft); var newRemove = GUILayout.Toggle(remove, "REMOVE", EditorStyles.miniButtonRight); if (newAdd && newRemove) { if (add && !remove) { add = false; remove = true; } else if (!add && remove) { add = true; remove = false; } else { add = newAdd; remove = newRemove; } } else { add = newAdd; remove = newRemove; } EditorGUILayout.EndHorizontal(); EditorGUI.BeginDisabledGroup(IsDisabled() || !additionalEditAllowed); if (GUILayout.Button("EDIT")) { OnEnabled(); OnEdit(selectedPointOfIterestType, AvailableModules[selectedModuleIndex]); EditorUtility.SetDirty(currentSelectedObjet); } EditorGUI.EndDisabledGroup(); if (currentSelectedObjet != null && selectedPointOfIterestType != null) { DoModuleListing(selectedPointOfIterestType); } GameDesignerEditorProfileSO.ApplyModifiedProperties(); GameDesignerEditorProfileSO.Update(); }
public virtual void OnEnabled() { this.commonGameConfigurations = new CommonGameConfigurations(); EditorInformationsHelper.InitProperties(ref this.commonGameConfigurations); }