Ejemplo n.º 1
0
    void SetCreatePreviewSettingsJson(string createPreviewSettingsJson)
    {
        if (lastCreatePreviewSettingsJson == createPreviewSettingsJson)
        {
            return;
        }

        lastCreatePreviewSettingsJson = createPreviewSettingsJson;
        if (createPreviewSettingsJson.IsNullOrEmpty())
        {
            if (createPreviewInst != null)
            {
                GameObject.Destroy(createPreviewInst.gameObject);
                createPreviewInst = null;
            }
        }
        else
        {
            // Settings changed, create new preview
            var settings = JsonUtility.FromJson <CreatePreviewSettings>(createPreviewSettingsJson);

            if (createPreviewInst != null)
            {
                GameObject.Destroy(createPreviewInst.gameObject);
            }

            createPreviewInst = Instantiate(createPreviewPrefab);
            createPreviewInst.SetRenderableByReference(
                settings.renderable,
                settings.addlRotation,
                settings.renderableOffset,
                settings.renderableRotation,
                _ => settings.scale,
                () => true);

            createPreviewInst.SetTint(currentTint);
        }
    }