public override void UpdateValue() { if (!HasParameters || m_isEvaluating) { try { Type baseType = ReflectionUtility.GetActualType(IValue.Value) ?? FallbackType; if (!ReflectionProvider.Instance.IsReflectionSupported(baseType)) { throw new Exception("Type not supported with reflection"); } UpdateReflection(); if (IValue.Value != null) { IValue.Value = IValue.Value.Cast(ReflectionUtility.GetActualType(IValue.Value)); } } catch (Exception e) { ReflectionException = e.ReflectionExToString(true); } } base.UpdateValue(); }
public ReflectionInspector(object target) : base(target) { if (this is StaticInspector) { m_targetType = target as Type; } else { m_targetType = ReflectionUtility.GetActualType(target); } m_targetTypeShortName = SignatureHighlighter.ParseFullSyntax(m_targetType, false); ConstructUI(); CacheMembers(m_targetType); FilterMembers(); }
public virtual void UpdateValue() { var value = IValue.Value; // if the type has changed fundamentally, make a new interactivevalue for it var type = value == null ? FallbackType : ReflectionUtility.GetActualType(value); var ivalueType = InteractiveValue.GetIValueForType(type); if (ivalueType != IValue.GetType()) { IValue.OnDestroy(); CreateIValue(value, FallbackType); m_subContent.SetActive(false); } IValue.OnValueUpdated(); IValue.RefreshElementsAfterUpdate(); }
internal void RefreshComponentList() { var go = GameObjectInspector.ActiveInstance.TargetGO; s_allComps = go.GetComponents <Component>().ToArray(); var components = s_allComps; s_compListPageHandler.ListCount = components.Length; //int startIndex = m_sceneListPageHandler.StartIndex; int newCount = 0; foreach (var itemIndex in s_compListPageHandler) { newCount++; // normalized index starting from 0 var i = itemIndex - s_compListPageHandler.StartIndex; if (itemIndex >= components.Length) { if (i > s_lastCompCount || i >= s_compListTexts.Count) { break; } GameObject label = s_compListTexts[i].transform.parent.parent.gameObject; if (label.activeSelf) { label.SetActive(false); } } else { Component comp = components[itemIndex]; if (!comp) { continue; } if (i >= s_compShortlist.Count) { s_compShortlist.Add(comp); AddCompListButton(); } else { s_compShortlist[i] = comp; } var text = s_compListTexts[i]; text.text = SignatureHighlighter.ParseFullSyntax(ReflectionUtility.GetActualType(comp), true); var toggle = s_compToggles[i]; if (comp.TryCast <Behaviour>() is Behaviour behaviour) { if (!toggle.gameObject.activeSelf) { toggle.gameObject.SetActive(true); } toggle.isOn = behaviour.enabled; } else { if (toggle.gameObject.activeSelf) { toggle.gameObject.SetActive(false); } } var label = text.transform.parent.parent.gameObject; if (!label.activeSelf) { label.SetActive(true); } } } s_lastCompCount = newCount; }
// Updating result list content private void RefreshResultList() { if (m_resultListPageHandler == null || m_results == null) { return; } m_resultListPageHandler.ListCount = m_results.Length; int newCount = 0; foreach (var itemIndex in m_resultListPageHandler) { newCount++; // normalized index starting from 0 var i = itemIndex - m_resultListPageHandler.StartIndex; if (itemIndex >= m_results.Length) { if (i > m_lastCount || i >= m_resultListTexts.Count) { break; } GameObject label = m_resultListTexts[i].transform.parent.parent.gameObject; if (label.activeSelf) { label.SetActive(false); } } else { var obj = m_results[itemIndex]; var unityObj = obj as UnityEngine.Object; if (obj == null || (unityObj != null && !unityObj)) { continue; } if (i >= m_resultShortList.Count) { m_resultShortList.Add(obj); AddResultButton(); } else { m_resultShortList[i] = obj; } var text = m_resultListTexts[i]; if (m_context != SearchContext.StaticClass) { var name = SignatureHighlighter.ParseFullSyntax(ReflectionUtility.GetActualType(obj), true); if (unityObj && m_context != SearchContext.Singleton) { if (unityObj && !string.IsNullOrEmpty(unityObj.name)) { name += $": {unityObj.name}"; } else { name += ": <i><color=grey>untitled</color></i>"; } } text.text = name; } else { var type = obj as Type; text.text = SignatureHighlighter.ParseFullSyntax(type, true); } var label = text.transform.parent.parent.gameObject; if (!label.activeSelf) { label.SetActive(true); } } } m_lastCount = newCount; }