private void OnEnable()
        {
            m_asset = (SDFMeshAsset)target;

            m_sourceMeshPreview = UnityEditor.Editor.CreateEditor(m_asset.SourceMesh);
            m_properties        = new SerializedProperties(serializedObject);
        }
Beispiel #2
0
        bool debugPositions = true;    //change this to diplay left click target positions

        private void OnEnable()
        {
            supportedTypes.Add(typeof(GameObject));
            supportedArrayProperties = new Dictionary <SerializedProperty, Vector2>();

            SerializedProperty sProperty = serializedObject.GetIterator();

            while (sProperty.NextVisible(true))
            {
                if (sProperty.isArray)
                {
                    Type elementType = SerializedProperties.GetElementType(sProperty);
                    if (supportedTypes.Contains(elementType))
                    {
                        supportedArrayProperties.Add(sProperty.Copy(), Vector2.zero);
                    }
                }
            }

            GameObject[] gos         = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();
            GameObject[] gameObjects = new GameObject[gos.Length + 1];
            gos.CopyTo(gameObjects, 1);

            GameObjectNameFilter     filter     = new GameObjectNameFilter();
            GameObjectCellView       cellView   = new GameObjectCellView(Vector2.zero); //use default size
            GameObjectNameCompararer compararer = new GameObjectNameCompararer();

            searchWindow = new MultipleSelectionSearchWindow <GameObject>(gameObjects, filter, cellView, compararer, false);

            searchWindow.CellClicked += OnCellSelectedHandler;

            //for debug position
            targetRectColor   = Color.red;
            targetRectColor.a = 0.1f;
        }
Beispiel #3
0
 /// <summary>
 /// Serialize streamable into a binary stream
 /// </summary>
 /// <typeparam name="TKey"></typeparam>
 /// <typeparam name="TPayload"></typeparam>
 /// <param name="container">The query container to which an egress point is being added.</param>
 /// <param name="identifier">A string that can uniquely identify the point of egress in the query.</param>
 /// <param name="input"></param>
 /// <param name="binaryStream"></param>
 /// <param name="writePropertiesToStream"></param>
 public static void RegisterBinaryOutput <TKey, TPayload>(this QueryContainer container, IStreamable <TKey, TPayload> input, Stream binaryStream, bool writePropertiesToStream = false, string identifier = null)
 {
     if (writePropertiesToStream)
     {
         var propSer = StreamSerializer.Create <SerializedProperties>();
         propSer.Serialize(binaryStream, SerializedProperties.FromStreamProperties(input.Properties));
     }
     container.RegisterOutputAsStreamMessages(input, identifier)
     .Subscribe(new BinaryStreamObserver <TKey, TPayload>(input.Properties, binaryStream));
 }
Beispiel #4
0
 /// <summary>
 /// Serialize streamable into a binary stream
 /// </summary>
 /// <typeparam name="TKey"></typeparam>
 /// <typeparam name="TPayload"></typeparam>
 /// <param name="input"></param>
 /// <param name="binaryStream"></param>
 /// <param name="writePropertiesToStream"></param>
 public static void ToBinaryStream <TKey, TPayload>(this IStreamable <TKey, TPayload> input, Stream binaryStream, bool writePropertiesToStream = false)
 {
     if (writePropertiesToStream)
     {
         var propSer = StreamSerializer.Create <SerializedProperties>();
         propSer.Serialize(binaryStream, SerializedProperties.FromStreamProperties(input.Properties));
     }
     input.ToStreamMessageObservable()
     .Subscribe(new BinaryStreamObserver <TKey, TPayload>(input.Properties, binaryStream));
 }
        // TODO: This appears to be copied code from Binary egress - can we unify?
        public ShardedSerializerObserver(Stream destination, StreamProperties <TKey, TPayload> sourceProps, bool writePropertiesToStream = false)
        {
            this.destination = destination;
            if (writePropertiesToStream)
            {
                var propSer = StreamableSerializer.Create <SerializedProperties>();
                propSer.Serialize(destination, SerializedProperties.FromStreamProperties(sourceProps));
            }

            this.serializer = StreamableSerializer.Create <QueuedMessage <StreamMessage <TKey, TPayload> > >(new SerializerSettings());
        }
        /// <summary>
        /// Write stream properties to specified .NET stream
        /// </summary>
        /// <typeparam name="TKey"></typeparam>
        /// <typeparam name="TPayload"></typeparam>
        /// <param name="streamable"></param>
        /// <param name="stream"></param>
        public static void WritePropertiesToStream <TKey, TPayload>(this IShardedStreamable <TKey, TPayload> streamable, Stream stream)
        {
            var properties        = StreamProperties <TKey, TPayload> .Default;
            var shardedStreamable = (ShardedStreamable <TKey, TPayload>)streamable;

            if (shardedStreamable != null)
            {
                if (shardedStreamable.Streamables.Length > 0)
                {
                    properties = shardedStreamable.Streamables[0].Properties;
                }
            }
            var propSer = StreamSerializer.Create <SerializedProperties>();

            propSer.Serialize(stream, SerializedProperties.FromStreamProperties(properties));
        }
Beispiel #7
0
        private void OnEnable()
        {
            m_isDeleteMode      = false;
            m_clickedCoordinate = null;
            m_hoveredCoordinate = null;

            m_grid = target as ChunkGrid;
            m_serializedProperties = new SerializedProperties(serializedObject);
            m_setter = new SerializedPropertySetter(serializedObject);

            m_emptyNeighbourControlIDs.Clear();

            foreach (Vector3Int coordinate in m_grid.UnoccupiedAxisAlignedNeighbourCoordinates)
            {
                m_emptyNeighbourControlIDs.Add(GUIUtility.GetControlID(FocusType.Passive), coordinate);
            }
        }
Beispiel #8
0
        private void OnCellSelectedHandler(object sender, ListView <GameObject> .OnCellClickedEventArgs e)
        {
            serializedObject.Update();

            if (currentlySelectedProperty == null)
            {
                return;
            }

            if (e.IsSelected)
            {
                SerializedProperties.AddArrayItem(e.CellData, currentlySelectedProperty);
            }
            else
            {
                SerializedProperties.RemoveArrayItem(e.CellData, currentlySelectedProperty);
            }

            serializedObject.ApplyModifiedProperties();
        }
 private void OnEnable()
 {
     m_sdfGroupMeshGen      = target as SDFGroupMeshGenerator;
     m_serializedProperties = new SerializedProperties(serializedObject);
     m_setter = new SerializedPropertySetter(serializedObject);
 }
 private void OnEnable()
 {
     m_serializedProperties = new SerializedProperties(serializedObject);
     m_sdfOperation         = target as SDFOperation;
     m_setter = new SerializedPropertySetter(serializedObject);
 }
        internal MixpanelEvent(string token)
        {
            Condition.Requires(token, nameof(token)).IsNotNull().IsNotEmpty().IsNotNullOrWhiteSpace();

            SerializedProperties.Add("token", token);
        }
Beispiel #12
0
 private void OnEnable()
 {
     m_serializedProperties = new SerializedProperties(serializedObject);
     m_sdfGroup             = target as SDFGroup;
 }
Beispiel #13
0
 private void OnEnable()
 {
     m_serializedProperties = new SerializedProperties(serializedObject);
     m_sdfMesh = target as SDFMesh;
     m_setter  = new SerializedPropertySetter(serializedObject);
 }
Beispiel #14
0
 private void OnEnable()
 {
     m_serializedProperties = new SerializedProperties(serializedObject);
     m_sdfPrimitive         = target as SDFPrimitive;
     m_setter = new SerializedPropertySetter(serializedObject);
 }
Beispiel #15
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            Event e = Event.current;

            Rect rect = EditorGUILayout.BeginVertical();    //hacky way to get rect of the component's inspector

            this.DrawDefaultInspector();
            EditorGUILayout.EndVertical();

            if (this.targets.Length > 1) //disable it for multiple objects editing
            {
                return;
            }

            if (e.type == EventType.Repaint)
            {
                validRect = rect;
            }

            if (validRect == null)                         //make sure a repaint event has occured to calculate array properties positions properly
            {
                return;
            }

            SerializedProperty sProperty = serializedObject.GetIterator();

            float padding = (float)/*GUI.skin.label.padding.vertical*//*4f /*/ 2f;          //technically we should get the style of each control drawn and use that padding
            float height  = 0;

            bool isExpanded = true;

            //calculate relative positions of each target control
            while (sProperty.NextVisible(isExpanded))
            {
                //make sure we don't count in child elements in none expanded controls
                isExpanded = sProperty.hasVisibleChildren ? sProperty.isExpanded : true;

                float propertyHeight = EditorGUI.GetPropertyHeight(sProperty, false) + padding;
                foreach (var key in supportedArrayProperties.Keys)
                {
                    if (SerializedProperty.EqualContents(key, sProperty))
                    {
                        //save the current position of target controls
                        supportedArrayProperties[key] = new Vector2(height, propertyHeight);       //technically propertyHeight should remain the same
                        break;
                    }
                }
                height += propertyHeight;
            }

            foreach (var pair in supportedArrayProperties)
            {
                //relative rect to Inspector Window
                Rect targetRect = new Rect(0, pair.Value.x + rect.y, Screen.width, pair.Value.y);

                if (debugPositions)
                {
                    EditorGUI.DrawRect(targetRect, targetRectColor);
                }

                if (e.button == 1 && e.type == EventType.MouseUp)
                {
                    if (targetRect.Contains(e.mousePosition))
                    {
                        currentlySelectedProperty = pair.Key;
                        List <GameObject> selected = new List <GameObject>();

                        for (int i = 0; i < pair.Key.arraySize; i++)
                        {
                            GameObject go = SerializedProperties.GetArrayElementAt(i, pair.Key) as GameObject;
                            selected.Add(go);
                        }

                        //eh
                        searchWindow.UnselectAll();
                        searchWindow.SetPreselectedItems(selected);

                        PopupWindow.Show(new Rect(e.mousePosition, Vector2.zero), searchWindow);
                        break;
                    }
                }
            }
        }
Beispiel #16
0
 private void OnEnable()
 {
     m_raymarcher           = target as SDFGroupRaymarcher;
     m_serializedProperties = new SerializedProperties(serializedObject);
     m_setter = new SerializedPropertySetter(serializedObject);
 }