Issue with button instantiation and variables in Unity3D

Im currently trying to make a system where an inventory of buttons are created and upon runtime the buttons are placed into a GUI component(Panel). I used a list of buttons which gets created on start and creates X amount of buttons for X amount of spells found for said player, and for some reason the button created isn’t acknowledging any changes made to it:

    public void createButton(int index)     {         var panel = GameObject.Find("ButtonPanel");         Spell spell = GlobalControl.Instance.spells[index];         GameObject button1 = (GameObject)Instantiate(ButtonPrefab);         button1.GetComponent<GUIText>().text = spell.spellname;         button1.GetComponent<RectTransform>().SetParent(panel.transform);         //get prev button position         float yindex = 130.0f - spellinv.Count * 35.0f;         button1.GetComponent<RectTransform>().SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, yindex + 0, 10);         button1.layer = 5;         spellinv.Add(button1);     } 

There are no issues at runtime, however the RectTransform doesn’t alter the position it just sits at (0,0,0), and the text is still set to the prefab default “Button”, it appears to not register anything I apply to the button, except for the layer settings.

dynamically create elements on button click

I’m using create guten blocks to create a custom block for my theme and I need to create a list item with an onClick.

<script> function addItem() {   var ul = document.getElementById("ul-item");   var li = document.createElement("li");   var input = document.createElement("input");   input.type = "text";   li.setAttribute("id", "li-item");   li.appendChild(input);   ul.appendChild(li); } </script>  <ul id='ul-item'>   <li id="li-item"><input type="text" value="" /></li> </ul> <button onClick='addItem()'>Add Item</button> 

see the fiddle https://jsfiddle.net/j2yp7ub9/

something like that I just don’t know how to do it in CGB and can’t find anything using google.

Resizing CTA button & keep it responsive

HI,

I want to resize the CTA button on a single product page to fit the container.
I used this CSS code to do so:

==
.single_add_to_cart_button.button.alt {
height: 47.35px;
width: 552px;
font-size: 25px;
text-align: center;
}
==

and it works fine on desktop screen.
I added this CSS code to make a button responsive & adaptative.

==
@media only screen and (max-width: 480px){
.single_add_to_cart_button.button.alt{
max-width:600px !important;
width:100%…

Resizing CTA button & keep it responsive

twentysixteen child theme – responsive menu – ham icon button not working – Cannot read property ‘classList’ of null

I am trying to convert this site http://buildandtest.atspace.cc/ into twentysixteen child theme. It appears that /js/menu.js in my child theme is not working as nothing happens when the ham icon button is clicked (pls.see my site link above to check correct behavior). On inspecting via Google Chrome Inspect I am getting the following errors:

Uncaught TypeError: Cannot read property ‘classList’ of null at mediaqueryresponse (menu.js?ver=5.3.2:19) at menu.js?ver=5.3.2:10 at menu.js?ver=5.3.2:31 mediaqueryresponse @ menu.js?ver=5.3.2:19 (anonymous) @ menu.js?ver=5.3.2:10 (anonymous) @ menu.js?ver=5.3.2:31

Any advice is appreciated

header.php in child theme

<header class="header" id='myTopnav'>  <?php  wp_nav_menu(              array(                   'theme_location'=> 'topnav',                   'container' => 'nav',                   'menu_class' => 'topnav',                   'menu_id'    => 'myTopnav',                   )  );?>  <button class="ham-icon"><span class="fa fa-bars fa-2x"></span></button>  </header> 

/js/menu.js in child theme

(function () {   var mql = window.matchMedia("screen and (max-width: 960px)");   //detect media query    var navTop = document.querySelector(".header");   //return first element within the document that matches .header    var toggle = document.querySelector(".ham-icon");    mediaqueryresponse(mql);   //ensures that addListener function is executed when the page loads, by default addListener only fires when state of the window changes   mql.addListener(mediaqueryresponse);    function mediaqueryresponse(mql) {     if (mql.matches) {       toggle.addEventListener("click", clickMenu);       //if media query matches, execute click or clickMenu event     } else {       navTop.classList.remove("responsive");       //otherwise remove .responsive       toggle.removeEventListener("click", clickMenu);       //and remove EventListener     }    }    function clickMenu() {     navTop.classList.toggle("responsive");   }  })(); 

Immovable rod button specifics

The immovable rod doesn’t move without a very large amount of force. We know this.

One of my players is asking if the button on the removable rod has to be pressed and then released to activate it, or just pressed down to activate it. There’s no RAW answer for this, so I’m looking for a rules as interpreted answer for it. He’s wondering if he can slam the button against a wall and stick the rod there. Where the button’s permanently pressed so as no one can move it again. Outside of destroying the wall and then pressing the button which would take far more time.

Or on another hand does it repeatedly activate and then deactivate until the button’s released, causing it to fall to the floor.

Backstory. The situation we ended the session where my characters are being chased by evil jailers. They’ve been through a very long portion of the dungeon, and just ran into a cell and locked themselves in. Well the jailers have keys. The party wanted to place the button end of the immovable rod against the back of the cage to hold the door shut effectively locking themselves in. When they get done with their long rest, the character with the robe of useful items is going to use a window patch to remove a large portion of the door behind the gate, letting them out.

If they just press the button and affix the rod to the door, the enemy can reach through and deactivate the rod and open the door, same with sideways.

Is this a DM discretion question, or is there any direction on how this would work.

Change Template view of proucts on click button with javascript woocommerce

I use woocommmerce and i have two template view for products (content-product.php) and (contentcarousel-product.php) . in (archive-product.php) per defaut display first template like this

<?php wc_get_template_part( 'content', 'product' ); ?> 

I created two button like this with onclick event with javascript

<button onclick="Viewone()"> view 1</button> <button onclick="Viewtwo()"> view 2</button> 

I want when click button 1 display first template per defaut and when click button 2 display second template.

How i can do this with javascript and php

Save custom price radio button value in cart and display it on Cart page Woocommerce

I have added custom price on woocommerce single product page using the code below on my theme’s functions php:

<?php // Output the Custom field in Product pages add_action("woocommerce_before_add_to_cart_button", "options_on_single_product", 1); function options_on_single_product(){  ?> <ul class="pricing-options"> <li> <div class="custom-radio"> <input type="radio" id="opt1" class="" name="filter_opt" checked> <label for="opt1" data-price="<?php echo wc_price( $  price ) ;?>"> <span class="circle"></span>Single Site License </label> </div>  <p>Nunc placerat mi id nisi interdum is mollis. Praesent pharetra, justo ut sceleris que      the mattis, leo quam.</p> </li>  <li> <div class="custom-radio"> <input type="radio" id="opt2" class="" name="filter_opt"> <label for="opt2" data-price="<?php echo wc_price( $  price*3 ) ;?>"> <span class="circle"></span>2 Sites License</label>  </div>  <p>Nunc placerat mi id nisi interdum is mollis. Praesent pharetra, justo ut sceleris que         the mattis, leo quam.</p> </li> </ul> <?php } 

Now i want to display the selected option value on cart page. Please help me to do this. Thanks

How to make the pressing of a button keep an event occurring at a controlled rate?

Suppose I use a Button[] to make some event occur, how can I make the pressing of this button keep that event occurring at a controlled rate? I tried the following:

x = 0; Button["X", Dynamic[Refresh[x = x + 1, UpdateInterval -> 1]]] Dynamic[x] 

But it doesn’t keep repeating the event x=x+1 if the button keeps pressed. If there is some neater/better alternative without Button[], I’m open to it.

CSS Button effects not working across browsers

Having a few issues with a CSS Button effects not working across browsers.

It displays as I would like it in Chrome, but not Firefox.

Can't seem to find the root of the problem. Here is what I have.

Fiddle

<a class="soft">Button</a>
Code (markup):

a.soft {display: inline-block;font-family:'Varela Round', sans-serif;padding:2rem3rem;font-size:1.25vw;box-shadow:-10px-10px20px0#E6E6E6,10px10px20px0#ABABAB, inset 10px10px20px0#E6E6E6, inset...
Code (CSS):

CSS Button effects not working across browsers

Button Size in Manipulate

Consider the following code

Manipulate[a,  Dynamic@Grid[{     {"Slider", Control[{{a, 0, ""}, 0, 1, .1}]},     {"Checkbox", Control[{{b, 1, ""}, {1, 0}}]}     }, Alignment -> {{Right, Left}, Automatic}],  Delimiter,  Button["Button 1"],  Button["Button 2"],  ControlPlacement -> Left] 

which gives

enter image description here

Now, if we were to include an If statement for one of the buttons, we would need to use Dynamic. For example, we could use

Manipulate[a,  Dynamic@Grid[{     {"Slider", Control[{{a, 0, ""}, 0, 1, .1}]},     {"Checkbox", Control[{{b, 1, ""}, {1, 0}}]}     }, Alignment -> {{Right, Left}, Automatic}],  Delimiter,  Button["Button 1"],  Dynamic[If[a == 0, Button["Button 2"], Button["Button 3"]]],  ControlPlacement -> Left] 

which yields

enter image description here

As one can see, the button alignment changes when I do this. I want to fix this, to keep the same appearance as in the first example. One attempt at trying to solve this was to consider a Dynamic@Grid. That is,

Manipulate[a,  Dynamic@Grid[{     {"Slider", Control[{{a, 0, ""}, 0, 1, .1}]},     {"Checkbox", Control[{{b, 1, ""}, {1, 0}}]}     }, Alignment -> {{Right, Left}, Automatic}],  Delimiter,  Dynamic@Grid[{     {Button["Button 1"]},     If[a == 0, {Button["Button 2"]}, {Button["Button 3"]}]     }],  ControlPlacement -> Left] 

This, however, makes it a bit worse:

enter image description here

I could change the ItemSize within the Grid to get something similar to what I want, but I would have to do it manually. For instance,

Manipulate[a,  Dynamic@Grid[{     {"Slider", Control[{{a, 0, ""}, 0, 1, .1}]},     {"Checkbox", Control[{{b, 1, ""}, {1, 0}}]}     }, Alignment -> {{Right, Left}, Automatic}],  Delimiter,  Dynamic@Grid[{     {Button["Button 1"]},     If[a == 0, {Button["Button 2"]}, {Button["Button 3"]}]     }, ItemSize -> 30],  ControlPlacement -> Left] 

leads to

enter image description here

Still, the alignment with the slider is not perfect, and I’d have to manually adjust it. I wonder if it’s possible to do this in a more “automatic” way, without relying on manually fixing the ItemSize. I could include all controls in a Grid, but the problem with that is that the Delimiter doesn’t seem to format if I use a Grid, and I want to keep it in my Manipulate. Any ideas how to solve this?

Furthermore, how would I deal with the case

Manipulate[a,  Dynamic@Grid[{     {"Slider", Control[{{a, 0, ""}, 0, 1, .1}]},     {"Checkbox", Control[{{b, 1, ""}, {1, 0}}]}     }, Alignment -> {{Right, Left}, Automatic}],  Delimiter,  Dynamic@Column[{     {Button["Button 1"], Button["Button 2"]} // Row,     {Button["Button 3"], Button["Button 4"]} // Row     }, ItemSize -> 15],  ControlPlacement -> Left] 

that is,

enter image description here

Any suggestions are appreciated.