예제 #1
0
    void Setup(Animations.EditAnimation anim)
    {
        base.SetupHeader(false, false, anim.name, SetName);
        editAnimation    = anim;
        this.dieRenderer = DiceRendererManager.Instance.CreateDiceRenderer(anim.defaultPreviewSettings.design, 600);
        if (dieRenderer != null)
        {
            previewImage.texture = dieRenderer.renderTexture;
        }

        rotationSlider.Setup(this.dieRenderer);
        rotationControl.Setup(this.dieRenderer);

        animationSelector.Setup(
            "Lighting Pattern Type",
            () => editAnimation.type,
            (t) => SetAnimationType((Animations.AnimationType)t),
            null);

        // Setup all other parameters
        parameters = UIParameterManager.Instance.CreateControls(anim, parametersRoot);
        parameters.onParameterChanged += OnAnimParameterChanged;

        dieRenderer.SetAuto(true);
        dieRenderer.SetAnimation(anim);
        dieRenderer.Play(true);
    }
예제 #2
0
 void OnDestroy()
 {
     if (DiceRendererManager.Instance != null && this.dieRenderer != null)
     {
         DiceRendererManager.Instance.DestroyDiceRenderer(this.dieRenderer);
         this.dieRenderer = null;
     }
 }
예제 #3
0
 void OnDestroy()
 {
     connectedDice.Clear();
     if (this.dieRenderer != null)
     {
         DiceRendererManager.Instance.DestroyDiceRenderer(this.dieRenderer);
         this.dieRenderer = null;
     }
 }
예제 #4
0
 public void Setup(Dice.EditDie die)
 {
     editDie          = die;
     this.dieRenderer = DiceRendererManager.Instance.CreateDiceRenderer(die.designAndColor);
     if (dieRenderer != null)
     {
         dieRenderImage.texture = dieRenderer.renderTexture;
     }
     dieNameText.text = die.name;
 }
예제 #5
0
    public override void Leave()
    {
        if (DiceRendererManager.Instance != null && this.dieRenderer != null)
        {
            DiceRendererManager.Instance.DestroyDiceRenderer(this.dieRenderer);
            this.dieRenderer = null;
        }

        foreach (var ruleui in rules)
        {
            GameObject.Destroy(ruleui.gameObject);
        }
        rules.Clear();
        gameObject.SetActive(false);
    }
예제 #6
0
    public void Setup(EditBehavior behavior)
    {
        this.editBehavior = behavior;
        this.dieRenderer  = DiceRendererManager.Instance.CreateDiceRenderer(behavior.defaultPreviewSettings.design);
        if (dieRenderer != null)
        {
            behaviorRenderImage.texture = dieRenderer.renderTexture;
        }
        behaviorNameText.text = behavior.name;

        dieRenderer.SetAuto(true);
        dieRenderer.SetAnimations(this.editBehavior.CollectAnimations());
        dieRenderer.Play(true);
        RefreshState();
    }
예제 #7
0
    public void Setup(EditAnimation anim)
    {
        this.editAnimation = anim;
        this.dieRenderer   = DiceRendererManager.Instance.CreateDiceRenderer(anim.defaultPreviewSettings.design);
        if (dieRenderer != null)
        {
            animRenderImage.texture = dieRenderer.renderTexture;
        }
        animNameText.text = anim.name;

        dieRenderer.SetAuto(true);
        dieRenderer.SetAnimation(anim);
        dieRenderer.Play(true);
        Expand(false);
    }
예제 #8
0
    public void Setup(EditBehavior bh)
    {
        this.editBehavior = bh;
        this.dieRenderer  = DiceRendererManager.Instance.CreateDiceRenderer(bh.defaultPreviewSettings.design);
        if (dieRenderer != null)
        {
            behaviorRenderImage.texture = dieRenderer.renderTexture;
        }
        behaviorNameText.text        = bh.name;
        behaviorDescriptionText.text = bh.description;

        dieRenderer.SetAuto(true);
        dieRenderer.SetAnimations(this.editBehavior.CollectAnimations());
        dieRenderer.Play(true);
        Expand(false);
    }
예제 #9
0
    void Setup(EditBehavior behavior)
    {
        editBehavior     = behavior;
        this.dieRenderer = DiceRendererManager.Instance.CreateDiceRenderer(editBehavior.defaultPreviewSettings.design, 300);
        if (dieRenderer != null)
        {
            previewImage.texture = dieRenderer.renderTexture;
        }
        // Generate a title for the page
        descriptionText.text = editBehavior.description;

        RefreshView();

        dieRenderer.SetAuto(true);
        dieRenderer.SetAnimations(this.editBehavior.CollectAnimations());
        dieRenderer.Play(true);
    }
예제 #10
0
    protected override void SetupControls(string name, System.Func <object> getterFunc, System.Action <object> setterAction, IEnumerable <object> attributes = null)
    {
        EditAnimation initialAnim = (EditAnimation)getterFunc();

        // Set name
        nameText.text = name;

        var design = DesignAndColor.V5_Grey;

        if (initialAnim != null)
        {
            design = initialAnim.defaultPreviewSettings.design;
        }
        this.dieRenderer = DiceRendererManager.Instance.CreateDiceRenderer(design, 160);
        if (dieRenderer != null)
        {
            animationRender.texture = dieRenderer.renderTexture;
        }

        selectAnimationButton.onClick.AddListener(() => PixelsApp.Instance.ShowAnimationPicker("Select Animation", (EditAnimation)getterFunc.Invoke(), (res, newAnim) =>
        {
            if (res)
            {
                SetAnimation(newAnim);
                setterAction?.Invoke((EditAnimation)newAnim);
            }
        }));

        // Set animation name field
        if (initialAnim != null)
        {
            dieRenderer.SetAnimation(initialAnim);
            dieRenderer.Play(true);
            animationNameText.text = initialAnim.name;
            dieRenderer.SetAuto(true);
        }
        else
        {
            dieRenderer.SetAuto(false);
        }
    }
예제 #11
0
    void UpdateView()
    {
        if (this.dieRenderer != null)
        {
            DiceRendererManager.Instance.DestroyDiceRenderer(this.dieRenderer);
            this.dieRenderer = null;
        }

        var design = DesignAndColor.Unknown;
        var dName  = "Missing Die";

        if (editAssignment.die != null)
        {
            design = editAssignment.die.designAndColor;
            dName  = editAssignment.die.name;
        }

        var bName = "Missing Profile";

        if (editAssignment.behavior != null)
        {
            bName = editAssignment.behavior.name;
        }

        this.dieRenderer = DiceRendererManager.Instance.CreateDiceRenderer(design);
        if (dieRenderer != null)
        {
            diePreview.texture = dieRenderer.renderTexture;
        }
        dieRenderer.SetAuto(true);
        if (editAssignment.behavior != null)
        {
            dieRenderer.SetAnimations(editAssignment.behavior.CollectAnimations());
            dieRenderer.Play(true);
        }

        dieName.text      = dName;
        behaviorName.text = bName;
    }
예제 #12
0
    public void Setup(EditPattern pattern)
    {
        this.editPattern = pattern;
        this.dieRenderer = DiceRendererManager.Instance.CreateDiceRenderer(Dice.DesignAndColor.V5_Black);
        if (dieRenderer != null)
        {
            animRenderImage.texture = dieRenderer.renderTexture;
        }
        animNameText.text = pattern.name;

        var anim = new EditAnimationKeyframed();

        anim.name     = "temp anim";
        anim.pattern  = pattern;
        anim.duration = pattern.duration;

        textureImage.texture = pattern.ToTexture();

        dieRenderer.SetAuto(true);
        dieRenderer.SetAnimation(anim);
        dieRenderer.Play(true);
    }
예제 #13
0
    void OnDisable()
    {
        if (DiceRendererManager.Instance != null && this.dieRenderer != null)
        {
            DiceRendererManager.Instance.DestroyDiceRenderer(this.dieRenderer);
            this.dieRenderer = null;
        }

        foreach (var parameter in parameters.parameters)
        {
            GameObject.Destroy(parameter.gameObject);
        }
        parameters = null;

        if (previewDie != null)
        {
            previewDie.die.SetStandardMode();
            DiceManager.Instance.DisconnectDie(previewDie, null);
            previewDie          = null;
            previewDieConnected = false;
        }
    }
    public void Setup(EditPattern pattern)
    {
        this.editPattern = pattern;
        this.dieRenderer = DiceRendererManager.Instance.CreateDiceRenderer(Dice.DesignAndColor.V5_Black);
        if (dieRenderer != null)
        {
            animRenderImage.texture = dieRenderer.renderTexture;
        }
        patternNameText.text = pattern.name;

        var anim = new EditAnimationKeyframed();

        anim.name     = "temp anim";
        anim.pattern  = pattern;
        anim.duration = pattern.duration;
        sizeText.text = "Size: " + (pattern.gradients.Sum(g => g.keyframes.Count) * 2).ToString() + " bytes";

        textureImage.texture = pattern.ToTexture();

        dieRenderer.SetAuto(true);
        dieRenderer.SetAnimation(anim);
        dieRenderer.Play(true);
        Expand(false);
    }
예제 #15
0
 public void Setup(SingleDiceRenderer diceRenderer)
 {
     this.diceRenderer = diceRenderer;
 }
예제 #16
0
 // Start is called before the first frame update
 public void Setup(SingleDiceRenderer diceRenderer)
 {
     this.diceRenderer = diceRenderer;
     diceRenderer.die.onRotationStateChange += OnRotationStateChange;
     OnRotationStateChange(diceRenderer.die.rotationState);
 }