public override void OnInspectorGUI () { EditorGUIUtility.LookLikeControls(80f); m_TargetSpriteSwith = target as SpriteSwith; m_TargetSpriteSwith.InitTargetSprite(); EditorGUILayout.BeginHorizontal(); m_TargetSpriteSwith.m_SpriteCount = EditorGUILayout.IntField("精灵数量",m_TargetSpriteSwith.m_SpriteCount); if(GUILayout.Button("确定")) { List<string> m_SpriteListGroup = new List<string>(); foreach (var item in m_TargetSpriteSwith.m_SpriteList) { m_SpriteListGroup.Add(item); } m_TargetSpriteSwith.m_SpriteList = new string[m_TargetSpriteSwith.m_SpriteCount]; for (int i = 0; i < m_SpriteListGroup.Count; i++) { if (i < m_TargetSpriteSwith.m_SpriteList.Length) { m_TargetSpriteSwith.m_SpriteList[i] = m_SpriteListGroup[i]; } } } EditorGUILayout.EndHorizontal(); m_TargetSprite = EditorGUILayout.ObjectField("UISprite:",m_TargetSpriteSwith.m_TargetSprite,typeof(UISprite),true) as UISprite; if(m_TargetSpriteSwith.m_TargetSprite != m_TargetSprite) { m_TargetSpriteSwith.m_TargetSprite = m_TargetSprite; } if(m_TargetSprite != null) { ComponentSelector.Draw<UIAtlas>(m_TargetSprite.atlas, OnSelectAtlas, true); if(m_TargetSpriteSwith.m_SpriteList==null) { m_TargetSpriteSwith.m_SpriteList = new string[m_TargetSpriteSwith.m_SpriteCount]; } for(int i = 0;i<m_TargetSpriteSwith.m_SpriteList.Length;i++) { string labelName = "Sprite "+i.ToString(); string spriteName =m_TargetSpriteSwith.m_SpriteList[i] ==null?"Empty":m_TargetSpriteSwith.m_SpriteList[i].ToString(); GUILayout.BeginHorizontal(); GUILayout.Label(labelName, GUILayout.Width(76f)); if (GUILayout.Button(spriteName, "MiniPullDown")) { NGUISettings.atlas = m_TargetSprite.atlas; NGUISettings.selectedSprite = spriteName; SpriteSelectorForSpriteSwith.Show(OnSelectSprite,i); } GUILayout.EndHorizontal(); } } }