Example #1
0
 public override bool OnInspectorGUI(UCL_TC_Data tc_data, UnityEditor.SerializedProperty sdata)
 {
     {
         var data = sdata.FindPropertyRelative("m_UCL_Path");
         if (data.arraySize == 0)
         {
             data.InsertArrayElementAtIndex(0);
         }
         UnityEditor.EditorGUILayout.PropertyField(data.GetArrayElementAtIndex(0), new GUIContent("Path"));
     }
     {
         var data = sdata.FindPropertyRelative("m_Transform");
         if (data.arraySize == 0)
         {
             data.InsertArrayElementAtIndex(0);
         }
         UnityEditor.EditorGUILayout.PropertyField(data.GetArrayElementAtIndex(0), new GUIContent("Target"));
     }
     {
         var data = sdata.FindPropertyRelative("m_LookAtFront");
         if (data.arraySize == 0)
         {
             data.InsertArrayElementAtIndex(0);
         }
         UnityEditor.EditorGUILayout.PropertyField(data.GetArrayElementAtIndex(0), new GUIContent("LookAtFront"));
     }
     return(true);
 }
Example #2
0
        public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label)
        {
            UnityEditor.EditorGUI.BeginProperty(position, label, property);
            position = UnityEditor.EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
            int indent = UnityEditor.EditorGUI.indentLevel;

            UnityEditor.EditorGUI.indentLevel = 0;

            Rect valueRect    = new Rect(position.x, position.y, 75, position.height);
            Rect variableRect = new Rect(position.x + 75, position.y, position.width - 75, position.height);

            GUI.enabled = false;
            UnityEngine.Object           obj      = property.FindPropertyRelative("_variable").objectReferenceValue;
            UnityEditor.SerializedObject variable = obj == null ? null : new UnityEditor.SerializedObject(obj);
            if (variable != null)
            {
                UnityEditor.EditorGUI.PropertyField(valueRect, variable.FindProperty("_value"), GUIContent.none);
            }
            else
            {
                UnityEditor.EditorGUI.TextField(valueRect, "");
            }
            GUI.enabled = true;

            UnityEditor.EditorGUI.PropertyField(variableRect, property.FindPropertyRelative("_variable"), GUIContent.none);

            UnityEditor.EditorGUI.indentLevel = indent;
            UnityEditor.EditorGUI.EndProperty();
        }
Example #3
0
        public override void SetupSerializedProperties(UnityEditor.SerializedProperty property)
        {
            m_objectType = AkWwiseProjectData.WwiseObjectType.AUXBUS;
            m_typeName   = "AuxBus";

            m_IDProperty   = new[] { property.FindPropertyRelative("ID") };
            m_guidProperty = new[] { property.FindPropertyRelative("valueGuid.Array") };
        }
        public override void SetupSerializedProperties(UnityEditor.SerializedProperty property)
        {
            m_objectType = AkWwiseProjectData.WwiseObjectType.ACOUSTICTEXTURE;
            m_typeName   = "AcousticTexture";

            m_IDProperty   = new[] { property.FindPropertyRelative("ID") };
            m_guidProperty = new[] { property.FindPropertyRelative("valueGuid.Array") };
        }
Example #5
0
        public override void SetupSerializedProperties(UnityEditor.SerializedProperty property)
        {
            m_objectType = AkWwiseProjectData.WwiseObjectType.GAMEPARAMETER;
            m_typeName   = "GameParameter";

            m_IDProperty   = new[] { property.FindPropertyRelative("ID") };
            m_guidProperty = new[] { property.FindPropertyRelative("valueGuid.Array") };
        }
Example #6
0
        public override void SetupSerializedProperties(UnityEditor.SerializedProperty property)
        {
            m_objectType = AkWwiseProjectData.WwiseObjectType.SOUNDBANK;
            m_typeName   = "Bank";

            m_IDProperty     = new[] { property.FindPropertyRelative("ID") };
            m_guidProperty   = new[] { property.FindPropertyRelative("valueGuid.Array") };
            bankNameProperty = property.FindPropertyRelative("name");
        }
Example #7
0
        public override void SetupSerializedProperties(UnityEditor.SerializedProperty property)
        {
            m_objectType = AkWwiseProjectData.WwiseObjectType.SWITCH;
            m_typeName   = "Switch";

            m_IDProperty   = new[] { property.FindPropertyRelative("ID"), property.FindPropertyRelative("groupID") };
            m_guidProperty = new[]
            { property.FindPropertyRelative("valueGuid.Array"), property.FindPropertyRelative("groupGuid.Array") };
        }
Example #8
0
        public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
        {
            var x = property.FindPropertyRelative("x");
            var y = property.FindPropertyRelative("y");
            var v = new UnityEngine.Vector2(x.floatValue, y.floatValue);

            v            = UnityEditor.EditorGUI.Vector2Field(position, label, v);
            x.floatValue = v.x;
            y.floatValue = v.y;
        }
Example #9
0
        public override void SetupSerializedProperties(UnityEditor.SerializedProperty property)
        {
            m_objectType = AkWwiseProjectData.WwiseObjectType.EVENT;
            m_typeName   = "Event";

            m_IDProperty    = new UnityEditor.SerializedProperty[1];
            m_IDProperty[0] = property.FindPropertyRelative("ID");

            m_guidProperty    = new UnityEditor.SerializedProperty[1];
            m_guidProperty[0] = property.FindPropertyRelative("valueGuid.Array");
        }
Example #10
0
    public void OnEnable()
    {
        m_AkEventPlayable          = target as AkEventPlayable;
        akEvent                    = serializedObject.FindProperty("akEvent");
        overrideTrackEmitterObject = serializedObject.FindProperty("overrideTrackEmitterObject");
        emitterObjectRef           = serializedObject.FindProperty("emitterObjectRef");
        retriggerEvent             = serializedObject.FindProperty("retriggerEvent");

        m_IDProperty   = new[] { akEvent.FindPropertyRelative("ID") };
        m_guidProperty = new[] { akEvent.FindPropertyRelative("valueGuid.Array") };
    }
        public void OnEnable()
        {

            list = new UnityEditorInternal.ReorderableList(
                serializedObject, 
                serializedObject.FindProperty("m_entries"),
                true, 
                true, 
                true, 
                true
            );

            list.drawElementCallback = (UnityEngine.Rect rect, int index, bool isActive, bool isFocused) =>
            {
                UnityEditor.SerializedProperty element = list.serializedProperty.GetArrayElementAtIndex(index);
                rect.y += 2;
                UnityEditor.EditorGUI.PropertyField(
                    new UnityEngine.Rect(
                        rect.x, 
                        rect.y, 
                        160, 
                        UnityEditor.EditorGUIUtility.singleLineHeight
                    ), 
                    element.FindPropertyRelative("key"), 
                    UnityEngine.GUIContent.none
                );
                UnityEditor.EditorGUI.PropertyField(
                    new UnityEngine.Rect(
                        rect.x + 170, 
                        rect.y, 160, 
                        UnityEditor.EditorGUIUtility.singleLineHeight
                    ), 
                    element.FindPropertyRelative("value"), 
                    UnityEngine.GUIContent.none
                );

            };

            list.onAddCallback = (UnityEditorInternal.ReorderableList list) =>
            {
                int index = list.serializedProperty.arraySize;
                list.serializedProperty.arraySize++;
                list.index = index;

                // Important! When adding a new element to the list (and dictionary),
                // the newly created key must be unique.
                UnityEditor.SerializedProperty element = list.serializedProperty.GetArrayElementAtIndex(index);
                element.FindPropertyRelative("key").stringValue = System.Guid.NewGuid().ToString(); // Create some kind of unique key, like a GUID or adding a number to the last one.
            };

        } /* OnEnable() */
Example #12
0
        public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
        {
            var x = property.FindPropertyRelative("x");
            var y = property.FindPropertyRelative("y");
            var z = property.FindPropertyRelative("z");
            var w = property.FindPropertyRelative("z");
            var v = new UnityEngine.Quaternion(x.floatValue, y.floatValue, z.floatValue, w.floatValue);

            v            = UnityEngine.Quaternion.Euler(UnityEditor.EditorGUI.Vector3Field(position, label, v.eulerAngles));
            x.floatValue = v.x;
            y.floatValue = v.y;
            z.floatValue = v.z;
            w.floatValue = v.w;
        }
            public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property,
                                       UnityEngine.GUIContent label)
            {
                UnityEditor.EditorGUI.BeginProperty(position, label, property);

                if (label != null && !string.IsNullOrEmpty(label.text))
                {
                    UnityEditor.EditorGUI.LabelField(position, label);
                    position.x     += UnityEditor.EditorGUIUtility.labelWidth;
                    position.width -= UnityEditor.EditorGUIUtility.labelWidth;
                }

                var indent = UnityEditor.EditorGUI.indentLevel;

                UnityEditor.EditorGUI.indentLevel = 0;

                var value = property.FindPropertyRelative("value");

                //Since some callback flags are unsupported, some bits are not used.
                //But when using EditorGUILayout.MaskField, clicking the third flag will set the third bit to one even if the third flag in the AkCallbackType enum is unsupported.
                //This is a problem because clicking the third supported flag would internally select the third flag in the AkCallbackType enum which is unsupported.
                //To solve this problem we use a mask for display and another one for the actual callback
                var displayMask = GetDisplayMask(value.intValue);

                displayMask    = UnityEditor.EditorGUI.MaskField(position, displayMask, SupportedCallbackFlags);
                value.intValue = GetWwiseCallbackMask(displayMask);

                UnityEditor.EditorGUI.indentLevel = indent;

                UnityEditor.EditorGUI.EndProperty();
            }
        public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label)
        {
            var attr       = this.attribute as InspectorDisplayAttribute;
            var fieldValue = property.FindPropertyRelative(attr.FieldName);

            UnityEditor.EditorGUI.PropertyField(position, fieldValue, label);
        }
    public void OnEnable()
    {
        m_AkEventPlayable          = target as AkEventPlayable;
        akEvent                    = serializedObject.FindProperty("akEvent");
        overrideTrackEmitterObject = serializedObject.FindProperty("overrideTrackEmitterObject");
        emitterObjectRef           = serializedObject.FindProperty("emitterObjectRef");
        retriggerEvent             = serializedObject.FindProperty("retriggerEvent");

        m_IDProperty      = new UnityEditor.SerializedProperty[1];
        m_IDProperty[0]   = akEvent.FindPropertyRelative("ID");
        m_guidProperty    = new UnityEditor.SerializedProperty[1];
        m_guidProperty[0] = akEvent.FindPropertyRelative("valueGuid.Array");

        if (!m_AkEventPlayable.akEvent.IsValid())
        {
            UnityEditor.EditorApplication.delayCall += DelayCreateCall;
        }
    }
        public override float GetPropertyHeight(UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) {
            
            var isInput = property.FindPropertyRelative("isInput").boolValue;
            if (isInput == true) return 0f;
            
            var h = 0f;
            var data = property.FindPropertyRelative("data");
            for (int i = 0; i < data.arraySize; ++i) {
                
                var element = data.GetArrayElementAtIndex(i);
                var isArray = element.FindPropertyRelative("isArray");
                var key = (isArray.boolValue == true ? "valueArr" : "value");
                var value = element.FindPropertyRelative(key);
                h += UnityEditor.EditorGUI.GetPropertyHeight(value, true);
                
            }

            return h;

        }
Example #17
0
        public override bool OnInspectorGUI(UCL_TC_Data tc_data, UnityEditor.SerializedProperty sdata)
        {
            var event_data = sdata.FindPropertyRelative("m_UCL_TC_Event");

            if (event_data.arraySize == 0)
            {
                event_data.InsertArrayElementAtIndex(0);
            }
            UnityEditor.EditorGUILayout.PropertyField(event_data.GetArrayElementAtIndex(0));
            return(true);
        }
        public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) {

            var data = property.FindPropertyRelative("data");
            var vars = property.FindPropertyRelative("boxVars");
            var captions = property.FindPropertyRelative("captions");
            var isInput = property.FindPropertyRelative("isInput").boolValue;
            for (int i = 0; i < data.arraySize; ++i) {

                var element = data.GetArrayElementAtIndex(i);
                var isArray = element.FindPropertyRelative("isArray");
                var key = (isArray.boolValue == true ? "valueArr" : "value");
                
                var value = element.FindPropertyRelative(key);
                if (isInput == false) UnityEditor.EditorGUI.PropertyField(position, value, new UnityEngine.GUIContent(GUILayoutExt.GetStringCamelCaseSpace(captions.GetArrayElementAtIndex(i).stringValue)), true);
                var h = UnityEditor.EditorGUI.GetPropertyHeight(value, true);
                position.height = UnityEditor.EditorGUI.GetPropertyHeight(value, false);
                this.DrawLink(ref position, i, vars.GetArrayElementAtIndex(i), value, isInput);
                position.y += h;

            }
            
        }
Example #19
0
    public override float GetPropertyHeight(UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
    {
        var height = (UnityEditor.EditorGUIUtility.singleLineHeight + UnityEditor.EditorGUIUtility.standardVerticalSpacing) *
                     2;
        var listenerListProperty = property.FindPropertyRelative("initialListenerList");

        if (listenerListProperty != null && listenerListProperty.isArray)
        {
            height += (UnityEditor.EditorGUIUtility.singleLineHeight + UnityEditor.EditorGUIUtility.standardVerticalSpacing) *
                      listenerListProperty.arraySize + UnityEditor.EditorGUIUtility.standardVerticalSpacing;
        }

        return(height);
    }
Example #20
0
 override public void OnInspectorGUIBasic(UCL_TC_Data iTcData, UnityEditor.SerializedProperty iSerializedProperty, Transform iTransform)
 {
     base.OnInspectorGUIBasic(iTcData, iSerializedProperty, iTransform);
     UnityEditor.SerializedProperty aTransformDatas = iSerializedProperty.FindPropertyRelative("m_Transform");
     if (iTransform != null && aTransformDatas != null)
     {
         if (aTransformDatas.arraySize == 0)
         {//Init
             aTransformDatas.InsertArrayElementAtIndex(0);
             aTransformDatas.InsertArrayElementAtIndex(1);
             aTransformDatas.GetArrayElementAtIndex(0).objectReferenceValue = iTransform;
         }
     }
 }
        public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label)
        {
            var attr       = this.attribute as InspectorDisplayAttribute;
            var fieldValue = property.FindPropertyRelative(attr.FieldName);

            if (fieldValue == null)
            {
                UnityEditor.EditorGUI.LabelField(position, label, new GUIContent()
                {
                    text = "InspectorDisplay can't find target:" + attr.FieldName
                });
            }
            else
            {
                UnityEditor.EditorGUI.PropertyField(position, fieldValue, label);
            }
        }
        public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label)
        {
            var viewInfoProp = property.FindPropertyRelative("viewInfo");
            var viewInfo     = viewInfoProp.GetSerializedValue <ME.ECS.Views.ViewInfo>();

            if (ME.ECS.Worlds.current != null)
            {
                var viewsModule    = ME.ECS.Worlds.current.GetModule <ME.ECS.Views.ViewsModule>();
                var viewSource     = viewsModule.GetViewSource(viewInfo.prefabSourceId);
                var viewsModuleInt = (IViewModuleBase)viewsModule;
                var arr            = viewsModuleInt.GetData();
                var hasInstance    = false;
                if (viewInfo.entity.id < arr.Length)
                {
                    var item = arr[viewInfo.entity.id];
                    if (item.mainView != null)
                    {
                        var view = item.mainView as ME.ECS.Views.Providers.MonoBehaviourViewBase;
                        if (view != null)
                        {
                            UnityEditor.EditorGUI.BeginDisabledGroup(true);
                            UnityEditor.EditorGUI.ObjectField(position, new GUIContent("View"), (Object)viewSource, typeof(Object), allowSceneObjects: false);
                            UnityEditor.EditorGUI.EndDisabledGroup();
                            hasInstance = true;
                        }
                    }
                }

                if (hasInstance == false)
                {
                    UnityEditor.EditorGUI.BeginDisabledGroup(true);
                    UnityEditor.EditorGUI.ObjectField(position, new GUIContent("View Source"), (Object)viewSource, typeof(Object), allowSceneObjects: false);
                    UnityEditor.EditorGUI.EndDisabledGroup();
                }
            }
            else
            {
                GUI.Label(position, "View Source Id: " + viewInfo.prefabSourceId);
            }
        }
Example #23
0
        public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
        {
            UnityEditor.EditorGUI.BeginProperty(position, label, property);

            var wwiseObjectReference = property.FindPropertyRelative("WwiseObjectReference");

            HandleDragAndDrop(wwiseObjectReference, position);

            position = UnityEditor.EditorGUI.PrefixLabel(position,
                                                         UnityEngine.GUIUtility.GetControlID(UnityEngine.FocusType.Passive), label);

            var style = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.button);

            style.alignment = UnityEngine.TextAnchor.MiddleLeft;
            style.fontStyle = UnityEngine.FontStyle.Normal;

            var componentName = GetComponentName(wwiseObjectReference);

            if (string.IsNullOrEmpty(componentName))
            {
                componentName          = "No " + WwiseObjectType + " is currently selected";
                style.normal.textColor = UnityEngine.Color.red;
            }

            if (UnityEngine.GUI.Button(position, componentName, style))
            {
                new AkWwiseComponentPicker.PickerCreator
                {
                    objectType           = WwiseObjectType,
                    wwiseObjectReference = wwiseObjectReference,
                    pickerPosition       = AkUtilities.GetLastRectAbsolute(position),
                    serializedObject     = property.serializedObject
                };
            }

            UnityEditor.EditorGUI.EndProperty();
        }
Example #24
0
            public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label)
            {
                UnityEditor.SerializedProperty
                    entityKind  = property.FindPropertyRelative("entityKind"),
                    domain      = property.FindPropertyRelative("domain"),
                    country     = property.FindPropertyRelative("country"),
                    category    = property.FindPropertyRelative("category"),
                    subCategory = property.FindPropertyRelative("subCategory"),
                    specific    = property.FindPropertyRelative("specific"),
                    extra       = property.FindPropertyRelative("extra");
                float ShiftLeft = 8 + 7 * UnityEditor.EditorGUI.indentLevel;

                UnityEditor.EditorGUI.BeginProperty(position, label, property);
                float titleWidth = UnityEditor.EditorGUIUtility.labelWidth;
                Rect  labelR     = new Rect(position);

                labelR.width = titleWidth;
                UnityEditor.EditorGUI.LabelField(labelR, label);
                float indentationFix = 15 * UnityEditor.EditorGUI.indentLevel;
                float totalTextWidth = 4 * TextWidth - 6 * ShiftLeft;
                float partWidth      = 4 + (position.width - titleWidth - totalTextWidth + indentationFix) / 4;
                Rect  kindR          = new Rect(labelR.xMax - indentationFix, position.y, partWidth, 16),
                      colon1R        = new Rect(kindR.x + partWidth - ShiftLeft, position.y, TextWidth, 16),
                      domainR        = new Rect(colon1R.x + colon1R.width - ShiftLeft, position.y, partWidth, 16),
                      colon2R        = new Rect(domainR.x + partWidth - ShiftLeft, position.y, TextWidth, 16),
                      countryR       = new Rect(colon2R.x + colon2R.width - ShiftLeft, position.y, partWidth, 16),
                      colon3R        = new Rect(countryR.x + partWidth - ShiftLeft, position.y, TextWidth, 16),
                      categoryR      = new Rect(colon3R.x + colon3R.width - ShiftLeft, position.y, partWidth, 16),
                      colon4R        = new Rect(categoryR.x + partWidth - ShiftLeft, position.y, TextWidth, 16),
                      subCategoryR   = new Rect(kindR.x, position.yMax - 16, partWidth, 16),
                      colon5R        = new Rect(colon1R.x, subCategoryR.y, TextWidth, 16),
                      specificR      = new Rect(domainR.x, colon5R.y, partWidth, 16),
                      colon6R        = new Rect(colon2R.x, specificR.y, TextWidth, 16),
                      extraR         = new Rect(countryR.x, colon6R.y, partWidth, 16);
                GUIStyle s           = new GUIStyle();

                s.alignment = TextAnchor.MiddleCenter;
                UnityEditor.EditorGUI.PropertyField(kindR, entityKind, GUIContent.none);
                UnityEditor.EditorGUI.LabelField(colon1R, ":", s);
                UnityEditor.EditorGUI.PropertyField(domainR, domain, GUIContent.none);
                UnityEditor.EditorGUI.LabelField(colon2R, ":", s);
                UnityEditor.EditorGUI.PropertyField(countryR, country, GUIContent.none);
                UnityEditor.EditorGUI.LabelField(colon3R, ":", s);
                UnityEditor.EditorGUI.PropertyField(categoryR, category, GUIContent.none);
                UnityEditor.EditorGUI.LabelField(colon4R, ":", s);
                UnityEditor.EditorGUI.PropertyField(subCategoryR, subCategory, GUIContent.none);
                UnityEditor.EditorGUI.LabelField(colon5R, ":", s);
                UnityEditor.EditorGUI.PropertyField(specificR, specific, GUIContent.none);
                UnityEditor.EditorGUI.LabelField(colon6R, ":", s);
                UnityEditor.EditorGUI.PropertyField(extraR, extra, GUIContent.none);
                UnityEditor.EditorGUI.EndProperty();

                Rect  propertyArea = Rect.MinMaxRect(kindR.xMin, kindR.yMin, categoryR.xMax + TextWidth, extraR.yMax);
                Event e            = Event.current;

                if (e.type == EventType.MouseDown && e.button == 1 && propertyArea.Contains(e.mousePosition))
                {
                    UnityEditor.GenericMenu menu = new UnityEditor.GenericMenu();
                    TextEditor te    = new TextEditor();
                    string     value = new System.Text.StringBuilder()
                                       .Append(entityKind.intValue).Append(":")
                                       .Append(domain.intValue).Append(":")
                                       .Append(country.intValue).Append(":")
                                       .Append(category.intValue).Append(":")
                                       .Append(subCategory.intValue).Append(":")
                                       .Append(specific.intValue).Append(":")
                                       .Append(extra.intValue).ToString();
                    menu.AddItem(new GUIContent("Copy " + value, value), false, () =>
                    {
                        te.text = value;
                        te.SelectAll();
                        te.Copy();
                    });
                    te.text = string.Empty;
                    if (te.CanPaste())
                    {
                        te.Paste();
                        EntityType type;
                        if (EntityType.TryFromString(te.text, out type, false))
                        {
                            menu.AddItem(new GUIContent("Paste " + te.text, te.text), false, () =>
                            {
                                entityKind.intValue  = type.entityKind;
                                domain.intValue      = type.domain;
                                country.intValue     = type.country;
                                category.intValue    = type.category;
                                subCategory.intValue = type.subCategory;
                                specific.intValue    = type.specific;
                                extra.intValue       = type.extra;
                                property.serializedObject.ApplyModifiedProperties();
                            });
                        }
                        else
                        {
                            menu.AddDisabledItem(new GUIContent("Paste as string", te.text));
                        }
                    }
                    else
                    {
                        menu.AddDisabledItem(new GUIContent("Paste as string"));
                    }
                    menu.ShowAsContext();
                }
            }
Example #25
0
            public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label)
            {
                UnityEditor.SerializedProperty site   = property.FindPropertyRelative("site"),
                                               host   = property.FindPropertyRelative("host"),
                                               entity = property.FindPropertyRelative("entity");
                float ShiftLeft = 6 + 8 * UnityEditor.EditorGUI.indentLevel;

                UnityEditor.EditorGUI.BeginProperty(position, label, property);
                float titleWidth = UnityEditor.EditorGUIUtility.labelWidth;
                Rect  labelR     = new Rect(position);

                labelR.width = titleWidth;
                UnityEditor.EditorGUI.LabelField(labelR, label);
                float indentationFix = 15 * UnityEditor.EditorGUI.indentLevel;
                float totalTextWidth = 2 * TextWidth - 4 * ShiftLeft;
                float partWidth      = (position.width - titleWidth - totalTextWidth + indentationFix) / 3;
                Rect  siteR          = new Rect(labelR.xMax - indentationFix, position.y, partWidth, position.height),
                      colon1R        = new Rect(siteR.xMax - ShiftLeft, position.y, TextWidth, position.height),
                      hostR          = new Rect(colon1R.xMax - ShiftLeft, position.y, partWidth, position.height),
                      colon2R        = new Rect(hostR.xMax - ShiftLeft, position.y, TextWidth, position.height),
                      entityR        = new Rect(colon2R.xMax - ShiftLeft, position.y, partWidth, position.height);

                UnityEditor.EditorGUI.PropertyField(siteR, site, GUIContent.none);
                UnityEditor.EditorGUI.PropertyField(hostR, host, GUIContent.none);
                UnityEditor.EditorGUI.PropertyField(entityR, entity, GUIContent.none);
                GUIStyle s = new GUIStyle();

                s.alignment = TextAnchor.MiddleCenter;
                UnityEditor.EditorGUI.LabelField(colon1R, ":", s);
                UnityEditor.EditorGUI.LabelField(colon2R, ":", s);

                Rect  propertyArea = Rect.MinMaxRect(siteR.xMin, siteR.yMin, entityR.xMax, entityR.yMax);
                Event e            = Event.current;

                if (e.type == EventType.MouseDown && e.button == 1 && propertyArea.Contains(e.mousePosition))
                {
                    TextEditor te = new TextEditor();
                    UnityEditor.GenericMenu menu = new UnityEditor.GenericMenu();
                    string value = new System.Text.StringBuilder()
                                   .Append(site.intValue).Append(":")
                                   .Append(host.intValue).Append(":")
                                   .Append(entity.intValue).ToString();
                    GUIContent content = new GUIContent("Copy " + value, value);
                    menu.AddItem(content, false, () =>
                    {
                        te.text = value;
                        te.SelectAll();
                        te.Copy();
                    });
                    te.text = string.Empty;
                    if (te.CanPaste())
                    {
                        te.Paste();
                        EntityId id;
                        if (EntityId.TryFromString(te.text, out id, false))
                        {
                            menu.AddItem(new GUIContent("Paste " + te.text, te.text), false, () =>
                            {
                                site.intValue   = id.site;
                                host.intValue   = id.host;
                                entity.intValue = id.entity;
                                property.serializedObject.ApplyModifiedProperties();
                            });
                        }
                        else
                        {
                            menu.AddDisabledItem(new GUIContent("Paste as string"));
                        }
                    }
                    else
                    {
                        menu.AddDisabledItem(new GUIContent("Paste as string"));
                    }
                    menu.ShowAsContext();
                }
                UnityEditor.EditorGUI.EndProperty();
            }
Example #26
0
        public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
        {
            var v = property.FindPropertyRelative("x");

            v.floatValue = UnityEditor.EditorGUI.FloatField(position, label, v.floatValue);
        }
Example #27
0
    public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property,
                               UnityEngine.GUIContent label)
    {
        // Using BeginProperty / EndProperty on the parent property means that
        // prefab override logic works on the entire property.
        UnityEditor.EditorGUI.BeginProperty(position, label, property);

        var initialRect = position;

        position = UnityEditor.EditorGUI.PrefixLabel(position,
                                                     UnityEngine.GUIUtility.GetControlID(UnityEngine.FocusType.Passive),
                                                     new UnityEngine.GUIContent("Use Default Listeners:"));
        position.height = UnityEditor.EditorGUIUtility.singleLineHeight +
                          UnityEditor.EditorGUIUtility.standardVerticalSpacing;

        var useDefaultListenersProperty = property.FindPropertyRelative("useDefaultListeners");

        useDefaultListenersProperty.boolValue = UnityEngine.GUI.Toggle(position, useDefaultListenersProperty.boolValue, "");

        var listenerListProperty = property.FindPropertyRelative("initialListenerList");

        if (listenerListProperty.isArray)
        {
            position.height = UnityEditor.EditorGUIUtility.singleLineHeight +
                              UnityEditor.EditorGUIUtility.standardVerticalSpacing;

            for (var ii = 0; ii < listenerListProperty.arraySize; ++ii)
            {
                var listenerFieldWidth = initialRect.width - removeButtonWidth;
                position.y    += UnityEditor.EditorGUIUtility.singleLineHeight + UnityEditor.EditorGUIUtility.standardVerticalSpacing;
                position.x     = initialRect.x;
                position.width = listenerFieldWidth - listenerSpacerWidth;

                var listenerProperty = listenerListProperty.GetArrayElementAtIndex(ii);
                UnityEditor.EditorGUI.PropertyField(position, listenerProperty, new UnityEngine.GUIContent("Listener " + ii));

                position.x     = initialRect.x + listenerFieldWidth;
                position.width = removeButtonWidth;

                if (UnityEngine.GUI.Button(position, "X"))
                {
                    UnityEngine.GUIUtility.keyboardControl = 0;
                    UnityEngine.GUIUtility.hotControl      = 0;

                    listenerProperty.objectReferenceValue = null;
                    listenerListProperty.DeleteArrayElementAtIndex(ii);
                    --ii;
                }
            }

            position.x     = initialRect.x;
            position.width = initialRect.width;
            position.y    += UnityEditor.EditorGUIUtility.singleLineHeight + UnityEditor.EditorGUIUtility.standardVerticalSpacing +
                             UnityEditor.EditorGUIUtility.standardVerticalSpacing;

            if (UnityEngine.GUI.Button(position, "Add Listener"))
            {
                UnityEngine.GUIUtility.keyboardControl = 0;
                UnityEngine.GUIUtility.hotControl      = 0;

                var lastPosition = listenerListProperty.arraySize;
                listenerListProperty.arraySize = lastPosition + 1;

                // Avoid copying the previous last array element into the newly added last position
                var listenerProperty = listenerListProperty.GetArrayElementAtIndex(lastPosition);
                listenerProperty.objectReferenceValue = null;
            }
        }

        UnityEditor.EditorGUI.EndProperty();
    }
        public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
        {
            var value = property.FindPropertyRelative("value");

            UnityEditor.EditorGUI.PropertyField(position, value, label);
        }
Example #29
0
        public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
        {
            // Get unique control Id
            int controlId = UnityEngine.GUIUtility.GetControlID(label, UnityEngine.FocusType.Passive);

            UnityEditor.EditorGUI.BeginProperty(position, label, property);

            var wwiseObjectReference = property.FindPropertyRelative("WwiseObjectReference");

            HandleDragAndDrop(wwiseObjectReference, position);

            position = UnityEditor.EditorGUI.PrefixLabel(position, controlId, label);

            var style = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.button);

            style.alignment = UnityEngine.TextAnchor.MiddleLeft;
            style.fontStyle = UnityEngine.FontStyle.Normal;

            var componentName = GetComponentName(wwiseObjectReference);

            if (string.IsNullOrEmpty(componentName))
            {
                componentName          = "No " + WwiseObjectType + " is currently selected";
                style.normal.textColor = UnityEngine.Color.red;
            }

            if (UnityEngine.GUI.Button(position, componentName, style))
            {
                new AkWwiseComponentPicker.PickerCreator
                {
                    objectType           = WwiseObjectType,
                    wwiseObjectReference = wwiseObjectReference,
                    serializedObject     = property.serializedObject,
                    //Current selected object
                    currentWwiseObjectReference = GetWwiseObjectReference(wwiseObjectReference),
                    //We're currently clicking focus windows must be the right
                    pickedSourceEditorWindow = UnityEditor.EditorWindow.focusedWindow,
                    //Useful to control event source
                    pickedSourceControlId = controlId,
                    pickerPosition        = AkUtilities.GetLastRectAbsolute(position),
                };
            }

            // Check picker window close event and we're in the right drawer instance using control ID
            if (UnityEngine.Event.current.commandName == AkWwiseComponentPicker.PickerClosedEventName &&
                controlId == AkWwiseComponentPicker.GetObjectPickerControlID())
            {
                var oldValue = GetWwiseObjectReference(wwiseObjectReference);
                var newValue = AkWwiseComponentPicker.GetObjectPickerObjectReference();

                if (oldValue != newValue)
                {
                    // Serialized object updating
                    wwiseObjectReference.serializedObject.Update();
                    SetSerializedObject(wwiseObjectReference, newValue);
                    wwiseObjectReference.serializedObject.ApplyModifiedProperties();

                    // Force GUI modification, to send back to the base component drawer
                    UnityEngine.GUI.changed = true;
                }
            }

            UnityEditor.EditorGUI.EndProperty();
        }
Example #30
0
        /// <summary>
        /// return true if data altered
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        virtual public bool OnInspectorGUI(UCL_TC_Data iTC_Data, UnityEditor.SerializedProperty iSerializedProperty)
        {
            bool aIsDirty = false;
            Dictionary <Type, List <FieldInfo> > aFieldInfosDic = GetFieldInfosDic();

            if (iTC_Data.UpdateVersion(UpdateVersionAct))
            {
                aIsDirty = true;
            }

            Action <Type, List <FieldInfo> > aDrawData = delegate(Type iType, List <FieldInfo> iFieldInfos) {
                string aTypeName = iType.Name;
                var    aDatas    = iSerializedProperty.FindPropertyRelative("m_" + aTypeName);
                if (aDatas == null)
                {
                    //if (typeof(Component).IsAssignableFrom(iType))
                    //{
                    //    aDatas = iSerializedProperty.FindPropertyRelative("m_Component");
                    //}
                    //else
                    {
                        if (GUILayout.Button(new GUIContent(aTypeName + " not supported by UCL_TC_Data",
                                                            "Click this button to open UCL_TC_Data script.")))
                        {
                            //Assets/UCL/UCL_Modules/UCL_Tween/UCL_TweenScript/UCL_TweenBehaviors/UCL_TweenComponentDatas/UCL_TC_Data.cs
                            string sc_path = Core.FileLib.EditorLib.GetLibFolderPath(Core.FileLib.LibName.UCL_TweenLib)
                                             + "/UCL_TweenScript/UCL_TweenBehaviors/UCL_TweenComponentDatas/UCL_TC_Data.cs";
                            //Debug.Log("EaseScript:" + sc_path);
                            var aObj = UCL.Core.EditorLib.AssetDatabaseMapper.LoadMainAssetAtPath(sc_path);
                            if (aObj != null)
                            {
                                UnityEditor.Selection.activeObject = aObj;
                            }
                        }
                        //GUILayout.Box(type_name + " not support by UCL_TC_Data yet!!");
                        return;
                    }
                }
                while (iFieldInfos.Count > aDatas.arraySize)
                {
                    aDatas.InsertArrayElementAtIndex(aDatas.arraySize);
                    var aFieldInfo = iFieldInfos[aDatas.arraySize - 1];
                    if (aFieldInfo.FieldType.IsBool())
                    {
                        bool aNewVal = (bool)iFieldInfos[aDatas.arraySize - 1].GetValue(this);
                        //Debug.LogError("aNewVal:" + aNewVal+ ",aFieldInfo.Name:" + aFieldInfo.Name);
                        aDatas.GetArrayElementAtIndex(aDatas.arraySize - 1).boolValue = aNewVal;
                    }
                }
                while (iFieldInfos.Count < aDatas.arraySize)
                {
                    aDatas.DeleteArrayElementAtIndex(aDatas.arraySize - 1);
                }
                for (int i = 0; i < iFieldInfos.Count && i < aDatas.arraySize; i++)
                {
                    var    aInfo        = iFieldInfos[i];
                    var    aFieldName   = aInfo.Name;
                    string aDisplayName = aFieldName.StartsWith("m_") ? aFieldName.Remove(0, 2) : aFieldName;
                    var    aHeaderAttr  = aInfo.GetCustomAttribute <HeaderAttribute>();
                    if (aHeaderAttr != null)
                    {
                        GUILayout.Box(aHeaderAttr.header);
                    }
                    UnityEditor.EditorGUILayout.PropertyField(aDatas.GetArrayElementAtIndex(i),
                                                              new GUIContent(aDisplayName), true);
                }
            };

            foreach (var aType in aFieldInfosDic)
            {
                aDrawData(aType.Key, aType.Value);
            }

            return(aIsDirty);
        }