void OnCreateButtonClicked() { if (m_CreateWindow != null) { m_CreateWindow.Close(); } var selection = m_InteractionModule.CurrentSelection; var normalSceneView = SimulationView.NormalSceneView != null ? SimulationView.NormalSceneView : SceneView.lastActiveSceneView; if (selection.Count == 1) { var createProxyData = new CreateProxyFromData(); var proxy = createProxyData.CreateImmediately(selection[0].AttachTarget.GetComponent <Proxy>()); proxy.transform.position = normalSceneView.pivot; OpenCreateProxyWindow(createProxyData); } else if (selection.Count > 1) { var creator = new CreateProxyGroupFromData(); var members = new List <PotentialChild> { GetPotentialChild(selection[0].AttachTarget.gameObject), GetPotentialChild(selection[1].AttachTarget.gameObject) }; var group = creator.CreateNewProxyGroup(members); group.transform.position = normalSceneView.pivot; OpenCreateProxyGroupWindow(creator); } }
internal void BindData(CreateProxyGroupFromData createGroupData) { BindPotentialRelations(createGroupData.PotentialRelations); BindPotentialChildren(createGroupData.PotentialGroupMembers); GetDefaultName += createGroupData.GenerateProxyGroupName; NameChanged += createGroupData.SetProxyGroupName; Create += () => { if (createGroupData.CreatedGameObject != null) { Undo.RegisterCreatedObjectUndo(createGroupData.CreatedGameObject, "Create Proxy Group"); EditorGUIUtility.PingObject(createGroupData.CreatedGameObject); } }; m_CountField.value = createGroupData.MaxCount; Cancel += createGroupData.CancelCreate; RefreshName(); }
void OpenCreateProxyGroupWindow(CreateProxyGroupFromData createGroupData) { var createProxyGroupUI = new CreateProxyGroupFromDataUI(); createProxyGroupUI.BindData(createGroupData); createProxyGroupUI.OnChildModified += createData => { createData.EditCreatedProxy(); OpenCreateProxyWindow(createData, false); }; createProxyGroupUI.CountChanged += x => createGroupData.MaxCount = x; var clickPosition = EditorWindow.focusedWindow.position.position + Event.current.mousePosition; m_CreateWindow = EditorWindow.GetWindow <CreateFromDataWindow>(true); m_CreateWindow.AddNewPage(createProxyGroupUI); m_CreateWindow.Open(clickPosition); createProxyGroupUI.StartEditingNameField(); }