/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(InspectorProperty property, TableListAttribute attribute, GUIContent label) { var context = property.Context.Get(this, "Context", (Context)null); if (context.Value == null) { context.Value = new Context(); context.Value.ListChanger = property.ValueEntry.GetListValueEntryChanger(); context.Value.Paging = new GUIPagingHelper(); context.Value.Paging.NumberOfItemsPerPage = attribute.NumberOfItemsPerPage == 0 ? GeneralDrawerConfig.Instance.NumberOfItemsPrPage : attribute.NumberOfItemsPerPage; property.Context.GetPersistent(this, "DrawList", out context.Value.DrawList); } context.Value.ObjectPicker = ObjectPicker.GetObjectPicker(UniqueDrawerKey.Create(property, this), context.Value.ListChanger.ElementType); context.Value.UpdateTable(property, attribute, label == null ? string.Empty : label.text); // @todo @fix passing null to update table for label causes OutOfRangeExceptions to be thrown. if (context.Value.DrawList.Value) { if (GUILayout.Button("Show table")) { context.Value.SwitchView = true; } this.CallNextDrawer(property, label); } else { if (context.Value.Table != null) { if (context.Value.WasUpdated && Event.current.type == EventType.Repaint) { // Everything is messed up the first frame. Lets not show that. GUIHelper.PushColor(new Color(0, 0, 0, 0)); } context.Value.Table.DrawTable(); if (context.Value.WasUpdated && Event.current.type == EventType.Repaint) { context.Value.WasUpdated = false; GUIHelper.PopColor(); } } if (context.Value.ObjectPicker.IsReadyToClaim && Event.current.type == EventType.Repaint) { var value = context.Value.ObjectPicker.ClaimObject(); object[] values = new object[context.Value.ListChanger.ValueCount]; values[0] = value; for (int j = 1; j < values.Length; j++) { values[j] = SerializationUtility.CreateCopy(value); } context.Value.ListChanger.AddListElement(values, CHANGE_ID); } } GUILayout.Space(3); }
void RenderEventNodeGUI(NodeEditor nodeEditor, XNode.Node node) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); dENode = node as DialogEventNode; if (dENode != null) { if (dENode.dialogEvent == null) { return; } EditorGUILayout.BeginVertical(EditorStyles.helpBox); dENode.dialogEvent.type = (DialogObject.DialogEventType)EditorGUILayout.EnumPopup("Type", dENode.dialogEvent.type); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); if (dENode.dialogEvent.type == DialogObject.DialogEventType.SetVar) { EditorGUILayout.LabelField("Var: " + dENode.dialogEvent.stringField); if (GUILayout.Button("Set Var")) { ObjectPicker.GetObject(ObjectPicker.ObjectType.Variable, dENode.SetStringField); // Debug.Log("Get/set vars"); } dENode.dialogEvent.boolField = EditorGUILayout.Toggle("Value", dENode.dialogEvent.boolField); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); }
void IDefinesGenericMenuItems.PopulateGenericMenu(InspectorProperty property, GenericMenu genericMenu) { var entry = property.ValueEntry as IPropertyValueEntry <T>; bool isChangeable = property.ValueEntry.SerializationBackend != SerializationBackend.Unity && !entry.BaseValueType.IsValueType && entry.BaseValueType != typeof(string); if (isChangeable) { if (entry.IsEditable) { var objectPicker = ObjectPicker.GetObjectPicker(entry, entry.BaseValueType); var rect = entry.Property.LastDrawnValueRect; rect.position = GUIUtility.GUIToScreenPoint(rect.position); rect.height = 20; genericMenu.AddItem(new GUIContent("Change Type"), false, () => { objectPicker.ShowObjectPicker(entry.WeakSmartValue, false, rect); }); } else { genericMenu.AddDisabledItem(new GUIContent("Change Type")); } } }
void App_DoUpdate(object sender, EventArgs e) { PhysicsEngine.Update(); List <BaseGameObject> worldSpaces = WorldData.GetObjectsByType(typeof(WorldSpace)); foreach (WorldSpace ws in worldSpaces) { ws.Update(); } ObjectPicker.Update(); DeferredRenderer.Update(); SkyDome.Update(); string s = string.Empty; s = "TotalGameTime: " + App.gameTime.TotalGameTime.ToString() + "\t"; s += "TotalRealTime: " + App.gameTime.TotalRealTime.ToString() + "\t"; s += "FramesPerSecond: " + App.gameTime.FramesPerSecond.ToString() + "\t"; s += "ElapsedGameTime: " + App.gameTime.ElapsedGameTime.ToString() + "\t"; s += "ElapsedRealTime: " + App.gameTime.ElapsedRealTime.ToString() + "\n"; //s += "Cc pos: " + PlayerInput.characterController.Body.Position.ToString(); }
public async Task <PickResult <T> > PickSingleObjectAsync <T>(string pageKey, object parameter = null, PickerOpenOption startOption = null) { Type page; lock (_pages) { var typeKey = typeof(T).FullName; if (!_pages.TryGetValue(typeKey, out var pages)) { throw new ArgumentException( string.Format("Type not found: {0}. Did you forget to call ObjectPickerService.Configure?", typeKey), nameof(typeKey)); } if (!pages.TryGetValue(pageKey, out page)) { throw new ArgumentException( string.Format("Page not found: {0}. Did you forget to call ObjectPickerService.Configure?", pageKey), nameof(pageKey)); } } var picker = new ObjectPicker <T>(); if (startOption != null) { picker.PickerOpenOption = startOption; } var result = await picker.PickSingleObjectAsync(page, parameter); return(result); }
/// <summary> /// Draws the property layout. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { if (this.drawAsList) { if (GUILayout.Button("Draw as table")) { this.drawAsList = false; } this.CallNextDrawer(label); return; } this.picker = ObjectPicker.GetObjectPicker(this, this.resolver.ElementType); this.paging.Update(this.resolver.MaxCollectionLength); this.currPage.Value = this.paging.CurrentPage; this.isPagingExpanded.Value = this.paging.IsExpanded; var rect = SirenixEditorGUI.BeginIndentedVertical(SirenixGUIStyles.PropertyPadding); { if (!this.Attribute.HideToolbar) { this.DrawToolbar(label); } if (this.Attribute.AlwaysExpanded) { this.DrawColumnHeaders(); this.DrawTable(); } else { if (SirenixEditorGUI.BeginFadeGroup(this, this.isVisible.Value) && this.Property.Children.Count > 0) { this.DrawColumnHeaders(); this.DrawTable(); } SirenixEditorGUI.EndFadeGroup(); } } SirenixEditorGUI.EndIndentedVertical(); if (Event.current.type == EventType.Repaint) { rect.yMin -= 1; rect.height -= 3; SirenixEditorGUI.DrawBorders(rect, 1); } this.DropZone(rect); this.HandleObjectPickerEvents(); if (Event.current.type == EventType.Repaint) { this.isFirstFrame = false; } }
public ObjectPickerDialogEx(string title, List <ObjectPicker.TabInfo> listObjs, List <ObjectPicker.HeaderInfo> headers, int numSelectableRows, List <ObjectPicker.RowInfo> preSelectedRows) : base("UiObjectPicker", 1, true, ModalDialog.PauseMode.PauseSimulator, null) { if (mModalDialogWindow == null) { return; } Rect area = mModalDialogWindow.Area; area.mBottomRight.x += 200; mModalDialogWindow.Area = area; Text caption = mModalDialogWindow.GetChildByID(0x05ef6bd3, false) as Text; caption.Caption = title; mTable = mModalDialogWindow.GetChildByID(0x05ef6bd0, false) as ObjectPicker; mTable.ObjectTable.TableChanged += OnTableChanged; mTable.SelectionChanged += OnSelectionChanged; mTable.RowSelected += OnSelectionChanged; mTable.mViewButton.Visible = false; mTable.mTable.mPopulationCompletedCallback += OnComplete; area = mTable.Area; area.mBottomRight.x += 200; mTable.Area = area; mOkayButton = mModalDialogWindow.GetChildByID(0x05ef6bd1, false) as Button; mOkayButton.TooltipText = Common.LocalizeEAString("Ui/Caption/Global:Accept"); mOkayButton.Enabled = true; mOkayButton.Click += OnOkayButtonClick; OkayID = mOkayButton.ID; SelectedID = mOkayButton.ID; Button closeButton = mModalDialogWindow.GetChildByID(0x05ef6bd2, false) as Button; closeButton.TooltipText = Common.LocalizeEAString("Ui/Caption/ObjectPicker:Cancel"); closeButton.Click += OnCloseButtonClick; CancelID = closeButton.ID; mTableOffset = (mModalDialogWindow.Area.BottomRight - mModalDialogWindow.Area.TopLeft) - (mTable.Area.BottomRight - mTable.Area.TopLeft); mTable.Populate(listObjs, headers, numSelectableRows); mTable.mTabs.TabSelect -= mTable.OnTabSelect; mTable.mTabs.TabSelect += OnTabSelect; mTable.ViewTypeToggle = true; mTable.Selected = preSelectedRows; ResizeWindow(true); }
protected void view1_MouseDown(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Pressed) { MainPlayer.Controller.LockCameraView = false; } D3DView view1 = (D3DView)sender; Point p = Mouse.GetPosition(view1); ObjectPicker.SelectionRay(e, p); }
// Use this for initialization void Start () { ritualQueue = new Queue<Ritual>(); for(int i = 0; i < NUM_RITUALS; i++) { ritualQueue.Enqueue(ritualObjects[i].GetComponent<Ritual>()); } fadeScript = Image.GetComponent<FadeSceneScript>(); //PickerScript = FirstPersonCamera.GetComponentInParent<ObjectPicker>(); PickerScript = firstPersonCharacter.GetComponent<ObjectPicker>(); firstPersonCharacter.SetActive( false); timerScript.enabled = true; Camera.SetupCurrent(introCamera); }
public DualPaneSimPickerRowController(TableRow row, TableContainer table, ObjectPicker.RowInfo info) { this.mIsEnabled = true; this.mRow = row; this.mTable = table; this.mInfo = info; List<CellController> cellControllers = this.mRow.CellControllers; List<WindowBase> cellWindows = this.mRow.CellWindows; TableThumbAndTextController tableThumbAndTextController = new TableThumbAndTextController(cellWindows[0]); cellControllers.Add(tableThumbAndTextController); tableThumbAndTextController.ImageSize = 40f; tableThumbAndTextController.Entry = ((MinorPet)this.mInfo.Item).GetLocalizedName() ; tableThumbAndTextController.Thumbnail = ((MinorPet)this.mInfo.Item).GetThumbnailKey(); }
public DualPaneSimPickerRowController(TableRow row, TableContainer table, ObjectPicker.RowInfo info, float multiplyer) { this.mIsEnabled = true; this.mRow = row; this.mTable = table; this.mInfo = info; List<CellController> cellControllers = this.mRow.CellControllers; List<WindowBase> cellWindows = this.mRow.CellWindows; TableThumbAndTextController tableThumbAndTextController = new TableThumbAndTextController(cellWindows[0]); cellControllers.Add(tableThumbAndTextController); tableThumbAndTextController.ImageSize = 40f; tableThumbAndTextController.Entry = ((InventoryItem)this.mInfo.Item).Object.GetLocalizedName() + " " + ShoppingMethods.CalculatePrice(((InventoryItem)this.mInfo.Item).Object.Value, multiplyer) + " §"; tableThumbAndTextController.Thumbnail = ((InventoryItem)this.mInfo.Item).Object.GetThumbnailKey(); }
public TaxCollectorSimpleDialog(string title, int funds, List <ObjectPicker.TabInfo> listObjs, List <ObjectPicker.HeaderInfo> headers, bool viewTypeToggle, Vector2 position) : base("SimplePurchaseDialog", 1, true, ModalDialog.PauseMode.PauseSimulator, null) { if (this.mModalDialogWindow != null) { Text text = this.mModalDialogWindow.GetChildByID(99576787u, false) as Text; text.Caption = title; this.mFunds = funds; text = (this.mModalDialogWindow.GetChildByID(99576788u, false) as Text); text.Caption = Responder.Instance.LocalizationModel.LocalizeString("Ui/Caption/Shopping/Cart:AvailableFunds", new object[] { UIUtils.FormatMoney(funds) }); this.mTable = (this.mModalDialogWindow.GetChildByID(99576784u, false) as ObjectPicker); this.mTable.ObjectTable.TableChanged += new TableContainer.TableChangedEventHandler(this.OnTableChanged); this.mTable.ObjectTable.SelectionChanged += new UIEventHandler <UISelectionChangeEventArgs>(this.OnSelectionChanged); this.mOkayButton = (this.mModalDialogWindow.GetChildByID(99576785u, false) as Button); this.mOkayButton.Enabled = false; this.mOkayButton.Click += new UIEventHandler <UIButtonClickEventArgs>(this.OnOkayButtonClick); this.mOkayButton.Caption = CMStoreSet.LocalizeString("Select", new object[0]); base.OkayID = this.mOkayButton.ID; base.SelectedID = this.mOkayButton.ID; this.mCloseButton = (this.mModalDialogWindow.GetChildByID(99576786u, false) as Button); this.mCloseButton.Click += new UIEventHandler <UIButtonClickEventArgs>(this.OnCloseButtonClick); base.CancelID = this.mCloseButton.ID; this.mTableOffset = this.mModalDialogWindow.Area.BottomRight - this.mModalDialogWindow.Area.TopLeft - (this.mTable.Area.BottomRight - this.mTable.Area.TopLeft); this.mTable.Populate(listObjs, headers, 1); this.mTable.ViewTypeToggle = viewTypeToggle; this.mModalDialogWindow.Area = new Rect(this.mModalDialogWindow.Area.TopLeft, this.mModalDialogWindow.Area.TopLeft + this.mTable.TableArea.BottomRight + this.mTableOffset); float x = position.x; float y = position.y; if (x < 0f && y < 0f) { this.mModalDialogWindow.CenterInParent(); } else { Rect area = this.mModalDialogWindow.Area; float num = area.BottomRight.x - area.TopLeft.x; float num2 = area.BottomRight.y - area.TopLeft.y; area.Set(x, y, x + num, y + num2); this.mModalDialogWindow.Area = area; } this.mModalDialogWindow.Visible = true; } }
public TaxCollectorSimpleDialog(string title, int funds, List<ObjectPicker.TabInfo> listObjs, List<ObjectPicker.HeaderInfo> headers, bool viewTypeToggle, Vector2 position) : base("SimplePurchaseDialog", 1, true, ModalDialog.PauseMode.PauseSimulator, null) { if (this.mModalDialogWindow != null) { Text text = this.mModalDialogWindow.GetChildByID(99576787u, false) as Text; text.Caption = title; this.mFunds = funds; text = (this.mModalDialogWindow.GetChildByID(99576788u, false) as Text); text.Caption = Responder.Instance.LocalizationModel.LocalizeString("Ui/Caption/Shopping/Cart:AvailableFunds", new object[] { UIUtils.FormatMoney(funds) }); this.mTable = (this.mModalDialogWindow.GetChildByID(99576784u, false) as ObjectPicker); this.mTable.ObjectTable.TableChanged += new TableContainer.TableChangedEventHandler(this.OnTableChanged); this.mTable.ObjectTable.SelectionChanged += new UIEventHandler<UISelectionChangeEventArgs>(this.OnSelectionChanged); this.mOkayButton = (this.mModalDialogWindow.GetChildByID(99576785u, false) as Button); this.mOkayButton.Enabled = false; this.mOkayButton.Click += new UIEventHandler<UIButtonClickEventArgs>(this.OnOkayButtonClick); this.mOkayButton.Caption = CMStoreSet.LocalizeString("Select", new object[0]); base.OkayID = this.mOkayButton.ID; base.SelectedID = this.mOkayButton.ID; this.mCloseButton = (this.mModalDialogWindow.GetChildByID(99576786u, false) as Button); this.mCloseButton.Click += new UIEventHandler<UIButtonClickEventArgs>(this.OnCloseButtonClick); base.CancelID = this.mCloseButton.ID; this.mTableOffset = this.mModalDialogWindow.Area.BottomRight - this.mModalDialogWindow.Area.TopLeft - (this.mTable.Area.BottomRight - this.mTable.Area.TopLeft); this.mTable.Populate(listObjs, headers, 1); this.mTable.ViewTypeToggle = viewTypeToggle; this.mModalDialogWindow.Area = new Rect(this.mModalDialogWindow.Area.TopLeft, this.mModalDialogWindow.Area.TopLeft + this.mTable.TableArea.BottomRight + this.mTableOffset); float x = position.x; float y = position.y; if (x < 0f && y < 0f) { this.mModalDialogWindow.CenterInParent(); } else { Rect area = this.mModalDialogWindow.Area; float num = area.BottomRight.x - area.TopLeft.x; float num2 = area.BottomRight.y - area.TopLeft.y; area.Set(x, y, x + num, y + num2); this.mModalDialogWindow.Area = area; } this.mModalDialogWindow.Visible = true; } }
void Start() { circleHand = FindObjectOfType <CircleHandler>(); hand = FindObjectOfType <SnapperHandler>(); seq = FindObjectOfType <Sequensing>(); pick = FindObjectOfType <ObjectPicker>(); parentObject = transform.parent.gameObject; for (int i = 0; i < ignoreThisIfNeedid.Count; i++) { try { Physics.IgnoreCollision(ignoreThisIfNeedid[i], GetComponent <BoxCollider>()); } catch { } } }
public BuildingScreen(CompressedBuilding compressedBuilding, BuildingsBinary buildingsBinary, EditorParams editorParams) { GameController.inGameState = InGameState.RUNNING; this.editorParams = editorParams; this.compressedBuilding = compressedBuilding; GameController.editorInMenu = false; this.buildingsBinary = buildingsBinary; AddContainer(new BackgroundMenu(new Rectangle(0, 0, 0, 0), DockType.SCREENRESOLUTION, TextureSheet.Editor)); editorView = new EditorView(new Rectangle(100, 100, 2000, 1500), DockType.SCREENRESOLUTION, compressedBuilding, editorParams); AddContainer(editorView); buildingPicker = new BuildingPicker(new Rectangle(200, 150, 400, 500), DockType.TOPRIGHTFIXEDY, compressedBuilding, editorParams); shadowPicker = new ShadowPicker(new Rectangle(200, 150, 400, 500), DockType.TOPRIGHTFIXEDY, compressedBuilding, editorParams); objectPicker = new ObjectPicker(new Rectangle(200, 150, 400, 500), DockType.TOPRIGHTFIXEDY, compressedBuilding, editorParams); drivingPicker = new DrivingPicker(new Rectangle(200, 150, 400, 500), DockType.TOPRIGHTFIXEDY, compressedBuilding, editorParams); AddContainer(buildingPicker); general = new General(new Rectangle(200, 150, 600, 1250), DockType.TOPLEFTFIXEDY, compressedBuilding, editorParams); AddContainer(general); }
// Methods public ObjectPickerDialog(string title, List<ObjectPicker.TabInfo> listObjs, List<ObjectPicker.HeaderInfo> headers, int numSelectableRows, List<ObjectPicker.RowInfo> preSelectedRows) : base("NRaas.OpportunityControl.UiObjectPicker", 1, true, ModalDialog.PauseMode.PauseSimulator, null) { if (mModalDialogWindow != null) { Text childByID = mModalDialogWindow.GetChildByID(0x5ef6bd3, false) as Text; childByID.Caption = title; mTable = mModalDialogWindow.GetChildByID(0x5ef6bd0, false) as ObjectPicker; mTable.ObjectTable.TableChanged += new TableContainer.TableChangedEventHandler(OnTableChanged); mTable.SelectionChanged += new ObjectPicker.ObjectPickerSelectionChanged(OnSelectionChanged); mTable.RowSelected += new ObjectPicker.ObjectPickerSelectionChanged(OnSelectionChanged); mOkayButton = mModalDialogWindow.GetChildByID(0x5ef6bd1, false) as Button; mOkayButton.TooltipText = NRaas.OpportunityControl.Localize("Choice:OK"); mOkayButton.Enabled = false; mOkayButton.Click += new UIEventHandler<UIButtonClickEventArgs>(OnOkayButtonClick); OkayID = mOkayButton.ID; SelectedID = mOkayButton.ID; mCloseButton = mModalDialogWindow.GetChildByID(0x5ef6bd2, false) as Button; mCloseButton.TooltipText = Localization.LocalizeString("Ui/Caption/ObjectPicker:Cancel", new object[0]); mCloseButton.Click += new UIEventHandler<UIButtonClickEventArgs>(OnCloseButtonClick); CancelID = mCloseButton.ID; mTableOffset = (mModalDialogWindow.Area.BottomRight - mModalDialogWindow.Area.TopLeft) - (mTable.Area.BottomRight - mTable.Area.TopLeft); mTable.Populate(listObjs, headers, numSelectableRows); mTable.ViewTypeToggle = true; mTable.Selected = preSelectedRows; mModalDialogWindow.Area = new Rect(mModalDialogWindow.Area.TopLeft, (mModalDialogWindow.Area.TopLeft + mTable.TableArea.BottomRight) + mTableOffset); Rect area = mModalDialogWindow.Area; float num = area.BottomRight.x - area.TopLeft.x; float num2 = area.BottomRight.y - area.TopLeft.y; Rect rect2 = mModalDialogWindow.Parent.Area; float num5 = rect2.BottomRight.x - rect2.TopLeft.x; float num6 = rect2.BottomRight.y - rect2.TopLeft.y; float x = (float)Math.Round((double)((num5 - num) / 2f)); float y = (float)Math.Round((double)((num6 - num2) / 2f)); area.Set(x, y, x + num, y + num2); mModalDialogWindow.Area = area; mModalDialogWindow.Visible = true; } }
// Methods public ObjectPickerDialog(string title, List <ObjectPicker.TabInfo> listObjs, List <ObjectPicker.HeaderInfo> headers, int numSelectableRows, List <ObjectPicker.RowInfo> preSelectedRows) : base("NRaas.OpportunityControl.UiObjectPicker", 1, true, ModalDialog.PauseMode.PauseSimulator, null) { if (mModalDialogWindow != null) { Text childByID = mModalDialogWindow.GetChildByID(0x5ef6bd3, false) as Text; childByID.Caption = title; mTable = mModalDialogWindow.GetChildByID(0x5ef6bd0, false) as ObjectPicker; mTable.ObjectTable.TableChanged += new TableContainer.TableChangedEventHandler(OnTableChanged); mTable.SelectionChanged += new ObjectPicker.ObjectPickerSelectionChanged(OnSelectionChanged); mTable.RowSelected += new ObjectPicker.ObjectPickerSelectionChanged(OnSelectionChanged); mOkayButton = mModalDialogWindow.GetChildByID(0x5ef6bd1, false) as Button; mOkayButton.TooltipText = NRaas.OpportunityControl.Localize("Choice:OK"); mOkayButton.Enabled = false; mOkayButton.Click += new UIEventHandler <UIButtonClickEventArgs>(OnOkayButtonClick); OkayID = mOkayButton.ID; SelectedID = mOkayButton.ID; mCloseButton = mModalDialogWindow.GetChildByID(0x5ef6bd2, false) as Button; mCloseButton.TooltipText = Localization.LocalizeString("Ui/Caption/ObjectPicker:Cancel", new object[0]); mCloseButton.Click += new UIEventHandler <UIButtonClickEventArgs>(OnCloseButtonClick); CancelID = mCloseButton.ID; mTableOffset = (mModalDialogWindow.Area.BottomRight - mModalDialogWindow.Area.TopLeft) - (mTable.Area.BottomRight - mTable.Area.TopLeft); mTable.Populate(listObjs, headers, numSelectableRows); mTable.ViewTypeToggle = true; mTable.Selected = preSelectedRows; mModalDialogWindow.Area = new Rect(mModalDialogWindow.Area.TopLeft, (mModalDialogWindow.Area.TopLeft + mTable.TableArea.BottomRight) + mTableOffset); Rect area = mModalDialogWindow.Area; float num = area.BottomRight.x - area.TopLeft.x; float num2 = area.BottomRight.y - area.TopLeft.y; Rect rect2 = mModalDialogWindow.Parent.Area; float num5 = rect2.BottomRight.x - rect2.TopLeft.x; float num6 = rect2.BottomRight.y - rect2.TopLeft.y; float x = (float)Math.Round((double)((num5 - num) / 2f)); float y = (float)Math.Round((double)((num6 - num2) / 2f)); area.Set(x, y, x + num, y + num2); mModalDialogWindow.Area = area; mModalDialogWindow.Visible = true; } }
/// <summary> /// Initialize everything Direct3D needs to run /// </summary> protected override void InitD3D() { base.InitD3D(); FillColor = new Color4(0.5f, 0.5f, 0.9f); // Create default scene CreateNewScene(); // Initialize our picker ObjectPicker = new ObjectPicker(); ObjectSpawner = new ObjectSpawner(); Subscribe(ObjectSpawner); InitEffects(); // Use the first valid render effect, if exists if (RenderEffects.Count == 0) { throw new Exception("No render effects could be loaded!"); } ActiveRenderEffect = RenderEffects[1]; }
public BigObjectPickerDialog(bool modal, ModalDialog.PauseMode pauseMode, string title, string buttonTrue, string buttonFalse, List<ObjectPicker.TabInfo> listObjs, List<ObjectPicker.HeaderInfo> headers, int numSelectableRows, Vector2 position, bool viewTypeToggle, List<ObjectPicker.RowInfo> preSelectedRows, bool showHeadersAndToggle) : base("cmo_BigObjectPicker", 1, modal, pauseMode, null) { if (this.mModalDialogWindow != null) { Text text = this.mModalDialogWindow.GetChildByID(99576787u, false) as Text; text.Caption = title; this.mTable = (this.mModalDialogWindow.GetChildByID(99576784u, false) as ObjectPicker); this.mTable.ObjectTable.TableChanged += new TableContainer.TableChangedEventHandler(this.OnTableChanged); this.mTable.SelectionChanged += new ObjectPicker.ObjectPickerSelectionChanged(this.OnSelectionChanged); this.mTable.RowSelected += new ObjectPicker.ObjectPickerSelectionChanged(this.OnSelectionChanged); this.mOkayButton = (this.mModalDialogWindow.GetChildByID(99576785u, false) as Button); this.mOkayButton.TooltipText = buttonTrue; this.mOkayButton.Enabled = false; //this.mOkayButton.Click += new UIEventHandler<UIButtonClickEventArgs>(this.OnOkayButtonClick); UIManager.RegisterEvent<UIButtonClickEventArgs>(this.mOkayButton, 678582774u, new UIEventHandler<UIButtonClickEventArgs>(this.OnOkayButtonClick)); base.OkayID = this.mOkayButton.ID; base.SelectedID = this.mOkayButton.ID; this.mCloseButton = (this.mModalDialogWindow.GetChildByID(99576786u, false) as Button); this.mCloseButton.TooltipText = buttonFalse; //this.mCloseButton.Click += new UIEventHandler<UIButtonClickEventArgs>(this.OnCloseButtonClick); UIManager.RegisterEvent<UIButtonClickEventArgs>(this.mCloseButton, 678582774u, new UIEventHandler<UIButtonClickEventArgs>(this.OnCloseButtonClick)); base.CancelID = this.mCloseButton.ID; this.mTableOffset = this.mModalDialogWindow.Area.BottomRight - this.mModalDialogWindow.Area.TopLeft - (this.mTable.Area.BottomRight - this.mTable.Area.TopLeft); this.mTable.ShowHeaders = showHeadersAndToggle; this.mTable.ShowToggle = showHeadersAndToggle; this.mTable.ObjectTable.NoAutoSizeGridResize = true; this.mTable.Populate(listObjs, headers, numSelectableRows); this.mTable.ViewTypeToggle = viewTypeToggle; this.mPreSelectedRows = preSelectedRows; this.mTable.TablePopulationComplete += new VoidEventHandler(this.OnPopulationCompleted); if (!this.mTable.ShowToggle) { Window window = this.mModalDialogWindow.GetChildByID(99576788u, false) as Window; Window window2 = this.mModalDialogWindow.GetChildByID(99576789u, false) as Window; this.mTable.Area = new Rect(this.mTable.Area.TopLeft.x, this.mTable.Area.TopLeft.y - 64f, this.mTable.Area.BottomRight.x, this.mTable.Area.BottomRight.y); window2.Area = new Rect(window2.Area.TopLeft.x, window2.Area.TopLeft.y - 64f, window2.Area.BottomRight.x, window2.Area.BottomRight.y); window.Area = new Rect(window.Area.TopLeft.x, window.Area.TopLeft.y - 64f, window.Area.BottomRight.x, window.Area.BottomRight.y); } this.mModalDialogWindow.Area = new Rect(this.mModalDialogWindow.Area.TopLeft, this.mModalDialogWindow.Area.TopLeft + this.mTable.TableArea.BottomRight + this.mTableOffset); Rect area = this.mModalDialogWindow.Area; float num = area.BottomRight.x - area.TopLeft.x; float num2 = area.BottomRight.y - area.TopLeft.y; if (!this.mTable.ShowToggle) { num2 -= 50f; } float num3 = position.x; float num4 = position.y; if (num3 < 0f && num4 < 0f) { Rect area2 = this.mModalDialogWindow.Parent.Area; float num5 = area2.BottomRight.x - area2.TopLeft.x; float num6 = area2.BottomRight.y - area2.TopLeft.y; num3 = (float)Math.Round((double)((num5 - num) / 2f)); num4 = (float)Math.Round((double)((num6 - num2) / 2f)); } area.Set(num3, num4, num3 + num, num4 + num2); this.mModalDialogWindow.Area = area; this.mModalDialogWindow.Visible = true; } }
//private EntityActionNode eaNode; //private EntityConditionNode ecNode; void RenderDialogNodeGUI(NodeEditor nodeEditor, XNode.Node node) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); dn = node as DialogNode; if (dn != null) { EditorGUILayout.BeginVertical(EditorStyles.helpBox); if (dn.showDialogText = EditorGUILayout.Foldout(dn.showDialogText, "Dialog")) { EditorGUILayout.LabelField("Dialog"); EditorGUILayout.BeginVertical(EditorStyles.helpBox); dn.dialog.text = EditorGUILayout.TextArea(dn.dialog.text, EditorStyles.wordWrappedLabel, GUILayout.MinHeight(60), GUILayout.MaxWidth(180)); EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); if (dn.Options = EditorGUILayout.Foldout(dn.Options, "Options")) { EditorGUILayout.LabelField("Talk ID"); dn.dialog.TalkID = EditorGUILayout.IntSlider(dn.dialog.TalkID, 0, 6); dn.dialog.clip = (AudioClip)EditorGUILayout.ObjectField("Audio", dn.dialog.clip, typeof(AudioClip), false); if (dn.dialog.hasEvent = EditorGUILayout.Toggle("Event", dn.dialog.hasEvent)) { dn.dialog.eventID = EditorGUILayout.IntField("Event ID", dn.dialog.eventID); } dn.dialog.isEntry = EditorGUILayout.Toggle("Is Entry", dn.dialog.isEntry); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); if (dn.showDialogCondition = EditorGUILayout.Foldout(dn.showDialogCondition, "Conditions")) { if (dn.dialog.conditions == null) { dn.dialog.conditions = new DialogObject.DialogCondition(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); dn.dialog.conditions.isOneTime = EditorGUILayout.Toggle("One Shot", dn.dialog.conditions.isOneTime); if (dn.dialog.conditions.isOneTime && string.IsNullOrEmpty(dn.dialog.conditions.oneTimeID)) { dn.dialog.conditions.oneTimeID = ToolKit.GetUniqueID(); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); if (dn.showDialogVar = EditorGUILayout.Foldout(dn.showDialogVar, "Global Var")) { EditorGUILayout.LabelField(dn.dialog.conditions.varID); if (GUILayout.Button("Set Var")) { ObjectPicker.GetObject(ObjectPicker.ObjectType.Variable, dn.SetDialogVar); } dn.dialog.conditions.varState = EditorGUILayout.Toggle("State", dn.dialog.conditions.varState); } EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); if (GUILayout.Button("Add", EditorStyles.toolbarButton)) { dn.AddResponse(); } if (GUILayout.Button("Remove", EditorStyles.toolbarButton)) { dn.RemoveResponse(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); { int i = 0; if (dn.selectedResponse > dn.dialog.responses.Length - 1) { dn.selectedResponse = -1; } foreach (DialogObject.DialogResponse response in dn.dialog.responses) { EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); string s = ""; if (!string.IsNullOrEmpty(response.response)) { s = TruncateLongString(response.response, 16); } else { s = "Response " + i.ToString(); } if (GUILayout.Button(s, EditorStyles.foldout)) { if (dn.selectedResponse == i) { dn.selectedResponse = -1; } else { dn.selectedResponse = i; } } nodeEditor.OnNodeGUI(i); EditorGUILayout.EndHorizontal(); if (dn.selectedResponse == i) { if (dn.dialog.responses != null && dn.dialog.responses.Length > 0 && dn.selectedResponse >= 0) { EditorGUILayout.BeginVertical(EditorStyles.helpBox); dn.dialog.responses[dn.selectedResponse].response = EditorGUILayout.TextArea(dn.dialog.responses[dn.selectedResponse].response, EditorStyles.wordWrappedLabel, GUILayout.MinHeight(60), GUILayout.MaxWidth(180)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); dn.responseOptions = EditorGUILayout.Foldout(dn.responseOptions, "Options"); if (dn.responseOptions) { dn.conditionOptions = false; dn.dialog.responses[dn.selectedResponse].eventID = EditorGUILayout.IntField("Event", dn.dialog.responses[dn.selectedResponse].eventID); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); dn.conditionOptions = EditorGUILayout.Foldout(dn.conditionOptions, "Conditions"); if (dn.conditionOptions) { dn.responseOptions = false; if (dn.dialog.responses[dn.selectedResponse].conditions == null) { dn.dialog.responses[dn.selectedResponse].conditions = new DialogObject.DialogCondition(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); dn.dialog.responses[dn.selectedResponse].conditions.isOneTime = EditorGUILayout.Toggle("One Shot", dn.dialog.responses[dn.selectedResponse].conditions.isOneTime); if (dn.dialog.responses[dn.selectedResponse].conditions.isOneTime && string.IsNullOrEmpty(dn.dialog.responses[dn.selectedResponse].conditions.oneTimeID)) { dn.dialog.responses[dn.selectedResponse].conditions.oneTimeID = ToolKit.GetUniqueID(); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); if (dn.showVar = EditorGUILayout.Foldout(dn.showVar, "Global Var")) { EditorGUILayout.LabelField(dn.dialog.responses[dn.selectedResponse].conditions.varID); if (GUILayout.Button("Set Var")) { //ObjectPicker.GetObject(ObjectPicker.ObjectType.Variable, dn.SetVar); Debug.Log("Get/set vars"); } dn.dialog.responses[dn.selectedResponse].conditions.varState = EditorGUILayout.Toggle("State", dn.dialog.responses[dn.selectedResponse].conditions.varState); } EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } } i++; EditorGUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); EditorUtility.SetDirty(dn); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); }
void OnTriggerEnter(Collider other) { Debug.Log ("other: "+other.name); if (other.GetComponent<Bow>() && !aiming) { Bow bow = other.GetComponent<Bow>(); myBow = bow; if (isPickedUp && bow.isPickedUp) { bow.currentArrow = this; aiming = true; targetToLookAt = transform.parent; transform.parent = bow.transform; attachPoint = transform.localPosition; transform.localPosition = Vector3.zero; myBowsPicker = myBow.myTransform.parent.GetComponent<ObjectPicker> (); } } }
/// <summary> /// Starts the object picker. /// </summary> /// <param name="typ"></param> /// <param name="callback"></param> public static void GetObject(ObjectType typ, System.Action <object> callback) { ObjectPicker objPick = GetWindow <ObjectPicker>(); objPick.Init(typ, callback); }
private void DrawToolbar() { SirenixEditorGUI.BeginHorizontalToolbar(); { // Label if (info.DropZone != null && DragAndDropManager.IsDragInProgress && info.DropZone.IsAccepted == false) { GUIHelper.PushGUIEnabled(false); } if (info.Property.ValueEntry.ListLengthChangedFromPrefab) { GUIHelper.PushIsBoldLabel(true); } if (info.ListConfig.HideFoldoutWhileEmpty && info.IsEmpty || info.CustomListDrawerOptions.Expanded) { GUILayout.Label(info.Label, GUILayoutOptions.ExpandWidth(false)); } else { info.Toggled.Value = SirenixEditorGUI.Foldout(info.Toggled.Value, info.Label ?? GUIContent.none); } if (info.Property.ValueEntry.ListLengthChangedFromPrefab) { GUIHelper.PopIsBoldLabel(); } if (info.CustomListDrawerOptions.Expanded) { info.Toggled.Value = true; } if (info.DropZone != null && DragAndDropManager.IsDragInProgress && info.DropZone.IsAccepted == false) { GUIHelper.PopGUIEnabled(); } GUILayout.FlexibleSpace(); // Item Count if (info.CustomListDrawerOptions.ShowItemCountHasValue ? info.CustomListDrawerOptions.ShowItemCount : info.ListConfig.ShowItemCount) { if (info.Property.ValueEntry.ValueState == PropertyValueState.CollectionLengthConflict) { GUILayout.Label(info.Count + " / " + info.CollectionResolver.MaxCollectionLength + " items", EditorStyles.centeredGreyMiniLabel); } else { GUILayout.Label(info.IsEmpty ? "Empty" : info.Count + " items", EditorStyles.centeredGreyMiniLabel); } } bool paging = info.CustomListDrawerOptions.PagingHasValue ? info.CustomListDrawerOptions.ShowPaging : true; bool hidePaging = info.ListConfig.HidePagingWhileCollapsed && info.Toggled.Value == false || info.ListConfig.HidePagingWhileOnlyOnePage && info.Count <= info.NumberOfItemsPerPage; int numberOfItemsPrPage = Math.Max(1, info.NumberOfItemsPerPage); int numberOfPages = Mathf.CeilToInt(info.Count / (float)numberOfItemsPrPage); int pageIndex = info.Count == 0 ? 0 : (info.StartIndex / numberOfItemsPrPage) % info.Count; // Paging if (paging) { bool disablePaging = paging && !hidePaging && (DragAndDropManager.IsDragInProgress || info.ShowAllWhilePaging || info.Toggled.Value == false); if (disablePaging) { GUIHelper.PushGUIEnabled(false); } if (!hidePaging) { if (pageIndex == 0) { GUIHelper.PushGUIEnabled(false); } if (SirenixEditorGUI.ToolbarButton(EditorIcons.TriangleLeft, true)) { if (Event.current.button == 0) { info.StartIndex -= numberOfItemsPrPage; } else { info.StartIndex = 0; } } if (pageIndex == 0) { GUIHelper.PopGUIEnabled(); } var userPageIndex = EditorGUILayout.IntField((numberOfPages == 0 ? 0 : (pageIndex + 1)), GUILayoutOptions.Width(10 + numberOfPages.ToString(CultureInfo.InvariantCulture).Length * 10)) - 1; if (pageIndex != userPageIndex) { info.StartIndex = userPageIndex * numberOfItemsPrPage; } GUILayout.Label("/ " + numberOfPages); if (pageIndex == numberOfPages - 1) { GUIHelper.PushGUIEnabled(false); } if (SirenixEditorGUI.ToolbarButton(EditorIcons.TriangleRight, true)) { if (Event.current.button == 0) { info.StartIndex += numberOfItemsPrPage; } else { info.StartIndex = numberOfItemsPrPage * numberOfPages; } } if (pageIndex == numberOfPages - 1) { GUIHelper.PopGUIEnabled(); } } pageIndex = info.Count == 0 ? 0 : (info.StartIndex / numberOfItemsPrPage) % info.Count; var newStartIndex = Mathf.Clamp(pageIndex * numberOfItemsPrPage, 0, Mathf.Max(0, info.Count - 1)); if (newStartIndex != info.StartIndex) { info.StartIndex = newStartIndex; var newPageIndex = info.Count == 0 ? 0 : (info.StartIndex / numberOfItemsPrPage) % info.Count; if (pageIndex != newPageIndex) { pageIndex = newPageIndex; info.StartIndex = Mathf.Clamp(pageIndex * numberOfItemsPrPage, 0, Mathf.Max(0, info.Count - 1)); } } info.EndIndex = Mathf.Min(info.StartIndex + numberOfItemsPrPage, info.Count); if (disablePaging) { GUIHelper.PopGUIEnabled(); } } else { info.StartIndex = 0; info.EndIndex = info.Count; } if (paging && hidePaging == false && info.ListConfig.ShowExpandButton) { if (info.Count < 300) { if (SirenixEditorGUI.ToolbarButton(info.ShowAllWhilePaging ? EditorIcons.TriangleUp : EditorIcons.TriangleDown, true)) { info.ShowAllWhilePaging = !info.ShowAllWhilePaging; } } else { info.ShowAllWhilePaging = false; } } // Add Button if (info.IsReadOnly == false && !info.HideAddButton) { info.ObjectPicker = ObjectPicker.GetObjectPicker(info, info.CollectionResolver.ElementType); var superHackyAddFunctionWeSeriouslyNeedANewListDrawer = CollectionDrawerStaticInfo.NextCustomAddFunction; CollectionDrawerStaticInfo.NextCustomAddFunction = null; if (SirenixEditorGUI.ToolbarButton(EditorIcons.Plus)) { if (superHackyAddFunctionWeSeriouslyNeedANewListDrawer != null) { superHackyAddFunctionWeSeriouslyNeedANewListDrawer(); } else if (info.GetCustomAddFunction != null) { var objs = new object[info.Property.Tree.WeakTargets.Count]; for (int i = 0; i < objs.Length; i++) { objs[i] = info.GetCustomAddFunction(info.Property.ParentValues[i]); } info.CollectionResolver.QueueAdd(objs); } else if (info.GetCustomAddFunctionVoid != null) { info.GetCustomAddFunctionVoid(info.Property.ParentValues[0]); this.Property.ValueEntry.WeakValues.ForceMarkDirty(); } else if (info.CustomListDrawerOptions.AlwaysAddDefaultValue) { var objs = new object[info.Property.Tree.WeakTargets.Count]; if (info.Property.ValueEntry.SerializationBackend == SerializationBackend.Unity) { for (int i = 0; i < objs.Length; i++) { objs[i] = UnitySerializationUtility.CreateDefaultUnityInitializedObject(info.CollectionResolver.ElementType); } } else { for (int i = 0; i < objs.Length; i++) { if (info.CollectionResolver.ElementType.IsValueType) { objs[i] = Activator.CreateInstance(info.CollectionResolver.ElementType); } else { objs[i] = null; } } } //info.ListValueChanger.AddListElement(objs, "Add default value"); info.CollectionResolver.QueueAdd(objs); } else if (info.CollectionResolver.ElementType.InheritsFrom <UnityEngine.Object>() && Event.current.modifiers == EventModifiers.Control) { info.CollectionResolver.QueueAdd(new object[info.Property.Tree.WeakTargets.Count]); } else { info.ObjectPicker.ShowObjectPicker( null, info.Property.GetAttribute <AssetsOnlyAttribute>() == null, GUIHelper.GetCurrentLayoutRect(), info.Property.ValueEntry.SerializationBackend == SerializationBackend.Unity); } } info.JumpToNextPageOnAdd = paging && (info.Count % numberOfItemsPrPage == 0) && (pageIndex + 1 == numberOfPages); } if (info.OnTitleBarGUI != null) { info.OnTitleBarGUI(info.Property.ParentValues[0]); } } SirenixEditorGUI.EndHorizontalToolbar(); }
public BigObjectPickerDialog(bool modal, ModalDialog.PauseMode pauseMode, string title, string buttonTrue, string buttonFalse, List <ObjectPicker.TabInfo> listObjs, List <ObjectPicker.HeaderInfo> headers, int numSelectableRows, Vector2 position, bool viewTypeToggle, List <ObjectPicker.RowInfo> preSelectedRows, bool showHeadersAndToggle) : base("cmo_BigObjectPicker", 1, modal, pauseMode, null) { if (this.mModalDialogWindow != null) { Text text = this.mModalDialogWindow.GetChildByID(99576787u, false) as Text; text.Caption = title; this.mTable = (this.mModalDialogWindow.GetChildByID(99576784u, false) as ObjectPicker); this.mTable.ObjectTable.TableChanged += new TableContainer.TableChangedEventHandler(this.OnTableChanged); this.mTable.SelectionChanged += new ObjectPicker.ObjectPickerSelectionChanged(this.OnSelectionChanged); this.mTable.RowSelected += new ObjectPicker.ObjectPickerSelectionChanged(this.OnSelectionChanged); this.mOkayButton = (this.mModalDialogWindow.GetChildByID(99576785u, false) as Button); this.mOkayButton.TooltipText = buttonTrue; this.mOkayButton.Enabled = false; //this.mOkayButton.Click += new UIEventHandler<UIButtonClickEventArgs>(this.OnOkayButtonClick); UIManager.RegisterEvent <UIButtonClickEventArgs>(this.mOkayButton, 678582774u, new UIEventHandler <UIButtonClickEventArgs>(this.OnOkayButtonClick)); base.OkayID = this.mOkayButton.ID; base.SelectedID = this.mOkayButton.ID; this.mCloseButton = (this.mModalDialogWindow.GetChildByID(99576786u, false) as Button); this.mCloseButton.TooltipText = buttonFalse; //this.mCloseButton.Click += new UIEventHandler<UIButtonClickEventArgs>(this.OnCloseButtonClick); UIManager.RegisterEvent <UIButtonClickEventArgs>(this.mCloseButton, 678582774u, new UIEventHandler <UIButtonClickEventArgs>(this.OnCloseButtonClick)); base.CancelID = this.mCloseButton.ID; this.mTableOffset = this.mModalDialogWindow.Area.BottomRight - this.mModalDialogWindow.Area.TopLeft - (this.mTable.Area.BottomRight - this.mTable.Area.TopLeft); this.mTable.ShowHeaders = showHeadersAndToggle; this.mTable.ShowToggle = showHeadersAndToggle; this.mTable.ObjectTable.NoAutoSizeGridResize = true; this.mTable.Populate(listObjs, headers, numSelectableRows); this.mTable.ViewTypeToggle = viewTypeToggle; this.mPreSelectedRows = preSelectedRows; this.mTable.TablePopulationComplete += new VoidEventHandler(this.OnPopulationCompleted); if (!this.mTable.ShowToggle) { Window window = this.mModalDialogWindow.GetChildByID(99576788u, false) as Window; Window window2 = this.mModalDialogWindow.GetChildByID(99576789u, false) as Window; this.mTable.Area = new Rect(this.mTable.Area.TopLeft.x, this.mTable.Area.TopLeft.y - 64f, this.mTable.Area.BottomRight.x, this.mTable.Area.BottomRight.y); window2.Area = new Rect(window2.Area.TopLeft.x, window2.Area.TopLeft.y - 64f, window2.Area.BottomRight.x, window2.Area.BottomRight.y); window.Area = new Rect(window.Area.TopLeft.x, window.Area.TopLeft.y - 64f, window.Area.BottomRight.x, window.Area.BottomRight.y); } this.mModalDialogWindow.Area = new Rect(this.mModalDialogWindow.Area.TopLeft, this.mModalDialogWindow.Area.TopLeft + this.mTable.TableArea.BottomRight + this.mTableOffset); Rect area = this.mModalDialogWindow.Area; float num = area.BottomRight.x - area.TopLeft.x; float num2 = area.BottomRight.y - area.TopLeft.y; if (!this.mTable.ShowToggle) { num2 -= 50f; } float num3 = position.x; float num4 = position.y; if (num3 < 0f && num4 < 0f) { Rect area2 = this.mModalDialogWindow.Parent.Area; float num5 = area2.BottomRight.x - area2.TopLeft.x; float num6 = area2.BottomRight.y - area2.TopLeft.y; num3 = (float)Math.Round((double)((num5 - num) / 2f)); num4 = (float)Math.Round((double)((num6 - num2) / 2f)); } area.Set(num3, num4, num3 + num, num4 + num2); this.mModalDialogWindow.Area = area; this.mModalDialogWindow.Visible = true; } }
// Use this for initialization void Start() { worldMgr = FindObjectOfType<WorldManager>(); picker = FindObjectOfType<ObjectPicker>(); }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <T> entry, GUIContent label) { var isToggled = entry.Property.Context.GetPersistent <bool>(this, "Toggled", SirenixEditorGUI.ExpandFoldoutByDefault); if (entry.ValueState == PropertyValueState.NullReference) { GUIHelper.PushGUIEnabled(GUI.enabled && entry.IsEditable); try { if (typeof(UnityEngine.Object).IsAssignableFrom(entry.TypeOfValue)) { entry.WeakSmartValue = label == null? EditorGUILayout.ObjectField((UnityEngine.Object) entry.WeakSmartValue, entry.TypeOfValue, entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null) : EditorGUILayout.ObjectField(label, (UnityEngine.Object)entry.WeakSmartValue, entry.TypeOfValue, entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null); } else { if (entry.SerializationBackend == SerializationBackend.Unity && entry.IsEditable && Event.current.type == EventType.Layout) { Debug.LogError("Unity-backed value is null. This should already be fixed by the FixUnityNullDrawer!"); } else { bool drawWithBox = ShouldDrawReferenceObjectPicker(entry); bool contextValue = isToggled.Value; if (drawWithBox) { SirenixEditorGUI.BeginBox(); SirenixEditorGUI.BeginBoxHeader(); { DrawObjectField(entry, label, ref contextValue); } SirenixEditorGUI.EndBoxHeader(); SirenixEditorGUI.EndBox(); } else { DrawObjectField(entry, label, ref contextValue, false); } isToggled.Value = contextValue; } } } finally { GUIHelper.PopGUIEnabled(); } } else { if (ShouldDrawReferenceObjectPicker(entry)) { SirenixEditorGUI.BeginBox(); SirenixEditorGUI.BeginBoxHeader(); { GUIHelper.PushGUIEnabled(GUI.enabled && entry.IsEditable); bool contextValue = isToggled.Value; DrawObjectField(entry, label, ref contextValue); isToggled.Value = contextValue; GUIHelper.PopGUIEnabled(); } SirenixEditorGUI.EndBoxHeader(); if (SirenixEditorGUI.BeginFadeGroup(UniqueDrawerKey.Create(entry, this), isToggled.Value)) { this.CallNextDrawer(entry.Property, null); } SirenixEditorGUI.EndFadeGroup(); SirenixEditorGUI.EndBox(); } else { this.CallNextDrawer(entry.Property, label); } } var objectPicker = ObjectPicker.GetObjectPicker(entry, entry.BaseValueType); if (objectPicker.IsReadyToClaim) { var obj = objectPicker.ClaimObject(); entry.Property.Tree.DelayActionUntilRepaint(() => entry.WeakSmartValue = obj); } }
private void OnGUI() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Entity Object"); dialogEntity = (GameObject)EditorGUILayout.ObjectField(dialogEntity, typeof(GameObject), true); EditorGUILayout.EndHorizontal(); if (dialogEntity == null) { return; } if (dialogTrigger == null) { dialogTrigger = dialogEntity.GetComponent <DialogTrigger>(); } if (dialogTrigger == null) { if (GUILayout.Button("Add Dialog Component")) { dialogTrigger = dialogEntity.AddComponent <DialogTrigger>(); } } else { dialogTrigger.NPCName = EditorGUILayout.TextField("NPC Name", dialogTrigger.NPCName); #region Dialog Object if (dialogTrigger.dialogObject == null) { if (GUILayout.Button("Set Dialog")) { ObjectPicker.GetObject(ObjectPicker.ObjectType.Dialog, SetDialog); } } else { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(dialogTrigger.dialogObject.name); if (GUILayout.Button("X")) { dialogTrigger.dialogObject = null; } EditorGUILayout.EndHorizontal(); } #endregion #region Audio Source EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Audio Source"); dialogTrigger.source = (AudioSource)EditorGUILayout.ObjectField(dialogTrigger.source, typeof(AudioSource), true); if (dialogTrigger.source == null) { if (GUILayout.Button("Find Audio")) { if (dialogTrigger.GetComponent <LipsyncController>()) { dialogTrigger.source = dialogTrigger.GetComponent <LipsyncController>().mouthSource; } else { dialogTrigger.source = dialogTrigger.GetComponent <AudioSource>(); } } } EditorGUILayout.EndHorizontal(); #endregion if (dialogTrigger.animator == null) { dialogTrigger.animator = dialogTrigger.GetComponent <Animator>(); } if (requireVar = EditorGUILayout.Toggle("Require Variable", requireVar)) { EditorGUILayout.BeginHorizontal(); if (!string.IsNullOrEmpty(dialogTrigger.requiredVar)) { EditorGUILayout.LabelField(dialogTrigger.requiredVarName); dialogTrigger.requiredValue = EditorGUILayout.Toggle(dialogTrigger.requiredValue); if (GUILayout.Button("X")) { dialogTrigger.requiredVar = ""; dialogTrigger.requiredVarName = ""; } } else { if (GUILayout.Button("Set Var")) { ObjectPicker.GetObject(ObjectPicker.ObjectType.FullVar, SetRequiredVar); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Head Transfer"); dialogTrigger.targetLookObj = (Transform)EditorGUILayout.ObjectField(dialogTrigger.targetLookObj, typeof(Transform), true); EditorGUILayout.EndHorizontal(); dialogTrigger.RotateToTarget = EditorGUILayout.Toggle("Rotate On Interact", dialogTrigger.RotateToTarget); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Interact Angle"); dialogTrigger.interactAngle = EditorGUILayout.Slider(dialogTrigger.interactAngle, 15.0f, 180.0f); EditorGUILayout.EndHorizontal(); EditorUtility.SetDirty(dialogTrigger); EditorGUILayout.Space(); EditorGUILayout.Space(); if (GUILayout.Button("Close")) { this.Close(); } } }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { var entry = this.ValueEntry; if (Event.current.type == EventType.Layout) { this.shouldDrawReferencePicker = ShouldDrawReferenceObjectPicker(this.ValueEntry); if (this.Property.Children.Count > 0) { this.drawChildren = true; } else if (this.ValueEntry.ValueState != PropertyValueState.None) { this.drawChildren = false; } else { // Weird case: This prevents a foldout from being drawn that expands nothing. // If we're the second last drawer, then the next drawer is most likely // the composite drawer. And since we don't have any children in this // else statement, we don't have anything else to draw. this.drawChildren = this.bakedDrawerArray[this.bakedDrawerArray.Length - 2] != this; } } if (entry.ValueState == PropertyValueState.NullReference) { if (this.drawUnityObject) { this.CallNextDrawer(label); } else { if (entry.SerializationBackend == SerializationBackend.Unity && entry.IsEditable && Event.current.type == EventType.Layout) { Debug.LogError("Unity-backed value is null. This should already be fixed by the FixUnityNullDrawer!"); } else { this.DrawField(label); } } } else { if (this.shouldDrawReferencePicker) { this.DrawField(label); } else { this.CallNextDrawer(label); } } var objectPicker = ObjectPicker.GetObjectPicker(entry, entry.BaseValueType); if (objectPicker.IsReadyToClaim) { var obj = objectPicker.ClaimObject(); entry.Property.Tree.DelayActionUntilRepaint(() => { entry.WeakValues[0] = obj; for (int j = 1; j < entry.ValueCount; j++) { entry.WeakValues[j] = SerializationUtility.CreateCopy(obj); } }); } }