简体   繁体   English

Unity - 如何重置 ExecuteInEditMode 脚本的检查器值?

[英]Unity - How do I reset Inspector values for an ExecuteInEditMode script?

I want to get back to the default values without having to shutdown and restart Unity.我想回到默认值而不必关闭并重新启动 Unity。

When I save in VSC the fields in the Inspector stay the same.当我在 VSC 中保存时,Inspector 中的字段保持不变。 The only way to get them to reset is to shutdown and restart Unity.让它们重置的唯一方法是关闭并重新启动 Unity。 Do I change code, a setting in Unity, or a setting in Visual Studio Code to get the Inspector panel and content back to original?我是否更改代码、Unity 中的设置或 Visual Studio Code 中的设置以将 Inspector 面板和内容恢复为原始状态?

在此处输入图片说明

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

[ExecuteInEditMode]
public class DebugGizmos : MonoBehaviour
{
 [SerializeField]
 private float innerRadius = 1.0f;

 [SerializeField]
 private float outerRadius = 10.0f;

 [SerializeField]
 private float angle = 10.0f;

 [SerializeField]
 private float gap = 10.0f;

 [SerializeField]
 private int segments = 10;

 [SerializeField]
 private float height = 1;

 // Debugging var for drawing Gizmos
 private Vector3 vLI, vLO, vUI, vUO;
 private List<Vector3> liaPts, loaPts, uiaPts, uoaPts;

 void OnDrawGizmos()
 {
     GenerateWedge(innerRadius, outerRadius, angle, gap, segments, height);
     // if (!Application.isPlaying) return;

     for (var i=0; i < segments; i++)
     {
         Gizmos.color = Color.red;
         Gizmos.DrawWireSphere(liaPts[i], .1f); //lowerInner
         Gizmos.color = Color.yellow;
         Gizmos.DrawWireSphere(uiaPts[i], .1f); //upperInner
         Gizmos.color = Color.green; 
         Gizmos.DrawWireSphere(loaPts[i], .1f); //lowerOuter
         Gizmos.color = Color.magenta;
         Gizmos.DrawWireSphere(uoaPts[i], .1f); //upperOuter
     }
 }

 ...and some helper functions.

Right Click on the Gear Icon in the Inspector where you script component is.在脚本组件所在的检查器中右键单击齿轮图标。

Then click on Reset.然后点击重置。

That should make the values go back to their initial values.这应该使值回到它们的初始值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM