示例#1
0
	public override void OnGUI(DatabaseEditor ed, GameCameraBase gameCam)
	{
		DefaultCam1 cam = gameCam as DefaultCam1;

		EditorGUILayout.BeginVertical(UniRPGEdGui.BoxStyle, GUILayout.Width(400));
		{
			UniRPGEdGui.LookLikeControls(160);
			cam.autoRotateToPlayer = EditorGUILayout.Toggle("Auto-rotate to player", cam.autoRotateToPlayer);
			cam.allowRotation = EditorGUILayout.Toggle("Allow rotation", cam.allowRotation);
			cam.allowZooming = EditorGUILayout.Toggle("Allow zooming", cam.allowZooming);
			EditorGUILayout.Space();

			cam.backDistance = EditorGUILayout.FloatField("Back Distance", cam.backDistance);
			cam.angle = EditorGUILayout.FloatField("Start Angle", cam.angle);
			EditorGUILayout.Space();

			cam.targetCenterOffset = EditorGUILayout.Vector3Field("Player Center Offset", cam.targetCenterOffset);
			EditorGUILayout.Space();

			cam.zoomSpeed = EditorGUILayout.FloatField("Zoom Speed", cam.zoomSpeed);
			cam.distance = EditorGUILayout.FloatField("Start Distance", cam.distance);
			cam.minZoomDistance = EditorGUILayout.FloatField("Min Zoom Distance", cam.minZoomDistance);
			cam.maxZoomDistance = EditorGUILayout.FloatField("Max Zoom Distance", cam.maxZoomDistance);
			EditorGUILayout.Space();

			cam.rotationStepping = EditorGUILayout.FloatField("Rotation Stepping", cam.rotationStepping);
			cam.rotationSpeed = EditorGUILayout.FloatField("Rotation Speed", cam.rotationSpeed);
			cam.autoRotationSpeed = EditorGUILayout.FloatField("Auto-rotation Speed", cam.autoRotationSpeed);

		}
		EditorGUILayout.EndVertical();
	}
示例#2
0
	// ================================================================================================================

	public override void CopyTo(GameCameraBase targetCam)
	{
		base.CopyTo(targetCam);

		DefaultCam1 cam = targetCam as DefaultCam1;

		cam.autoRotateToPlayer = this.autoRotateToPlayer;
		cam.allowRotation = this.allowRotation;
		cam.allowZooming = this.allowZooming;

		cam.distance = this.distance;
		cam.backDistance = this.backDistance;
		cam.angle = this.angle;
		cam.targetCenterOffset = this.targetCenterOffset;

		cam.zoomSpeed = this.zoomSpeed;
		cam.minZoomDistance = this.minZoomDistance;
		cam.maxZoomDistance = this.maxZoomDistance;

		cam.rotationStepping = this.rotationStepping;
		cam.rotationSpeed = this.rotationSpeed;
		cam.autoRotationSpeed = this.autoRotationSpeed;
	}
示例#3
0
	public virtual void CopyTo(GameCameraBase targetCam)
	{
		targetCam.id = this.id.Copy();
		targetCam.cameraPrefab = this.cameraPrefab;
	}
示例#4
0
	public void SetActiveCamera(GameCameraBase cam)
	{
		if (_activeCam != null)
		{
			_activeCam.gameObject.SetActive(false);
			_activeCam.DeactivatedByUniRPG();
		}
		_activeCam = null;
		if (cam == null) return;

		_activeCam = cam;
		_activeCam.gameObject.SetActive(true);
		_activeCam.ActivatedByUniRPG();

		AudioListener.volume = UniRPGGlobal.DB.audioMainVolume;
	}
示例#5
0
	public bool SetActiveCamera(GUID id)
	{
		if (id == null) return false;

		for (int i = 0; i < gameCameras.Count; i++)
		{
			if (gameCameras[i].id == id)
			{
				// deactivate prev cam
				if (_activeCam != null)
				{
					_activeCam.gameObject.SetActive(false);
					_activeCam.DeactivatedByUniRPG();
				}
				_activeCam = null;

				// activate selected cam
				SetActiveCamera(gameCameras[i]);
				return true;
			}
		}

		return false;
	}
示例#6
0
	public void ClearActiveCamera()
	{
		if (_activeCam != null)
		{
			_activeCam.gameObject.SetActive(false);
			_activeCam.DeactivatedByUniRPG();
		}
		_activeCam = null;
	}
示例#7
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;
		}
	}
示例#8
0
	private void OnCameraSelected(System.Object sender)
	{
		CameraSelectWiz wiz = sender as CameraSelectWiz;
		if (wiz.selected != null)
		{
			curr = CameraEditor.CreateCamera(wiz.selected.name, wiz.selected.cameraType);
			ed.db.cameraPrefabs.Add(curr.gameObject);
			EditorUtility.SetDirty(ed.db);
			AssetDatabase.SaveAssets();
			GetCurrentEd();
		}
		wiz.Close();
	}
	public virtual void OnGUI(DatabaseEditor ed, GameCameraBase gameCam) { }