Exemple #1
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        // Debug.Log(0);
        object parent = property.GetParent();

        if (parent == null)
        {
            Debug.Log("ERROR Null: " + property.displayName);
            return;
        }
        //   Debug.Log(1+ "target.varName"+ target.varName);
        FieldInfo fieldToCheck = parent.GetType().GetField(target.varName);

        if (fieldToCheck == null)
        {
            Debug.Log("ERROR Null: " + property.displayName);
            return;
        }
        if (target.DisplaceLevel != 0)
        {
            position.y += 18f * target.DisplaceLevel;
        }

        object objToCheck = fieldToCheck.GetValue(parent);

        //      Debug.Log(2+"value: "+ objToCheck.ToString());
        if (objToCheck == null || (objToCheck.ToString() != target.value.ToString()))
        {
            if (!target.skipLine)
            {
                target.hide(property.GetParent(), true);
            }
            //        Debug.Log(3);
        }
        else
        {
            //    Debug.Log(4+ label.text);
            target.hide(property.GetParent(), false);
            if (target.hideLabel)
            {
                EditorGUI.PropertyField(position, property, new GUIContent(""), true);

                // Debug.Log(5 + label.text);
            }
            else
            {
                if (target.labelWidth != 0f && target.labelWidth != 0f)
                {
                    ResponsiveDrawer.ResponsivePropertyField(position, property, label, target.labelWidth, target.valueWidth);
                }
                else
                {
                    EditorGUI.PropertyField(position, property, label, true);
                }
            }
        }
    }
Exemple #2
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        object value       = GetFieldValue(property, AttributeTarget.varName);
        bool   _guiEnabled = GUI.enabled;

        if (value.ToString() != AttributeTarget.ValueToCheck.ToString())
        {
            GUI.enabled = false;
        }
        if (AttributeTarget.labelWidth == 0f)
        {
            EditorGUI.PropertyField(position, property, true);
        }
        else
        {
            ResponsiveDrawer.ResponsivePropertyField(position, property, label, AttributeTarget.labelWidth, AttributeTarget.valueWidth);
        }

        GUI.enabled = _guiEnabled;
    }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        if (property.objectReferenceValue == null)
        {
            string tipo = property.type;
            tipo = tipo.Replace("PPtr<$", "");
            tipo = tipo.Replace(">", "");

            MonoBehaviour inspectedObject = (MonoBehaviour)property.serializedObject.targetObject;
            property.objectReferenceValue = inspectedObject.GetComponent(tipo);
            if (property.objectReferenceValue == null)
            {
                property.objectReferenceValue = GetComponentInChildren(inspectedObject.transform, tipo);
            }
            else
            {
                // Debug.Log("Component Obtained: " + tipo);
            }
            if (property.objectReferenceValue == null)
            {
                //Debug.Log("Component not found: " + tipo);
            }
        }
        if (target.force)
        {
            GUI.enabled = false;
        }


        if (target.labelWidth == 0f)
        {
            EditorGUI.PropertyField(position, property, label, true);
        }
        else
        {
            ResponsiveDrawer.ResponsivePropertyField(position, property, label, target.labelWidth, target.valueWidth);
        }
    }
Exemple #4
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        if (LastUpdate == Time.time && LastPosition == position.y)
        {
            position.y += position.height;
        }

        object parent = property.GetParent();

        if (parent == null)
        {
            return;
        }

        if (target.varName == null)
        {
            if (property.floatValue.ToString() != target.value.ToString())
            {
                if (target.labelWidth == 0f)
                {
                    EditorGUI.PropertyField(position, property, label, true);
                }
                else
                {
                    ResponsiveDrawer.ResponsivePropertyField(position, property, label, target.labelWidth, target.valueWidth);
                }
                target.skipLine = false;
                target.hide(parent, false);
            }
            else
            {
                target.skipLine = true;
                target.hide(parent, true);
            }
            return;
        }

        FieldInfo fieldToCheck = parent.GetType().GetField(target.varName);
        object    obj          = fieldToCheck.GetValue(parent);

        if (obj.ToString() == target.value.ToString())
        {
            if (target.skipLine)
            {
                target.hide(parent, true);
            }
        }
        else
        {
            target.hide(parent, false);

            if (target.readOnly)
            {
                GUI.enabled = false;
            }

            EditorGUI.PropertyField(position, property, label, true);
        }
        //   Debug.Log(property.name+" - "+Time.time);
        LastUpdate   = Time.time;
        LastPosition = position.y;
    }