public ChildObjectData(SerializationInfo info, StreamingContext context)
 {
     this.DeserializeInfo    = info;
     this.DeserializeContext = context;
     this.Uid           = new ShortUid(info.GetInt64("sp_uid"));
     this.ComponentType = info.GetValue("sp_t", typeof(System.Type)) as System.Type;
 }
Exemplo n.º 2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            position = EditorGUI.PrefixLabel(position, label);
            float w  = Mathf.Min(position.width, 60f);
            var   r2 = new Rect(position.xMax - w, position.yMin, w, position.height);
            var   r1 = new Rect(position.xMin, position.yMin, Mathf.Max(position.width - w, 0f), position.height);

            var  lowProp  = property.FindPropertyRelative("_low");
            var  highProp = property.FindPropertyRelative("_high");
            long value    = (lowProp.longValue & uint.MaxValue) | (highProp.longValue << 32);

            var  attrib      = this.fieldInfo.GetCustomAttributes(typeof(ShortUid.ConfigAttribute), false).FirstOrDefault() as ShortUid.ConfigAttribute;
            bool resetOnZero = attrib == null || !attrib.AllowZero;
            bool readWrite   = attrib == null || !attrib.ReadOnly;

            if (readWrite)
            {
                //read-write
                EditorGUI.BeginChangeCheck();
                var sval = EditorGUI.TextField(r1, value.ToString("X16"));
                if (EditorGUI.EndChangeCheck())
                {
                    if (long.TryParse(sval, System.Globalization.NumberStyles.HexNumber, null, out value))
                    {
                        lowProp.longValue  = (value & uint.MaxValue);
                        highProp.longValue = (value >> 32);
                    }
                }
            }
            else
            {
                //read-only
                EditorGUI.SelectableLabel(r1, value.ToString("X16"), EditorStyles.textField);
            }

            if (GUI.Button(r2, "New Id") || (resetOnZero && value == 0))
            {
                value              = ShortUid.NewId().Value;
                lowProp.longValue  = (value & uint.MaxValue);
                highProp.longValue = (value >> 32);
            }

            EditorGUI.EndProperty();
        }
        internal void CreateAnimationEvent(AnimationClip clip, float time, AnimationEventCallback callback, object token)
        {
            //TODO - just realized, this might actually create multiple events on the same clip if 2 different gameobjects call to add it... not sure if 'AnimationClip' is a shared asset or not. Need to test!

            var ev = new AnimationEvent();

            ev.time            = time;
            ev.functionName    = "SPAnimationEventHook33417";
            ev.stringParameter = ShortUid.NewId().ToString();

            if (_animEventTable == null)
            {
                _animEventTable = new Dictionary <string, AnimationCallbackData>();
            }
            _animEventTable.Add(ev.stringParameter, new AnimationCallbackData(callback, token));

            clip.AddEvent(ev);
        }