예제 #1
0
    private void SaveActor()
    {
        editMain.AddDebugMessage("Saving " + actor.GetDisplayName());
        Texture2D thumbnail = snapshotCamera.SnapshotActor(actor);

        if (sceneActorLibrary.Exists(actor.GetDisplayName()))
        {
            // TODO: Confirm overwrite?
        }
        sceneActorLibrary.Put(actor.GetDisplayName(), actor, thumbnail);
#if UNITY_EDITOR
        // Ctrl + Alt + click also copies the actor to clipboard for easy (and hacky) exporting.
        if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
        {
            GUIUtility.systemCopyBuffer = sceneActorLibrary.ExportToJson(actor, thumbnail);
            editMain.AddDebugMessage("Also saved TO CLIPBOARD as prefab (DEBUG)");
        }
#endif

        Sprite _sprite = Sprite.Create(thumbnail, new Rect(0, 0, thumbnail.width, thumbnail.height), new Vector2(.5f, .5f), 100);
        Instantiate(snapshotPopupPrefab, editMain.GetMainRect()).GetComponent <Popup>().Setup(_sprite, POPUP_DURATION);

        // TODO: put this back
        // creationLibrary.OnSaveActorPrefab(prefab);
    }