void OnEnable()
		{
			if( !z_Pref.VersionCheck() )
				z_Pref.ClearPrefs();

			z_Editor._instance = this;

			this.wantsMouseMove = true;

			if( z_ReflectionUtil.ProBuilderExists() )
			{
				pbEditLevelChangedDelegate = new System.Action<int>( OnProBuilderEditLevelChanged );

				z_ReflectionUtil.enableWarnings = false;

				z_ReflectionUtil.Invoke(null,
										z_ReflectionUtil.ProBuilderEditorType,
										"AddOnEditLevelChangedListener",
										new Type[] { typeof(System.Action<int>) },
										BindingFlags.Public | BindingFlags.Static,
										pbEditLevelChangedDelegate);

				z_ReflectionUtil.enableWarnings = true;
			}

			this.titleContent = new GUIContent("Polybrush", z_IconUtility.GetIcon("Icon/window_icon"));

			if(modeIcons == null)
			{
				modeIcons = new GUIContent[]
				{
					new GUIContent(z_IconUtility.GetIcon("Icon/Sculpt"), "Push and pull vertex positions"),
					new GUIContent(z_IconUtility.GetIcon("Icon/Smooth"), "Smooth vertex positions"),
					new GUIContent(z_IconUtility.GetIcon("Icon/Palette"), "Paint vertex colors"),
					new GUIContent(z_IconUtility.GetIcon("Icon/FlowerAndGrass"), "Paint Prefabs"),
					new GUIContent(z_IconUtility.GetIcon("Icon/Bricks"), "Paint textures on meshes"),
					new GUIContent(z_IconUtility.GetIcon("Icon/Gear"), "Polybrush general settings")
				};
			}

			if(mirrorGuiContent == null)
			{
				 mirrorGuiContent = new GUIContent[]
				{
					new GUIContent("None", "No Mirroring"),
					new GUIContent("X", "Mirror across the X axis, with Y up"),
					new GUIContent("Y", "Mirror the brush up/down."),
					new GUIContent("Z", "Mirror across the Z axis, with Y up")
				};
			}

			if(mirrorSpaceGuiContent == null)
			{
				mirrorSpaceGuiContent = new GUIContent[]
				{
					new GUIContent("World", "Mirror rays in world space"),
					new GUIContent("Camera", "Mirror rays in camera space")
				};
			}

			if(gc_SaveBrushSettings == null)
				gc_SaveBrushSettings = new GUIContent("Save",
					"Save the brush settings as a preset");

			SceneView.onSceneGUIDelegate -= OnSceneGUI;
			SceneView.onSceneGUIDelegate += OnSceneGUI;

			Undo.undoRedoPerformed -= UndoRedoPerformed;
			Undo.undoRedoPerformed += UndoRedoPerformed;

			// force update the preview
			lastHoveredGameObject = null;

			if(brushSettings == null)
				SetBrushSettings(z_EditorUtility.GetDefaultAsset<z_BrushSettings>("Brush Settings/Default.asset"));

			lockBrushToFirst = z_Pref.GetBool(z_Pref.lockBrushToFirst);
			ignoreUnselected = z_Pref.GetBool(z_Pref.ignoreUnselected);

			RefreshAvailableBrushes();

			SetTool(tool == z_BrushTool.None ? z_BrushTool.RaiseLower : tool);
		}
Пример #2
0
		void OnEnable()
		{
			z_Editor._instance = this;

			this.titleContent = new GUIContent("Polybrush", (Texture2D)Resources.Load(ICON_PATH, typeof(Texture2D)));

			if(modeIcons == null)
			{
				modeIcons = new GUIContent[]
				{
					EditorGUIUtility.IconContent("TerrainInspector.TerrainToolRaise", "|Raise and lower the terrain height."),
					EditorGUIUtility.IconContent("TerrainInspector.TerrainToolSmoothHeight", "|Smooth the terrain height."),
					EditorGUIUtility.IconContent("TerrainInspector.TerrainToolSplat", "|Paint the terrain texture."),
#if PREFAB_MODE_ENABLED
					EditorGUIUtility.IconContent("TerrainInspector.TerrainToolPlants", "|Place plants, stones and other small foilage"),
#endif
					EditorGUIUtility.IconContent("TerrainInspector.TerrainToolPlants", "|Place plants, stones and other small foilage"),
					EditorGUIUtility.IconContent("TerrainInspector.TerrainToolSettings", "|Settings for the terrain")
				};
			}

			if(mirrorGuiContent == null)
			{
				 mirrorGuiContent = new GUIContent[]
				{
					new GUIContent("None", "No Mirroring"),
					new GUIContent(" X ", "Mirror across the X axis, with Y up"),
					new GUIContent(" Y ", "Mirror the brush up/down."),
					new GUIContent(" Z ", "Mirror across the Z axis, with Y up")
				};
			}

			SceneView.onSceneGUIDelegate -= OnSceneGUI;
			SceneView.onSceneGUIDelegate += OnSceneGUI;

			Undo.undoRedoPerformed -= UndoRedoPerformed;
			Undo.undoRedoPerformed += UndoRedoPerformed;

			// force update the preview
			lastHoveredGameObject = null;

			if(brushSettings == null)
				brushSettings = z_EditorUtility.GetDefaultAsset<z_BrushSettings>("Brush Settings/Default.asset");

			RefreshAvailableBrushes();

			SetTool(tool == z_BrushTool.None ? z_BrushTool.RaiseLower : tool);
		}