示例#1
0
        protected override void Load()
        {
            pinning = new List <PinnedItem>();

            var prefsKey = GetPinnedPrefsKey();

            var saveData = ProjectPrefs.Get <List <SaveData> >(prefsKey, null);

            if (saveData == null)
            {
                return;
            }

            if (saveData.Any())
            {
                // Hierarchy上のGameObjectを検索して取得.
                var hierarchyObjects = UnityEditorUtility.FindAllObjectsInHierarchy();

                foreach (var data in saveData)
                {
                    if (data.localIdentifierInFile == -1)
                    {
                        continue;
                    }

                    var targetObject = hierarchyObjects.FirstOrDefault(y => UnityEditorUtility.GetLocalIdentifierInFile(y) == data.localIdentifierInFile) as Object;

                    if (targetObject == null)
                    {
                        continue;
                    }

                    var item = new PinnedItem()
                    {
                        target  = targetObject,
                        comment = data.comment,
                    };

                    pinning.Add(item);
                }
            }
        }
示例#2
0
        protected override void Load()
        {
            pinning = new List <PinnedItem>();

            var saveData = ProjectPrefs.Get <List <SaveData> >(PinnedPrefsKey, null);

            if (saveData == null)
            {
                return;
            }

            foreach (var data in saveData)
            {
                if (string.IsNullOrEmpty(data.guid))
                {
                    continue;
                }

                var assetPath = AssetDatabase.GUIDToAssetPath(data.guid);

                if (string.IsNullOrEmpty(assetPath))
                {
                    continue;
                }

                var asset = AssetDatabase.LoadAssetAtPath <Object>(assetPath);

                if (asset == null)
                {
                    continue;
                }

                var item = new PinnedItem()
                {
                    target  = asset,
                    comment = data.comment,
                };

                pinning.Add(item);
            }
        }