示例#1
0
        // SciptableObject.OnDisable
        protected void OnDisable()
        {
            // Clean up scene references not longer in use
            var sceneRefs = AssetDatabase.LoadAllAssetsAtPath(DATA_PATH)
                            .OfType <ShelfSceneReference>()
                            .ToList();

            for (int i = sceneRefs.Count - 1; i >= 0; i--)
            {
                foreach (var layer in Data.layers)
                {
                    foreach (var item in layer.objects)
                    {
                        if (item == sceneRefs[i])
                        {
                            goto ContinueWithNextRef;
                        }
                    }
                }

                // Screne reference not found on any shelf
                DestroyImmediate(sceneRefs[i], true);

ContinueWithNextRef:
                continue;
            }

            editorInstance = null;
            EditorUtility.SetDirty(Data);

            Undo.undoRedoPerformed -= OnUndoRedo;
        }
示例#2
0
        // SciptableObject.OnEnable
        protected void OnEnable()
        {
            editorInstance = this;

            // Setup reorderable list
            if (reorderable.objectReferencesCallback != ObjectReferences)
            {
                reorderable.emptyListItemHeight      = SHELF_ITEM_HEIGHT;
                reorderable.undoTarget               = Data;
                reorderable.objectReferencesCallback = ObjectReferences;
                reorderable.listItemNameCallback     = ListItemName;
                reorderable.listItemContentCallback  = ListItemContent;
                reorderable.listItemDrawCallback     = DrawListItem;
                reorderable.listItemClickEvent      += ListItemClick;
            }

            Undo.undoRedoPerformed += OnUndoRedo;
        }