unit: how do I make an image appear depending on the current state I am in?

I am following a tutorial called Complete C # Unity Developer 2D: Learn to code creation games. In one section we create a text-based game, where we show a canvas with some elements of the user interface. The text changes according to the current state, which is configured through a couple of scripts. Only for future knowledge (not part of the tutorial), I want to make an image visualization for each state.

Before publishing the scripts, this is what I tried: 1) serialize a Sprite field in one of the scripts to be able to assign an active sprite .jpg. At that time I wasn't sure how to make it appear based on the state, which is a series of states. 2) I created an image of UI and added it to the canvas, then disabled it. My intention here was to enable it when state.name == x. Unfortunately, I can't make that work either.

I am using two scripts, 1) AdventureGame.cs and 2) State.cs:

1) AdventureGame.cs

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class AdventureGame : MonoBehaviour
    Text m_textComponent;
    State startingState;
    // I added this Sprite field
    Sprite m_spriteComponent;

    State state;

    void Start()
        state = startingState;
        m_textComponent.text = state.GetStateStory();
        // This is what I added, a call to a method in the other script
        m_spriteComponent = state.GetStateSprite();
        // The sprite is called HellDoor

    void Update()

    private void ManageState()
        var nextStates = state.GetNextStates();
        for (int index = 0; index < nextStates.Length; index++)
            if (Input.GetKeyDown(KeyCode.Alpha1 + index))
                state = nextStates(index);
            m_textComponent.text = state.GetStateStory();

        // Tested for state name to be sure, Door is one of them

        if (state.name == "Door")
            // Not sure what to put here



2) State.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

// Creates a new slot called State in the Create menu!
(CreateAssetMenu(menuName = "State"))
public class State : ScriptableObject
    // First number determines minimum size of the field, and the second number
    // determines the amount of lines before you start to scroll
    (TextArea(10, 14))
    string m_storyText;
    State() nextStates;
    // This is the field I added
    Sprite m_stateSprite;

    public string GetStateStory()
        return m_storyText;

    public State() GetNextStates()
        return nextStates;
    // This is the method I added
    public Sprite GetStateSprite()
        return m_stateSprite;

Also, this is what I configured in the editor.

Publisher Design


sql server: function to obtain the current or default value of a two-value string

I have SQL scripts that I want to be directly executable in the editor and also in automated integration tests. However, in each use case they require different environment and version parameters. I can not use string_split because we use an old SQL Server 2012.

To differentiate between them, I created the GetCurrentOrDefault function that can use the first or second value.

I start by finding the index of the | What do I use as a separator? Then I get the string before and after this character. Finally, I check if the string has the format '{%}|%' and if so, then I use the default version, otherwise the current version. (All magic numbers are arbitrary cousins).

if object_id('dbo.GetCurrentOrDefault') is not null drop function GetCurrentOrDefault


create function GetCurrentOrDefault(@valueOrDefault nvarchar(59)) returns nvarchar(17)
    declare @current_value as nvarchar(17);
    declare @default_value as nvarchar(17);
    declare @value_separator_index as int

    select @value_separator_index = charindex('|', @valueOrDefault)

    if @value_separator_index = 0 return null

    select @current_value = substring(@valueOrDefault, 0, @value_separator_index)
    select @default_value = substring(@valueOrDefault, @value_separator_index + 1, len(@valueOrDefault) - @value_separator_index + 1)
    return iif(@valueOrDefault like '{%}|%', @default_value, @current_value)


Example of use:

declare @env as nvarchar(51) = N'{Environment}|production'
declare @ver as nvarchar(59) = N'{Version}|3.9.0'

select @env = dbo.GetCurrentOrDefault(@env)
select @ver = dbo.GetCurrentOrDefault(@ver)

if @env is null raiserror ('Invalid environment: ' + @env, 16, 1)
if @ver is null raiserror ('Invalid version: ' + @ver, 16, 1)

Tests replace placeholders with their custom values ​​such as:

.GetSql().Format(new { Environment = "test", Version = "4.0.0" })

What you think? Is there a smarter solution?

Current number of proxies / threads to use to prevent the suspension of the proxy?

Proxies … 2 part publication
1- It has been a good time since I did any important scraping … can anyone save me the test time and temporary prohibition proxies, and know what the current thread is by proxy and the delay I need to use in scrapebox to get? Maximum scraping done without my proxies being banned?
2- If you have good recommendations for private / exclusive representatives, I am all ears
Thank you all

mojave – Application selector – Only change the open windows on the current desktop

Can I customize the behavior of the application selector to show only windows from the current desktop?

If I only have one Chrome window open, which is on desktop 1, and I am using desktop 3, then the Chrome window should not even appear on my application switch.

Current Behavior: Chrome appears on my application switch and if I select Chrome on the switch, I suddenly move to desktop 1 from desktop 3 (in the context of the previous example).

Permissions: If the library is not visible to you, why do you see the automatic link in the current navigation?

I used to remember that if you stop inheriting the permissions from the top and show the automatic link in the current navigation of a library, users who have been deleted should NOT see the library link. Now you can see the library link, but when you click on it, you see the empty library. I expected access to the denied page, but no, only the library without content (however, you can see all the metadata columns).

Am I remembering wrong or has something changed? The only way to "hide" the URL is to use audience targeting in Settings – Navigation?

I am using a classic site.

wp query – Shows the current position of the publication in the Elementor Publications widget

I am using Elementor 2.6.8 + Elementor Pro 2.6.2

I am designing a file template to display a list of types of custom posts filtered by custom taxonomy terms.
I am using Elementor Pro's Posts Widget to do this without a line of code.

Also, thanks to the Ele Custom Skin complement (1.2.0), I can design each publication skin in a personalized way (hopefully Elementor Pro will provide it in the future) /

Now, I want to show, in each post, the current position of the post in the list (= in the WP loop).

I tried this code snippet that I added to each post with the short code widget.

add_shortcode( 'current_post_count', function () {
    global $wp_query;
    $out = $wp_query->current_post;
    return $out;
} );

But this always returns -1.

I guess the reason is that, in the context of the publications widget, the global $ wp_query is not the only one to get the information. I guess the widget uses another variable.
But I don't know how to achieve this. Maybe if I could use the actual $ query variable in use? Or maybe you use the query ID parameter offered by the posts widget?

I don't know how to make this work.

Anything that points me in the right direction guys?
Thank you!

javascript: migrate the Current React JS project to run it in Sharepoint

Our team has created a React SPA that is based on js instead of ts. From what I've seen, creating and using a web part requires typing. This project is quite large, so I guess I wonder what would be our best option to take this SPA to Sharepoint. Is converting the project to typing the best option? Are there other options to implement a SPA in Sharepoint without creating a web part?

The other thing with this is that we would like to have a test site where this runs alone, outside of Sharepoint. Would we essentially need 2 different code bases to do that?

Sharepoint online: ssign current user permission to a list item programmatically

I am creating an event web part that is connected to a list of elements. When a user attends an event, a json object will be analyzed in a txt document that is attached to that particular item / event in the list. With user details. However, when a user does not have permission to edit, this will not work. In this case, I want to grant the user editing permissions. I am using online sharepoint.

I was thinking of using REST API to change user permissions for that particular list item, but from what I could gather, it seems that it only works for group permissions, etc. and not for the current user. Have I missed something or do I need to use another type of method?

magento2 – Getting the custom attribute of the current product in aroundExecute of Cart Add function – Magento 2

I need to access a custom attribute of the current product in VendorModuleNamePluginCheckoutControllerCart. I tried to get this from the request parameter, checkoutSession, registration (although it is deprecated) but I failed.

it's possible? I'll show you my code below,

 objectManager = $objectManager;
    $this->resultRedirectFactory = $resultRedirectFactory;
    $this->url = $url;
    $this->request = $request;
    $this->_checkoutSession = $_checkoutSession;

 * Around cart execute
 * @param MagentoCheckoutControllerCartAdd $subject
 * @param Closure                              $proceed
 * @throws MagentoFrameworkExceptionLocalizedException
 * @throws MagentoFrameworkExceptionNoSuchEntityException
public function aroundExecute(
    MagentoCheckoutControllerCartAdd $subject,
    Closure $proceed
) {
    $cartData = $this->_checkoutSession->getQuote()->getAllVisibleItems();
    $cartDataCount = count($cartData);
    $objectManager = MagentoFrameworkAppObjectManager::getInstance();
    $product = $objectManager->get('MagentoFrameworkRegistry')->registry('current_product');//get current product
    $logger = MagentoFrameworkAppObjectManager::getInstance()->get(PsrLogLoggerInterface::class);

    $contactUrl = $this->url->getUrl(
    $result = ();
    $result('backUrl') = $contactUrl;



For your information, I am aware that the use of ObjectManager is not advised. This was done for testing purposes only.

Android development: how to get DecorView from another activity of the current one?

I have two activities The activity below can be seen through.
I use a blurry library that takes views above and below. Blurred view of 500px, to be precise.

I want to get the first activity as a view along with the second and go to the blurred view.

How can I do it?