예제 #1
0
	void OnGUI()
	{
		if (!inited) Init();
		UniRPGEdGui.UseSkin();

		scroll = UniRPGEdGui.BeginScrollView(scroll);
		{
			if (UniRPGEditorGlobal.CameraEditors.Length > 0)
			{
				foreach (UniRPGCameraEdInfo cam in UniRPGEditorGlobal.CameraEditors)
				{
					if (UniRPGEdGui.ToggleButton(selected == cam, cam.name, UniRPGEdGui.ButtonStyle, UniRPGEdGui.ButtonOnColor, GUILayout.Width(180)))
					{
						selected = cam;
					}
				}
			}
			else
			{
				GUILayout.Label("No Camera plugins found", UniRPGEdGui.WarningLabelStyle);
			}
		}
		UniRPGEdGui.EndScrollView();
		UniRPGEdGui.DrawHorizontalLine(1, UniRPGEdGui.DividerColor, 0, 10);

		EditorGUILayout.BeginHorizontal();
		{
			GUILayout.FlexibleSpace();

			if (selected == null) GUI.enabled = false;
			if (GUILayout.Button("Accept", UniRPGEdGui.ButtonStyle)) accepted = true;
			GUI.enabled = true;

			if (GUILayout.Button("Cancel", UniRPGEdGui.ButtonStyle)) this.Close();
			GUILayout.FlexibleSpace();
		}
		EditorGUILayout.EndHorizontal();
		GUILayout.Space(10);
	}
예제 #2
0
	private static void LoadCameraEditors(Assembly[] asms)
	{
		// find all the classes that inherit from GameCameraEditorBase
		List<System.Type> foundEdTypes = new List<System.Type>();

		float progress = 0f;
		float step = 1f / (float)asms.Length;
		//EditorUtility.DisplayProgressBar("Updating ...", "Updating Camera Editor cache", progress);

		for (int i = 0; i < asms.Length; i++)
		{
			progress += step;
			//EditorUtility.DisplayProgressBar("Updating ...", "Updating Camera Editor cache", progress);
			System.Type[] types = asms[i].GetExportedTypes();
			for (int j = 0; j < types.Length; j++)
			{
				if (types[j].IsClass && typeof(GameCameraEditorBase).IsAssignableFrom(types[j]) && types[j].Name != "GameCameraEditorBase")
				{
					foundEdTypes.Add(types[j]);
				}
			}
		}

		// extract some meta data and create the editor instances
		List<UniRPGCameraEdInfo> eds = new List<UniRPGCameraEdInfo>();

		progress = 0f;
		step = 1f / (float)foundEdTypes.Count;
		//EditorUtility.DisplayProgressBar("Updating ...", "Updating Camera Editor cache", progress);

		for (int i = 0; i < foundEdTypes.Count; i++)
		{
			progress += step;
			//EditorUtility.DisplayProgressBar("Updating ...", "Updating Camera Editor cache", progress);

			bool err = true;
			GameCameraAttribute att = null;
			System.Object[] attribs = foundEdTypes[i].GetCustomAttributes(typeof(GameCameraAttribute), false);
			if (attribs.Length > 0)
			{	// find the ALL occurance of GameCameraAttribute
				for (int j = 0; j < attribs.Length; j++)
				{
					att = (attribs[j] as GameCameraAttribute);
					if (att != null)
					{
						err = false;
						UniRPGCameraEdInfo nfo = new UniRPGCameraEdInfo();
						nfo.name = att.Name;
						nfo.cameraType = att.cameraType;
						nfo.editor = (GameCameraEditorBase)System.Activator.CreateInstance(foundEdTypes[i]);
						eds.Add(nfo);
					}
				}
			}

			if (err)
			{
				Debug.LogError("Invalid Camera Editor [" + foundEdTypes[i].ToString() + "] encountered. Please check the documentation on how to create custom Cameras and Editor.");
			}
		}

		// sort the editors according to priority/ name
		eds.Sort(delegate(UniRPGCameraEdInfo a, UniRPGCameraEdInfo b) { return a.name.CompareTo(b.name); });

		// update the caches
		CameraEditors = eds.ToArray();
		//EditorUtility.ClearProgressBar();
	}