unity shader bool3D 怎么保存toggle的bool值?

user interface - Unity3d - Multiple Selection Toggle Group UGUI - Stack Overflow
Stack Overflow for Teams
A private, secure home for your team's questions and answers.
to customize your list.
This site uses cookies to deliver our services and to show you relevant ads and job listings.
By using our site, you acknowledge that you have read and understand our
Your use of Stack Overflow’s Products and Services, including the Stack Overflow Network, is subject to these policies and terms.
I'm making a GUI for a program and I want the user to be able to pick from two of 7 choices. Is there a built in way to do this or do I need to do it from scratch myself? I read the documentation for Toggle and Toggle group and didn't see anything in there but I might be missing something either there or in another GUI element.
Edited to add: Unity3d 4.6.2
If you have not figured it out yet...
I have not tried this myself, but I imagine you could write a script for the toggles in place of using toggle group. I would try messing around with something along the lines of..
public void MyToggles()
if (ToggleOptions & 2)
//code to uncheck the last checked item
public void ToggleOptions()
//code here to group together your toggles
That's how I would approach this problem. As I said before I haven't needed this functionality so I cant say for certain how you would do that off the top of my head, but I hope that helps!
ToggleGroup is what you want.
Choose any other GameObject in the scene, and add a "ToggleGroup" component to that GameObject.
A natural choice would be whatever GameObject is the parent of your Toggle items.
Each of your Toggle items will have a "Group" field. Drag the GameObject with the ToggleGroup component on it into the "Group" field for each of your Toggle items.
1,22511532
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Post as a guest
Post as a guest
By clicking &Post Your Answer&, you acknowledge that you have read our updated ,
and , and that your continued use of the website is subject to these policies.
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledunity3d toggle组件如何实现声音的开启关闭_百度知道
unity3d toggle组件如何实现声音的开启关闭
自己写了写,但是只有点击选框的时候音乐才会关闭一下,并不能长时间关闭
我有更好的答案
记得好像是这个组件的OnValueChanged的机制问题。你可以尝试通过判断Toggle组件里的IsOn的状态来控制AudioSource.Play()或者AudioSource.Stop()
采纳率:78%
为您推荐:
其他类似问题
您可能关注的内容
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。Unity5.0_EditorGUI.Toggle 开关按钮_软件教程_翼狐网
Unity资源下载
下载次数:388
下载次数:264
下载次数:263
下载次数:240
下载次数:232
下载次数:202
Unity热门视频教程
共有87726人学习了该教程
共有46098人学习了该教程
共有44882人学习了该教程
共有39946人学习了该教程
共有32863人学习了该教程
共有29928人学习了该教程
翼狐网(yiihuu.com)旗下新媒体平台,为设计师定制的《生活周刊》!
微信号:yihuwang2012
摘要:Unity5.0_EditorGUI.Toggle 开关按钮_软件教程_翼狐网editorgui.toggle 开关按钮static function toggle (position : rect, value : bool) : boolstatic function toggle (position : rect, label : string, value : bool) : boolstatic function toggle (position : rect, label : guicontent, value : bool) : bool parameters参数positionrectangle on the screen to use for the toggle. & &屏幕上开关按钮使用的矩形区域 & &labeloptional label in front of the toggle. & &开关按钮前的可选标签 & &valuethe shown state of the toggle.
& &开关按钮的状态 & &returnsbool - the selected state of the toggle.返回布尔类型 - 开关按钮的选择状态。description描述 make a toggle.制作一个开关按钮。 toggle control in an editor window. 在编辑器窗口开关控制。// use a toggle button to show/hide a button that can close the window.//用一个开关按钮来 显示/隐藏 一个能关闭窗口的按钮class editorguitoggle extends editorwindow {var showclose : boolean =@menuitem(&examples/editorgui toggle usage&)static function init() {var window = getwindow(editorguitoggle);window.show();}function ongui() {showclose = editorgui.toggle(rect(0,5,position.width,20),&show close button&,showclose);if(showclose)if(gui.button(rect(0, 25, position.width, 100),&close window!&))this.close();}}
行业教程引导
软件教程引导unity3d自定义Toggle组件,解决设置isOn自动调用方法 - 简书
unity3d自定义Toggle组件,解决设置isOn自动调用方法
当我们在使用unity自带的Toggle组件的时候,我们是通过Toggle组件上的isOn属性得知是开启我们的功能面板还是关闭,这时候通常我们会给toggle绑定一个方法,当我们点击toggle的时候,调用方法,同时播放点击音效,可是有些时候,需要我们在切换界面的时候通过其它方法来关闭我们的属性isOn为false,方便我们下次点击的时候,isOn为true,这时候,我们单独对toggle的isOn属性赋值时会调用一次我们的方法,同时还会播放一次声音,恶心的事情就此发生,所以在项目中不得不重写了此组件,以方便项目中多处使用,下面是MyToggle脚本,挂载到对象身上即可,和unity自带的Toggle用法一样,只是在手动设置isOn属性的时候不会自动调用方法。
using UnityE
using UnityE
using UnityEngine.E
using UnityEngine.EventS
using UnityEngine.S
using UnityEngine.UI;
/// &summary&
/// 自定义Toggle组件
/// &/summary&
[RequireComponent(typeof(RectTransform))]
public class MyToggle : Selectable, IEventSystemHandler, IPointerClickHandler, ISubmitHandler, ICanvasElement
/// &summary&
/// toggle为true时切换显示的底图
/// &/summary&
public Graphic m_ChangeI
[SerializeField]
[FormerlySerializedAs("m_IsActive")]
private bool m_IsOn;
public MyToggle.ToggleTransition toggleTransition = MyToggle.ToggleTransition.F
public Toggle.ToggleEvent onValueChanged = new Toggle.ToggleEvent();
/// &summary&
/// 设置ison属性(自动调用一次方法)
/// &/summary&
public bool isOn
return this.m_IsOn;
this.Set(value);
/// &summary&
/// 设置ison属性(不会自动调用方法)
/// &/summary&
public bool IsOn
return this.m_IsOn;
this.Set(value, value, value);
protected MyToggle()
public virtual void Rebuild(CanvasUpdate executing)
if (executing != CanvasUpdate.Prelayout)
this.onValueChanged.Invoke(this.m_IsOn);
public virtual void LayoutComplete()
public virtual void GraphicUpdateComplete()
protected override void OnEnable()
base.OnEnable();
this.PlayEffect(true);
this.IsOn =
protected override void OnDisable()
base.OnDisable();
this.IsOn =
private void Set(bool value)
this.Set(value, true);
private void Set(bool value, bool sendCallback)
if (this.m_IsOn == value)
this.m_IsOn =
this.PlayEffect(this.toggleTransition == MyToggle.ToggleTransition.None);
if (!sendCallback)
this.onValueChanged.Invoke(this.m_IsOn);
private void Set(bool value, bool sendCallback, bool call)
if (this.m_IsOn == value)
this.m_IsOn =
this.PlayEffect(this.toggleTransition == MyToggle.ToggleTransition.None);
if (!sendCallback)
private void InternalToggle()
if (!this.IsActive() || !this.IsInteractable())
this.isOn = !this.isOn;
/// &summary&
/// 点击事件
/// &/summary&
/// &param name="eventData"&Current event.&/param&
public virtual void OnPointerClick(PointerEventData eventData)
if (eventData.button != PointerEventData.InputButton.Left)
this.InternalToggle();
public virtual void OnSubmit(BaseEventData eventData)
this.InternalToggle();
public enum ToggleTransition
[Serializable]
public class ToggleEvent : UnityEvent&bool&
protected override void OnDidApplyAnimationProperties()
if ((UnityEngine.Object)this.m_ChangeImage != (UnityEngine.Object)null)
bool flag = !Mathf.Approximately(this.m_ChangeImage.canvasRenderer.GetColor().a, 0.0f);
if (this.m_IsOn != flag)
this.m_IsOn =
this.Set(!flag);
base.OnDidApplyAnimationProperties();
private void PlayEffect(bool instant)
if ((UnityEngine.Object)this.m_ChangeImage == (UnityEngine.Object)null)
if (!Application.isPlaying)
this.m_ChangeImage.canvasRenderer.SetAlpha(!this.m_IsOn ? 0.0f : 1f);
this.m_ChangeImage.CrossFadeAlpha(!this.m_IsOn ? 0.0f : 1f, !instant ? 0.1f : 0.0f, true);
protected override void Start()
this.PlayEffect(true);
protected override void OnValidate()
base.OnValidate();
this.Set(this.m_IsOn, false);
this.PlayEffect(this.toggleTransition == MyToggle.ToggleTransition.None);
if (PrefabUtility.GetPrefabType((UnityEngine.Object)this) == PrefabType.Prefab || Application.isPlaying)
CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild((ICanvasElement)this);
This article is a record of my journey to learn Game Development and it will keep updating. 由于这篇文章的长度早已超出了简书编辑器的限制,因此后续内容将不在本文中更新,请移步本人的独...
?开启? 【iAPP实现进入界面执行逐一显】 〖 15:22:14〗 《//首先开一个线程,因为你有这么多的stop要执行,其次必须使用ufusui(),否则可能不会显示你的字体。切记:文字必须设置“text=”,否则很尴尬,还有我这里的8,14是两个文...
111. [动画系统]如何将其他类型的动画转换成关键帧动画? 动画-&点缓存-&关键帧 112. [动画]Unity引擎Mecanim动画系统功能优点? 答: l 简单化对类人角色动画设计与功能实现的工作流程。 l Mecanim动画系统使用一个可视化编程工具来管理动画之间...
用两张图告诉你,为什么你的 App 会卡顿? - Android - 掘金 Cover 有什么料? 从这篇文章中你能获得这些料: 知道setContentView()之后发生了什么? ... Android 获取 View 宽高的常用正确方式,避免为零 - 掘金 相信有很多...
用两张图告诉你,为什么你的 App 会卡顿? - Android - 掘金Cover 有什么料? 从这篇文章中你能获得这些料: 知道setContentView()之后发生了什么? ... Android 获取 View 宽高的常用正确方式,避免为零 - 掘金相信有很多朋友...
两种方法监测网络状态: AFNetworking中AFNetworkReachabilityManager监测网络状态 (void) inspectNetworkState {//创建网络状态监测管理者AFNetworkReachabilityManager manager...
舞枪灵湖畔,弹唱古亭边。 今朝逢佳日,福寿天际来。
《祝天下所有的情侣都是失散多年的兄妹》,第一次知道好妹妹乐队就是因为这首歌,随后听了些他们的翻唱,像是《青城山下白素贞》,《你到底有几个好妹妹》,《往事只能回味》等。后来知道,他们出了第一张专辑《春生》,备受好评,吸引了一批粉丝,到第二张《南北》时却被骂,说风格跟第一张雷同...Unity 游戏存档如何实现?求思路【unity3d吧】_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:86,518贴子:
Unity 游戏存档如何实现?求思路收藏
在做一款单击RPG,类似 我的世界和Terraria.整个游戏世界的元素都是可以重组的,有没有办法是保存整个游戏场景的?如果只是单纯的基本数据类型 string,int,bool,float,在脑中过了一遍,好像也不是不行,但会非常非常的麻烦.有没有比较好的方法?
51CTO学院12年行业品牌,1600万用户选择,中国专业IT技能学习平台,unity.通过在线学习的方式,帮助广大技术人员实现技能提升,高薪就业的职业梦想,unity.
没人了解吗? 召唤大神
可以用txt或者xml啊
给予每个prefab一个id,保存坐标和id,读取的时候把id对应的prefab在坐标实例化
和图集一样的概念呗,记住物体的ID或者名称,配上他的坐标,然后实例化物体。
点亮12星座印记,
使用0-X数字代表游戏物体,储存为一个txt文件,在游戏开始的时候读取这个文件,并且根据编号实例化游戏物体,在游戏中实时监测地图改变,同时更新地图txt文件不就行了。我的一个TANK大战游戏就是这么做的。
有一个方法是把同类型所有坐标保存下来为一个数组,然后用的时候三个三个分开,加载xyz,我的世界就是这样
其实存储数据就行,没必要存储对象,通过数据去实例化对象就可以
楼主最后是怎么做的啊
登录百度帐号

我要回帖

更多关于 unity animator bool 的文章

 

随机推荐