Why the UI text value is changing take affect only when returning back to the visual studio window and than back to the editor?

My guess is because I’m using OnValidate but is there another way to try to accomplish what I’m trying ?

The goal is use the drawn circle in one script information and use this information in another script.

For example the GameObject the draw circle script is attached to I want to get the Y position of that GameObject and assign the value to the other script specific variable in both Editor and Runtime modes.

This script draw a circle in this case around my player and I attached this script to a empty GameObject child of my player so I can change the circle height by changing the GameObject Y position :

using UnityEngine; using System.Collections; using System;  [ExecuteAlways] [RequireComponent(typeof(LineRenderer))] public class DrawRadiusAroundObject : MonoBehaviour {     [Range(1, 50)] public int segments = 50;     [Range(1, 5)] public float xRadius = 5;     [Range(1, 5)] public float yRadius = 5;     [Range(0.1f, 5f)] public float width = 0.1f;     public bool controlBothXradiusYradius = false;     public bool draw = true;      [SerializeField] private LineRenderer line;      private void Start()     {         if (!line) line = GetComponent<LineRenderer>();          CreatePoints();     }      //private void Update()     //{     //         //}      public void CreatePoints()     {         line.enabled = true;         line.widthMultiplier = width;         line.useWorldSpace = false;         line.widthMultiplier = width;         line.positionCount = segments + 1;          float x;         float y;          var angle = 20f;         var points = new Vector3[segments + 1];         for (int i = 0; i < segments + 1; i++)         {             x = Mathf.Sin(Mathf.Deg2Rad * angle) * xRadius;             y = Mathf.Cos(Mathf.Deg2Rad * angle) * yRadius;              points[i] = new Vector3(x, 0f, y);              angle += (380f / segments);         }          // it's way more efficient to do this in one go!         line.SetPositions(points);     }  #if UNITY_EDITOR     private float prevXRadius, prevYRadius;     private int prevSegments;     private float prevWidth;      private void OnValidate()     {         // Can't set up our line if the user hasn't connected it yet.         if (!line) line = GetComponent<LineRenderer>();         if (!line) return;          if (!draw)         {             // instead simply disable the component             line.enabled = false;         }         else         {             // Otherwise re-enable the component             // This will simply re-use the previously created points             line.enabled = true;              if (xRadius != prevXRadius || yRadius != prevYRadius || segments != prevSegments || width != prevWidth)             {                 CreatePoints();                  // Cache our most recently used values.                 prevXRadius = xRadius;                 prevYRadius = yRadius;                 prevSegments = segments;                 prevWidth = width;             }              if (controlBothXradiusYradius)             {                 yRadius = xRadius;             }         }     } #endif } 

The object with the drawn circle :

Drawn circle around the player

And this script is making an object the Target child to rotate around my player. I want by using the drawn circle information to set the rotating variables.

using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine;  [ExecuteAlways] public class SimpleRotate : MonoBehaviour {     public List<TextMeshProUGUI> uiText = new List<TextMeshProUGUI>();      public DrawRadiusAroundObject drawAround;      // Add this script to Cube(2)     [Header("Add your turret")]     public GameObject Turret;//to get the position in worldspace to which this gameObject will rotate around.      [Header("The axis by which it will rotate around")]     public Vector3 axis;//by which axis it will rotate. x,y or z.      [Header("Angle covered per update")]     public float angle; //or the speed of rotation.      public float upperLimit, lowerLimit, delay;// upperLimit & lowerLimit: heighest & lowest height;      private float height, prevHeight, time;//height:height it is trying to reach(randomly generated); prevHeight:stores last value of height;delay in radomness;       // Update is called once per frame     void Update()     {         //Gets the position of your 'Turret' and rotates this gameObject around it by the 'axis' provided at speed 'angle' in degrees per update          transform.RotateAround(Turret.transform.position, axis.normalized, angle);         time += Time.deltaTime;         //Sets value of 'height' randomly within 'upperLimit' & 'lowerLimit' after delay          if (time > delay)         {             prevHeight = height;             height = Random.Range(lowerLimit, upperLimit);             time = 0;         }         //Mathf.Lerp changes height from 'prevHeight' to 'height' gradually (smooth transition)           transform.position = new Vector3(transform.position.x, Mathf.Lerp(prevHeight, height, time), transform.position.z);          uiText[0].text = angle.ToString();         uiText[1].text = upperLimit.ToString();         uiText[2].text = lowerLimit.ToString();         uiText[3].text = delay.ToString();          upperLimit = drawAround.transform.position.y;     } } 

The object with the script that make Target object child to rotate around my player

Target is the basketball.

The basketball rotating around my player.

For example I tried to set the object Y position value on the Upper Limit variable in the SimpleRotate script.

Everything is getting update find in editor mode and runtime mode except the ui text.

First of all I’m not sure using [ExecuteAlways] in both scripts is the right way and second because I’m using OnValidate in the script that draw the circle the affecting on the variable upper limit is taking affect only when I validate by changing windows in the editor mode.

Why when I move the transform closer to the target by dragging it in the editor in the scene view the target start stuttering and moving back?

The script is attached to a transform that move to a target and than when reaching the target the transform become child of the target.

The script is working fine as it is now but if I drag with the mouse in the editor in the scene view the target to the moving transform while the transform is already moving to the target then the transform start stuttering and even moving back a bit like pushed back some forces pushing it back maybe because I’m using lerp in lines 55,56 ? I want to use lerp but maybe it’s making the problem?

Second if I move the target away from the transform instead trying to chase me and reaching me its doing this problems again.

I want that if I’m dragging and make the target closer to the moving transform than just keep the transform moving to the target and become child when they reaching each other and if I drag the target away from the transform make the transform try to chase me reach me and become child too.

using System.Collections; using System.Collections.Generic; using UnityEngine;  public class MoveToTarget : MonoBehaviour {     public enum TransitionState     {         None,         MovingTowards,         Transferring     }      public Transform destinationTransform;     public float speed;     public float lerpTime;     public bool isChild = false;      public AnimationCurve curve = AnimationCurve.EaseInOut(0.0f, 0.0f, 1.0f, 1.0f);     public Transform start;     public Transform end;     public float duration = 10.0f;     private float t;      private Transform originTransform;     private float timer;     private TransitionState state = TransitionState.MovingTowards;     private Vector3 originTrans;      void Start()     {         t = 0.0f;          curve.postWrapMode = WrapMode.PingPong;         originTrans = transform.position;     }      void Update()     {         switch (state)         {             case TransitionState.MovingTowards:                 var v = destinationTransform.position - transform.position;                 if (v.magnitude < 0.001f)                 {                     state = TransitionState.Transferring;                     originTransform = destinationTransform;                     timer = 0;                     return;                 }                 Vector3 moveDir = v.normalized;                 //transform.position += moveDir * speed * Time.deltaTime;                 t += Time.deltaTime;                 float s = t / duration;                 transform.position = Vector3.Lerp(originTrans,                     destinationTransform.position, curve.Evaluate(s));                 break;              case TransitionState.Transferring:                 timer += Time.deltaTime;                 this.transform.position = Vector3.Lerp(originTransform.position, destinationTransform.position, timer);                 if (timer >= 1.0f)                 {                     this.transform.parent = destinationTransform;                     isChild = true;                     state = TransitionState.None;                     this.enabled = false;                     return;                 }                 break;              default:                 this.enabled = false;                 return;         }     } } 

Map() fails when reading back GPU Texture

I need to read back a GPU texture (stored in the GPU as D3D11_USAGE_DEFAULT). I am doing this via creating a staging ID3D11Texture. The whole application is running in a Microsoft Store application.

I am starting from a D3D11ShaderResourceView defined in the cResourceShaderView variable below. Code follows:

    ID3D11Texture2D* pTextureInterface = 0;     ID3D11Resource* res;     HRESULT hr = 0;      ID3D11Texture2D* tx = 0;          ID3D11Device* dv;     deviceContext->GetDevice(&dv);      cResourceShaderView->GetResource(&res);     hr = res->QueryInterface<ID3D11Texture2D>(&pTextureInterface);     D3D11_TEXTURE2D_DESC desc;     pTextureInterface->GetDesc(&desc);      desc.Usage = D3D11_USAGE_STAGING;     desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;     desc.BindFlags = 0;      hr = dv->CreateTexture2D(&desc, nullptr, &tx);     deviceContext->CopyResource(tx, pTextureInterface);       D3D11_MAPPED_SUBRESOURCE mapped = { 0 };     hr = deviceContext->Map(tx, 0, D3D11_MAP_READ, 0, &mapped); 

The Map() function fails with an E_INVALIDARG.

I have turned on Debug Layers and there are no specific Warnings nor Errors in the VS Window for all these code above.

If I try to save this texture using the DirectX::SaveWICTextureToFile function which uses this same method in the sample, inside this function the Map() function call here fails as well with an E_INVALIDARG and without any Debug Warnings nor Errors.

The GetDesc() function gives me a valid D3D11_TEXTURE2D_DESC for that texture.

enter image description here

What could be wrong?

Thanks!

reload page when going back in browser

is there any way to refresh the browser page when backtracking with javascript: window.history.go (-1);?

there is the option to use document.referrer; but I can only go back one page. yes, I must go back 2 or 3 pages I can’t get it to work.

I wanted to know if there is a possibility to use some function so that when you go back the page is refreshed.

Greetings.

Getting Back Int WP Dev – Best Approach for custom post widgets (drag/drop)

At one point I was a fairly solid WP dev (at least I thought I was), but have not done a lot with the platform in about 6 years.

An old work friend has a job and was asking me to help out. I downloaded WP today and boy, was I shocked at the changes.

Here is what I am trying to do.

The project my friend has designed is pretty straightforward, outside of the home page.

On the HP, he wants to have dedicated areas where the client can drag and drop posts from various categories, BUT they all have custom layouts – ie in one section a post widget looks different than another, additionally, inside that section there needs to be some conditional logic – ie if the post has no image, don’t have the image tag etc.

Based on what I am seeing I should be using something like elementor, But, unless I am mistaken, even though customizable, the actual widgets or elements are limited in terms of fine tuning the contents – ie, you can manipulate them a bit, but ultimately they only can be customized so much.

To illustrate: Here is an example from his design:

enter image description here

All items here are standard posts, albeit in different categories.

What he would be looking to do is have a template where these posts can be dragged in. And be styled according to the section.

Back when I was building WP, it would have been a little more rigid, the sections would be hardcoded into the HP template and I would pull the posts in based on a query result (most recent, have a custom field checked etc etc). However, it would have been fool-proof and the content would simply flow.

I know the Gutenberg block editor allegedly will eventually allow this I would ideally be able to build a template with editable areas that the user could just drag items onto, BUT THEY NEED TO LOOK LIKE THEY DO IN EACH SECTION! Ie, could I build a template with those areas hardcoded in, and then have the user drag/remove custom post widgets into each, one at a time? Based on what I am seeing with the current state of the block editor, this is not doable.

Questions:

Can this be achieved with Elementor, Divi, or any of the other new editor tools – ie a completely custom single post element?

Ideally, can this be done with the current block editor – seems like it is still a bit off.

One more thing to add: this is not a new site, I actually built the original version in 2013, and it currently has 4k posts, so we’re kind of stuck wp here.

I used bool parameter in my animator controller setting it to true by script but where should I set it back to false and when?

using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI;  public class FireEffect : MonoBehaviour {     public Transform player;     public Transform target;      private float timeElapsed = 0;     private float lerpDuration = 3;     private float startValue = 1;     private float endValue = 0;     private float valueToLerp = 0;      private Animator playerAnimator;     private bool prevFacing = false;     private bool stopped = false;     private bool move = true;     private bool rot = false;     private Vector3 currPos;      private void Start()     {         playerAnimator = player.GetComponent<Animator>();     }      private void Update()     {         var currFacing = IsFacing(target);         if (currFacing != prevFacing)         {             timeElapsed = 0;         }         prevFacing = currFacing;          var distance = Vector3.Distance(player.position, target.position);          if (IsFacing(target))         {             if (distance < 10 && move)             {                 if (timeElapsed < lerpDuration)                 {                     valueToLerp = Mathf.Lerp(startValue, endValue, timeElapsed / lerpDuration);                     playerAnimator.SetFloat("Forward", valueToLerp);                     timeElapsed += Time.deltaTime;                 }                 playerAnimator.SetFloat("Forward", valueToLerp);                 stopped = true;                 valueToLerp = 0;             }              if (move == false)             {                 playerAnimator.SetFloat("Forward", 0);             }              if (playerAnimator.GetFloat("Forward") == 0 && stopped)             {                 move = false;                 rot = true;                 currPos = player.position;                 stopped = false;                 Debug.Log("Player current position when valueToLerp value is 0 : " + currPos);             }         }                  if(rot)         {             playerAnimator.SetBool("Walk Back", true);              rot = false;         }          if (playerAnimator.GetCurrentAnimatorStateInfo(0).IsName("Walk Back"))         {             playerAnimator.SetBool("Walk Back", false);         }     }      private bool IsFacing(Transform target)     {         Vector3 forward = player.TransformDirection(Vector3.forward);         Vector3 toTarget = target.position - player.position;         return Vector3.Dot(forward, toTarget) > 0;     }      public IEnumerator ScaleOverSeconds(Vector3 scaleTo, Vector3 rotateTo, Vector3 moveTo, float seconds)     {         float elapsedTime = 0;         Vector3 startingScale = player.localScale;         Vector3 startingRotation = player.localEulerAngles;         Vector3 startingPosition = player.localPosition;          while (elapsedTime < seconds)         {             player.localScale = Vector3.Lerp(startingScale, scaleTo, (elapsedTime / seconds));             player.localEulerAngles = Vector3.Lerp(startingRotation, rotateTo, (elapsedTime / seconds));             player.localPosition = Vector3.Lerp(startingPosition, moveTo, (elapsedTime / seconds));              elapsedTime += Time.deltaTime;              yield return null;         }         player.localScale = scaleTo;         player.localEulerAngles = rotateTo;         player.localPosition = moveTo;     } } 

At this part, I’m setting the bool to true once and it’s playing the "Walk Back".

if(rot)             {                 playerAnimator.SetBool("Walk Back", true);                      rot = false;             }                  if (playerAnimator.GetCurrentAnimatorStateInfo(0).IsName("Walk Back"))             {                 playerAnimator.SetBool("Walk Back", false);             } 

After that, I’m setting the trigger to false when it’s finishing playing it because if I will not set it to false it will keep playing the "Walk Back" nonstop.

I want that it will play it once but also when rot is true again then play it again once. but because I’m setting it false it’s not playing it again even if rot is true again.

animator controller

I created a transition from the Grounded blend tree to the Walk Back with the bool condition in the screenshot.

The Walk Back is working fine smooth as I wanted the problem is now how to make it play once only each time rot is true?

The way or the place in the script I’m setting the bool back to false make it that it will not play the Move Back ever again even if rot is true.

Best USA Hosting | $12 Per Year | SSD Storage | 30 Days Money Back | SSL

Hostpoco is a privately-owned professional free and paid web hosting provider company. Hostpoco has experienced tremendous growth and popularity thanks to our affordable high-performance web hosting services supported by the highly experienced techs and excellent level of service we deliver to our customers and all this available at a reasonable price. Today, the Hostpoco brand is heading to synonymous with excellent quality of service in the web hosting industry.

Hostpoco operates worldwide from the data center located in the United States. In addition to web hosting, Hostpoco offers additional web hosting peripherals including a wide variety of domain names. Currently, we are offering 50% with our shared, reseller, and WordPress hosting plans, get the advantage of this.

Promo Code: HP50

Our Strength’s:

Secure, Reliable, Stable, and best affiliate commission hosting
The hosting plan starts from $1/mo
Quality Assurance and protection
30 days unconditional money-back guarantee

Features of Hostpoco:

– Setup fee: Free
– Activation: Instant Setup
– Backups: Daily
– Free SSL
– Free Account Migration.
– Softaculous Autoinstaller
– Uptime: 99.9% guarantee
– 24/7/365 support
– 30-Day Money-Back Guarantee
– Payment Mode: Paypal, Card, Netbanking
– NO HIDDEN FEE
– Free Migration Service
– Cloudflare
– SEO Tools
– Mail Channels to route emails
– SSD Storage Servers

Try Now: https://www.hostpoco.com/one-dollar-cheap-ssd-hosting.php

Follow us on Twitter: https://twitter.com/HostPoco
Find us on Facebook: https://www.facebook.com/HostPoco/

Hostpoco.com

$1 Unlimited SSD Hosting | Cpanel | Free SSL | Money Back – Hostbazzar!

Powerful and high speed web hosting for your websites starting from one dollar per month. Now host your
website with us on our high quality SSD apache technology server. Hostbazzar is a well-funded small
business and dealing with web hosting since 2015. We’re not a corporation with hundreds of staff on
our payroll but we have a stable foundation and optimized operation costs which allow us to provide
you with reliable hosting services at affordable rates. Most of our best delivered plans are starting
from one dollar per month.

Our servers are located in USA. You can rest assured you are receiving the best possible price and service with Hostbazzar.
We also have 30 days money back guarantee!

*Features covered with our service :

-Unmetered Bandwidth
-Free DDoS Protection
-Free Let’s Encrypt SSL
-Free Daily Backups
-Free Migration
-Superfast NVMe SSD Drives
-Latest cPanel or DirectAdmin
-CloudLinux+
-Imunify360
-MailChannels
-JetBackup
-Multiple PHP Versions
-MariaDB
-IPv4 Supported
-USA Based Technical Support
-99.9% Uptime Guarantee
-30 Day Money Back Guarantee
-Softaculous Premium (Install WordPress in a snap!)
-SpamAssassin Spam Filter
-Cron Jobs

Order Now – https://hostbazzar.com/linux_shared_hosting.php

Thank you.