Exemplo n.º 1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty typeProp      = property.FindPropertyRelative(nameof(EventField.type));
            SerializedProperty scopeProperty = property.FindPropertyRelative(nameof(EventField.scope));

            StratusEvent.Scope scope = GetEnumValue <StratusEvent.Scope>(scopeProperty);

            //SerializedProperty typeProp = property.FindPropertyRelative("Type");
            //Type eventType = typeProp.objectReferenceValue as Type;

            label = EditorGUI.BeginProperty(position, label, property);
            EditorGUI.PrefixLabel(position, label);


            float initialHeight = position.y;

            DrawPropertiesVertical(ref position, typeProp, scopeProperty);

            // Scope
            if (scope == StratusEvent.Scope.GameObject)
            {
                DrawSingleProperty(ref position, property.FindPropertyRelative(nameof(EventField.targets)));
                //AddLine(ref position);
            }
            height = position.y - initialHeight;
            EditorGUI.EndProperty();
        }
Exemplo n.º 2
0
        //------------------------------------------------------------------------/
        // Methods
        //------------------------------------------------------------------------/
        /// <summary>
        /// Constructs a proxy in order to observe another GameObject's collision messages
        /// </summary>
        /// <param name="target"></param>
        /// <param name="type"></param>
        /// <param name="onCollision"></param>
        /// <param name="persistent"></param>
        /// <returns></returns>
        public static StratusEventProxy Construct(GameObject target, StratusEvent.Scope scope, Type type, System.Action <Stratus.StratusEvent> onTrigger, bool persistent = true, bool debug = false)
        {
            var proxy = target.gameObject.AddComponent <StratusEventProxy>();

            proxy.scope = scope;
            proxy.type  = type;
            proxy.onTrigger.AddListener(new UnityAction <StratusEvent>(onTrigger));
            proxy.persistent = persistent;
            proxy.debug      = debug;
            return(proxy);
        }
Exemplo n.º 3
0
        //private float height = 0;

        //protected override float GetPropertyHeight(SerializedProperty property)
        //{
        //	//return base.GetPropertyHeight(property);
        //	return this.height;
        //}

        //public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        //{
        //	SerializedProperty typeProp = property.FindPropertyRelative(nameof(EventField.type));
        //	SerializedProperty scopeProperty = property.FindPropertyRelative(nameof(EventField.scope));
        //	StratusEvent.Scope scope = GetEnumValue<StratusEvent.Scope>(scopeProperty);
        //
        //	//SerializedProperty typeProp = property.FindPropertyRelative("Type");
        //	//Type eventType = typeProp.objectReferenceValue as Type;
        //
        //	label = EditorGUI.BeginProperty(position, label, property);
        //	position = EditorGUI.PrefixLabel(position, label);
        //
        //
        //	float initialHeight = position.y;
        //	this.DrawPropertiesVertical(ref position, typeProp, scopeProperty);
        //
        //	// Scope
        //	if (scope == StratusEvent.Scope.GameObject)
        //	{
        //		this.DrawProperty(ref position, property.FindPropertyRelative(nameof(EventField.targets)));
        //		//AddLine(ref position);
        //	}
        //	//this.height = position.y - initialHeight;
        //	EditorGUI.EndProperty();
        //}

        protected override void OnDrawProperty(Rect position, SerializedProperty property)
        {
            SerializedProperty typeProp      = property.FindPropertyRelative(nameof(StratusEventField.type));
            SerializedProperty scopeProperty = property.FindPropertyRelative(nameof(StratusEventField.scope));

            StratusEvent.Scope scope = GetEnumValue <StratusEvent.Scope>(scopeProperty);

            //SerializedProperty typeProp = property.FindPropertyRelative("Type");
            //Type eventType = typeProp.objectReferenceValue as Type;
            this.DrawPropertiesVertical(ref position, typeProp, scopeProperty);

            // Scope
            if (scope == StratusEvent.Scope.GameObject)
            {
                DrawProperty(ref position, property.FindPropertyRelative(nameof(StratusEventField.targets)));
            }
        }