Ejemplo n.º 1
0
	private void LeftPanel()
	{
		EditorGUILayout.BeginVertical(GUILayout.Width(DatabaseEditor.LeftPanelWidth));
		GUILayout.Space(5);
		// -------------------------------------------------------------

		// the add button
		EditorGUILayout.Space();
		EditorGUILayout.BeginHorizontal();
		{
			GUILayout.FlexibleSpace();
			if (GUILayout.Button(new GUIContent("Add Camera", UniRPGEdGui.Icon_Plus), EditorStyles.miniButtonLeft))
			{
				GUI.FocusControl("");
				CameraSelectWiz.Show(OnCameraSelected);
			}
			if (curr == null) GUI.enabled = false;
			if (GUILayout.Button(new GUIContent(UniRPGEdGui.Icon_Copy, "Copy"), EditorStyles.miniButtonMid))
			{
				GUI.FocusControl("");
				GameCameraBase cam = CameraEditor.CreateCamera(curr.name, curr.GetType());
				curr.CopyTo(cam);
				cam.id = UniRPG.GUID.Create();
				curr = cam;
				ed.db.cameraPrefabs.Add(curr.gameObject);
				GetCurrentEd();
			}
			GUI.enabled = true;
		}
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.Space();

		scroll[0] = UniRPGEdGui.BeginScrollView(scroll[0], GUILayout.Width(DatabaseEditor.LeftPanelWidth));
		{
			if (ed.db.Cameras.Length > 0)
			{
				foreach (GameCameraBase cam in ed.db.Cameras)
				{
					if (cam == null)
					{	// detected a null value, 1st cleanup the list
						ed.db.cameraPrefabs = UniRPGUtil.CleanupList<GameObject>(ed.db.cameraPrefabs);
						EditorUtility.SetDirty(ed.db);
						AssetDatabase.SaveAssets();
						GUIUtility.ExitGUI();
						return;
					}

					EditorGUILayout.BeginHorizontal(GUILayout.Width(DatabaseEditor.LeftPanelWidth - 20), GUILayout.ExpandWidth(false));
					{
						if (UniRPGEdGui.ToggleButton(curr == cam, cam.name, UniRPGEdGui.ButtonLeftStyle, GUILayout.Width(160), GUILayout.ExpandWidth(false)))
						{
							GUI.FocusControl("");
							curr = cam;
							GetCurrentEd();
						}

						//if (ed.db.Cameras.Length == 1) GUI.enabled = false; // can't allow deleting the camera if there is only one left since runtime depends on at least one being present
						if (GUILayout.Button("X", UniRPGEdGui.ButtonRightStyle, GUILayout.Width(20))) del = cam;
						//GUI.enabled = true;
					}
					EditorGUILayout.EndHorizontal();
				}
			}
			else
			{
				GUILayout.Label("No Cameras are defined.\nThis is acceptable but then\nyou need to add your own\nMain Camera to the game\nscene(s).", UniRPGEdGui.WarningLabelStyle);
			}
		}
		UniRPGEdGui.EndScrollView(); // 0

		// -------------------------------------------------------------
		GUILayout.Space(3);
		EditorGUILayout.EndVertical();

		if (del != null)
		{
			if (curr == del) { curr = null; currEd = null; }
			ed.db.cameraPrefabs.Remove(del.gameObject);
			EditorUtility.SetDirty(ed.db);
			AssetDatabase.SaveAssets();

			string path = AssetDatabase.GetAssetPath(del.gameObject);
			AssetDatabase.DeleteAsset(path);
			AssetDatabase.Refresh();
			del = null;
		}
	}
Ejemplo n.º 2
0
	private void GetCurrentEd()
	{
		currEd = null;
		foreach (UniRPGCameraEdInfo camNfo in UniRPGEditorGlobal.CameraEditors)
		{
			if (camNfo.cameraType.IsAssignableFrom(curr.GetType()))
			{
				currEd = camNfo.editor;
			}
		}
	}