1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5#include "BsCorePrerequisites.h"
6#include "Scene/BsGameObject.h"
7
8namespace bs
9{
10 /** @addtogroup Scene
11 * @{
12 */
13
14 /** Performs various prefab specific operations. */
15 class BS_CORE_EXPORT PrefabUtility
16 {
17 public:
18 /**
19 * Remove any instance specific changes to the object or its hierarchy from the provided prefab instance and
20 * restore it to the exact copy of the linked prefab.
21 *
22 * @param[in] so Object to revert.
23 */
24 static void revertToPrefab(const HSceneObject& so);
25
26 /**
27 * Updates all of the objects belonging to the same prefab instance as the provided object (if any). The update
28 * will apply any changes from the linked prefab to the hierarchy (if any).
29 *
30 * @param[in] so Object to update.
31 */
32 static void updateFromPrefab(const HSceneObject& so);
33
34 /**
35 * Generates prefab "link" ID that can be used for tracking which game object in a prefab instance corresponds to
36 * an object in the prefab.
37 *
38 * @note If any children of the provided object belong to another prefab they will not have IDs generated.
39 */
40 static void generatePrefabIds(const HSceneObject& sceneObject);
41
42 /**
43 * Clears all prefab "link" IDs in the provided object and its children.
44 *
45 * @param[in] sceneObject Prefab instance to clear the link IDs from.
46 * @param[in] recursive If true, all children of the provided scene object will be cleared as well.
47 * @param[in] clearRoot If true, the root provided object will have its link ID cleared. If false the root
48 * object's components will have their IDs cleared but not the scene object itself.
49 * (Child scene objects will have their link IDs cleared in case @p recursive is true.)
50 *
51 * @note If any of its children belong to another prefab they will not be cleared.
52 */
53 static void clearPrefabIds(const HSceneObject& sceneObject, bool recursive = true, bool clearRoot = true);
54
55 /**
56 * Updates the internal prefab diff data by recording the difference between the current values in the provided
57 * prefab instance and its prefab.
58 *
59 * @note
60 * If the provided object contains any child prefab instances, this will be done recursively for them as well.
61 */
62 static void recordPrefabDiff(const HSceneObject& sceneObject);
63 };
64
65 /** @} */
66}