public void Init(DialogReceiverInterface e, SceneDataControl scene, int areaIndex) { sceneRef = scene; calledAreaIndexRef = areaIndex; string backgroundPath = Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[ GameRources.GetInstance().selectedSceneIndex].getPreviewBackground(); backgroundPreviewTex = AssetsController.getImage(backgroundPath).texture; activeAreaTex = (Texture2D)Resources.Load("Editor/ActiveArea", typeof(Texture2D)); exitTex = (Texture2D)Resources.Load("Editor/ExitArea", typeof(Texture2D)); selectedAreaTex = (Texture2D)Resources.Load("Editor/SelectedArea", typeof(Texture2D)); float bgwidth = backgroundPreviewTex.width * (600f / backgroundPreviewTex.height); imageBackgroundRect = new Rect(0f, 0f, bgwidth, 600); x = sceneRef.getActiveAreasList().getActiveAreasList()[areaIndex].getX(); y = sceneRef.getActiveAreasList().getActiveAreasList()[areaIndex].getY(); width = sceneRef.getActiveAreasList().getActiveAreasList()[areaIndex].getWidth(); heigth = sceneRef.getActiveAreasList().getActiveAreasList()[areaIndex].getHeight(); base.Init(e, bgwidth, 600); }
public override void OnSceneSelected(SceneDataControl scene) { base.OnSceneSelected(scene); if (scene == null) { return; } activeAreasList.SetData(scene.getActiveAreasList(), (dc) => (dc as ActiveAreasListDataControl).getActiveAreas().Cast <DataControl>().ToList()); }
public List <ActiveAreaDataControl> getParentSceneActiveAreaList() { return(sceneDataControl.getActiveAreasList().getActiveAreas()); }
void OnGUI() { // Dragging events if (Event.current.type == EventType.mouseDrag) { if (currentRect.Contains(Event.current.mousePosition)) { if (!dragging) { dragging = true; startPos = currentPos; } } currentPos = Event.current.mousePosition; } if (Event.current.type == EventType.mouseUp) { dragging = false; } scrollPosition = GUILayout.BeginScrollView(scrollPosition); GUI.DrawTexture(imageBackgroundRect, backgroundPreviewTex); for (int i = 0; i < sceneRef.getActiveAreasList().getActiveAreasList().Count; i++) { Rect aRect = new Rect(sceneRef.getActiveAreasList().getActiveAreasList()[i].getX(), sceneRef.getActiveAreasList().getActiveAreasList()[i].getY(), sceneRef.getActiveAreasList().getActiveAreasList()[i].getWidth(), sceneRef.getActiveAreasList().getActiveAreasList()[i].getHeight()); GUI.DrawTexture(aRect, activeAreaTex); } for (int i = 0; i < sceneRef.getExitsList().getExitsList().Count; i++) { Rect eRect = new Rect(sceneRef.getExitsList().getExitsList()[i].getX(), sceneRef.getExitsList().getExitsList()[i].getY(), sceneRef.getExitsList().getExitsList()[i].getWidth(), sceneRef.getExitsList().getExitsList()[i].getHeight()); GUI.DrawTexture(eRect, exitTex); // Frame around current area if (calledExitIndexRef == i) { currentRect = eRect; GUI.DrawTexture(eRect, selectedExitTex); } } /* * HANDLE EVENTS */ if (dragging) { OnBeingDragged(); } GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); GUILayout.Box("X", GUILayout.Width(0.25f * backgroundPreviewTex.width)); GUILayout.Box("Y", GUILayout.Width(0.25f * backgroundPreviewTex.width)); GUILayout.Box(TC.get("SPEP.Width"), GUILayout.Width(0.25f * backgroundPreviewTex.width)); GUILayout.Box(TC.get("SPEP.Height"), GUILayout.Width(0.25f * backgroundPreviewTex.width)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); x = EditorGUILayout.IntField(sceneRef.getExitsList().getExitsList()[calledExitIndexRef].getX(), GUILayout.Width(0.25f * backgroundPreviewTex.width)); y = EditorGUILayout.IntField(sceneRef.getExitsList().getExitsList()[calledExitIndexRef].getY(), GUILayout.Width(0.25f * backgroundPreviewTex.width)); width = EditorGUILayout.IntField(sceneRef.getExitsList().getExitsList()[calledExitIndexRef].getWidth(), GUILayout.Width(0.25f * backgroundPreviewTex.width)); heigth = EditorGUILayout.IntField(sceneRef.getExitsList().getExitsList()[calledExitIndexRef].getHeight(), GUILayout.Width(0.25f * backgroundPreviewTex.width)); HALF_WIDTH = (int)(0.5f * sceneRef.getExitsList().getExitsList()[calledExitIndexRef].getWidth()); HALF_HEIGHT = (int)(0.5f * sceneRef.getExitsList().getExitsList()[calledExitIndexRef].getHeight()); sceneRef.getExitsList().getExitsList()[calledExitIndexRef].setValues(x, y, width, heigth); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Ok")) { reference.OnDialogOk("Applied"); this.Close(); } //if (GUILayout.Button(TC.get("GeneralText.Cancel"))) //{ // reference.OnDialogCanceled(); // this.Close(); //} GUILayout.EndHorizontal(); }