public VisualElement Build(InspectorDataProxy <Entity> proxy)
        {
            m_ObjectField = new ObjectField {
                label = proxy.Name
            };
            m_ObjectField.RegisterValueChangedCallback(evt => ValueChanged(proxy, evt));
            m_WorldManager   = proxy.Session.GetManager <IWorldManager>();
            m_AssetManager   = proxy.Session.GetManager <IAssetManager>();
            m_ComponentCache = proxy.Session.GetManager <IUnityComponentCacheManager>();

            // TODO: Find correct mapping
            var withComponents = proxy.GetAttribute <EntityWithComponentsAttribute>();

            if (null != withComponents)
            {
                m_ObjectField.objectType = DomainCache.GetAssetType(withComponents.Types.FirstOrDefault());
                m_SimpleMode             = false;
            }

            // Revert back to very generic
            if (null == m_ObjectField.objectType)
            {
                m_ObjectField.objectType = typeof(EntityReference);
                m_SimpleMode             = true;
            }
            return(m_ObjectField);
        }
Beispiel #2
0
        public void Update(InspectorDataProxy <SceneReference> proxy)
        {
            var sceneReference = proxy.Data;
            var assetPath      = m_PersistenceManager.GetSceneAssetPath(sceneReference.SceneGuid);
            var sceneAsset     = UnityEditor.AssetDatabase.LoadAssetAtPath <SceneAsset>(assetPath);

            m_ObjectField.SetValueWithoutNotify(sceneAsset);
        }
Beispiel #3
0
        public VisualElement Build(InspectorDataProxy <DynamicBuffer <TextString> > proxy)
        {
            m_TextField = new TextField("Value");
            m_Proxy     = proxy;
            m_TextField.RegisterValueChangedCallback(ValueChanged);

            return(m_TextField);
        }
 public VisualElement Build(InspectorDataProxy <EntityGuid> proxy)
 {
     m_TextField = new TextField {
         label = "guid"
     };
     m_TextField.RegisterValueChangedCallback(ValueChanged);
     return(m_TextField);
 }
        public void Update(InspectorDataProxy <LayerSorting> proxy)
        {
            var data  = proxy.Data;
            var index = m_Names.FindIndex(l => l.id == data.id);

            m_Layers.index = index < 0 ? 0 : index;
            m_Order.SetValueWithoutNotify(data.order);
        }
        public VisualElement Build(InspectorDataProxy <Color> proxy)
        {
            var c = proxy.Data;

            m_Field = new ColorField(proxy.Name);
            m_Field.AddToClassList(proxy.Name);
            m_Field.RegisterValueChangedCallback(evt => ColorChanged(proxy, evt));
            return(m_Field);
        }
 public virtual VisualElement Build(InspectorDataProxy <TNativeString> proxy)
 {
     m_Proxy     = proxy;
     m_TextField = new TextField
     {
         label     = proxy.Name,
         maxLength = MaxSize
     };
     m_TextField.RegisterValueChangedCallback(StringChanged);
     return(m_TextField);
 }
        public VisualElement Build(InspectorDataProxy <float2> proxy)
        {
            m_VectorField = new Vector2Field(proxy.Name);
            m_VectorField.AddToClassList(proxy.Name);

            SetInputClass(m_VectorField.Q <FloatField>("unity-x-input"), "x");
            SetInputClass(m_VectorField.Q <FloatField>("unity-y-input"), "y");

            m_VectorField.RegisterValueChangedCallback(evt => ValueChanged(proxy, evt));
            return(m_VectorField);
        }
Beispiel #9
0
 public VisualElement Build(InspectorDataProxy <SceneReference> proxy)
 {
     m_Proxy       = proxy;
     m_ObjectField = new ObjectField {
         label = m_Proxy.Name
     };
     m_ObjectField.RegisterValueChangedCallback(evt => ValueChanged(evt));
     m_ObjectField.objectType = typeof(SceneAsset);
     m_WorldManager           = m_Proxy.Session.GetManager <IWorldManager>();
     m_PersistenceManager     = m_Proxy.Session.GetManager <IPersistenceManager>();
     return(m_ObjectField);
 }
        public VisualElement Build(InspectorDataProxy <Rect> proxy)
        {
            var c = proxy.Data;

            m_Field = new RectField(proxy.Name);
            m_Field.AddToClassList(proxy.Name);
            SetInputClass(m_Field.Q <FloatField>("unity-x-input"), "x");
            SetInputClass(m_Field.Q <FloatField>("unity-y-input"), "y");
            SetInputClass(m_Field.Q <FloatField>("unity-width-input"), "width");
            SetInputClass(m_Field.Q <FloatField>("unity-height-input"), "height");
            m_Field.RegisterValueChangedCallback(evt => RectChanged(proxy, evt));
            return(m_Field);
        }
        private void ValueChanged(InspectorDataProxy <Entity> proxy, ChangeEvent <Object> evt)
        {
            if (m_SimpleMode)
            {
                if (evt.newValue && null != evt.newValue)
                {
                    EntityReference entityRef = null;
                    switch (evt.newValue)
                    {
                    case EntityReference reference:
                        entityRef = reference;
                        break;

                    case Component component:
                        entityRef = component.GetComponent <EntityReference>();
                        break;

                    case GameObject gameObject:
                        entityRef = gameObject.GetComponent <EntityReference>();
                        break;
                    }

                    if (entityRef && null != entityRef)
                    {
                        proxy.Data = m_WorldManager.GetEntityFromGuid(entityRef.Guid);
                    }
                    else
                    {
                        proxy.Data = Entity.Null;
                    }
                }
                else
                {
                    proxy.Data = Entity.Null;
                }
            }
            else
            {
                if (evt.newValue && null != evt.newValue)
                {
                    proxy.Data = m_AssetManager.GetEntity(evt.newValue);
                }
                else
                {
                    proxy.Data = Entity.Null;
                }
            }
        }
        public VisualElement Build(InspectorDataProxy <LayerSorting> proxy)
        {
            m_Proxy = proxy;
            var root = new VisualElement();

            m_Names  = UnityEngine.SortingLayer.layers.ToList();
            m_Layers = new PopupField <string>(
                nameof(LayerSorting.layer),
                m_Names.Select(sl => sl.name).ToList(),
                0,
                null, null);
            m_Layers.RegisterValueChangedCallback(LayerChanged);

            m_Order = new IntegerField(nameof(LayerSorting.order));
            m_Order.RegisterValueChangedCallback(OrderChanged);

            root.contentContainer.Add(m_Layers);
            root.contentContainer.Add(m_Order);

            return(root);
        }
Beispiel #13
0
 public void Update(InspectorDataProxy <Parent> proxy)
 {
 }
 public void Update(InspectorDataProxy <Entity> proxy)
 {
     m_ObjectField.SetValueWithoutNotify(m_SimpleMode
         ? m_ComponentCache.GetEntityReference(proxy.Data)
         : m_AssetManager.GetUnityObject(proxy.Data, ObjectType));
 }
        public void Update(InspectorDataProxy <Rect> proxy)
        {
            var c = proxy.Data;

            m_Field.SetValueWithoutNotify(new UnityEngine.Rect(c.x, c.y, c.width, c.height));
        }
        private static void RectChanged(InspectorDataProxy <Rect> parent, ChangeEvent <UnityEngine.Rect> evt)
        {
            var c = evt.newValue;

            parent.Data = new Rect(c.x, c.y, c.width, c.height);
        }
        private static void ColorChanged(InspectorDataProxy <Color> parent, ChangeEvent <UnityEngine.Color> evt)
        {
            var c = evt.newValue;

            parent.Data = new Color(c.r, c.g, c.b, c.a);
        }
        private static void ValueChanged(InspectorDataProxy <quaternion> parent, ChangeEvent <Vector3> evt)
        {
            var radians = evt.newValue;

            parent.Data = quaternion.Euler(Mathf.Deg2Rad * radians);
        }
Beispiel #19
0
 public void Update(InspectorDataProxy <DynamicBuffer <TextString> > proxy)
 {
     m_TextField.value = proxy.Data.Reinterpret <char>().AsString();
 }
Beispiel #20
0
 public VisualElement Build(InspectorDataProxy <Parent> proxy)
 => null;
 public void Update(InspectorDataProxy <TNativeString> proxy)
 {
     m_TextField.SetValueWithoutNotify(proxy.Data.ToString());
 }
        public void Update(InspectorDataProxy <Color> proxy)
        {
            var c = proxy.Data;

            m_Field.SetValueWithoutNotify(new UnityEngine.Color(c.r, c.g, c.b, c.a));
        }
 private static void ValueChanged(InspectorDataProxy <float4> parent, ChangeEvent <Vector4> evt)
 {
     parent.Data = evt.newValue;
 }
        public void Update(InspectorDataProxy <quaternion> proxy)
        {
            var v = proxy.Data.value;

            m_VectorField.SetValueWithoutNotify(new Quaternion(v.x, v.y, v.z, v.w).eulerAngles);
        }
 public void Update(InspectorDataProxy <float4> proxy)
 {
     m_VectorField.SetValueWithoutNotify(proxy.Data);
 }
 public void Update(InspectorDataProxy <EntityGuid> proxy)
 {
     m_TextField.SetValueWithoutNotify(proxy.Data.ToString());
 }