コード例 #1
0
        protected override void OnBuildGui(ref Rect position, SerializedProperty property, GUIContent label)
        {
            bool drawCreateButton  = GetPropertyTypeName(property) != "IVariableSO" && SO.Zisettings.Inistance.ShowAssignButton;
            bool drawVariabelValue = SO.Zisettings.Inistance.ShowVarSOValue;

            variableSORef = (VariableSO)SORef;
            CalculateLAyout(ref position);

            //  uncomment to debug draw area ------------------------------------------------------
            // DebugDrawArea(position);

            //first field --------------------------------------
            if (variableSORef)//hase value
            {
                if (drawVariabelValue)
                {
                    //value inside variableSO
                    VraiableField(leftRow, label, variableSORef); //input field
                }
                else
                {
                    AddProberty(ref position, property, label);
                }
            }
            else //no value
            {
                if (drawCreateButton)
                {
                    AddProberty(ref leftRow, property, label);
                }
                else
                {
                    AddProberty(ref position, property, label);
                }
            }

            //secound field-------------------------------------------
            EditorGUI.indentLevel       = 0;
            EditorGUIUtility.labelWidth = .1f;
            if (variableSORef)//hase value
            {
                if (drawVariabelValue)
                {
                    //VariableSO refrence
                    AddProberty(ref rightRow, property, new GUIContent(" "));
                }
            }
            else
            {
                if (drawCreateButton)
                {
                    if (GUI.Button(rightRow, "Assign"))
                    {
                        UnityEngine.Object soVar = AutoAssignSO(label.text, getCreatePath(), property);
                        //assing to the current property
                        property.objectReferenceValue = soVar;
                    }
                }
            }
        }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            //Draw the defualt inspector options
            DrawDefaultInspector();

            VariableSO <T> script = (VariableSO <T>)target;

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            EditorGUILayout.LabelField("Debugging Options", EditorStyles.centeredGreyMiniLabel);

            EditorGUILayout.LabelField("Current Value: " + script.Value, EditorStyles.boldLabel);

            EditorGUILayout.BeginHorizontal();

            //Display a int input field and button to add the inputted Value to the current Value
            ModifyValue = GetEditorGUILayoutValue(ModifyValue);

            //  EditorGUILayout.PropertyField(serializedObject.FindProperty("value"));
            //  serializedObject.ApplyModifiedProperties();
            // script.se
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();

            if (!EqualityComparer <T> .Default.Equals(script.GetValue(), ModifyValue))
            {
                if (GUILayout.Button("Modify"))
                {
                    script.SetValue(ModifyValue);
                }
            }
            EditorGUILayout.EndHorizontal();

            //Display button that resets the Value to the starting Value
            if (GUILayout.Button("Reset Value"))
            {
                if (EditorApplication.isPlaying)
                {
                    script.ResetValue();
                }
            }
            EditorGUILayout.EndVertical();
        }
コード例 #3
0
 protected virtual void VraiableField(Rect Position, GUIContent label, VariableSO variableSO)
 {
     if (variableSO.ToString("ID") == "ID" || variableSO.ToString("ID") == "-ID") //check if formating made issue with data
     {
         float ParsedNum;
         if (float.TryParse(variableSO.ToString(), out ParsedNum))
         {
             variableSO.SetValue(EditorGUI.FloatField(Position, label, ParsedNum).ToString());
         }
         else
         {
             variableSO.SetValue(EditorGUI.TextField(Position, label, variableSO.ToString()));
         }
     }
     else
     {
         variableSO.SetValue(EditorGUI.TextField(Position, label, variableSO.ToString("ID")));
     }
 }
コード例 #4
0
 public void SetValue(VariableSO <T> numSO)
 {
     SetValue(numSO.Value);
 }
コード例 #5
0
        protected override void VraiableField(Rect position, GUIContent label, VariableSO variableSO)
        {
            var varRefrence = (Vector3SO)variableSO;

            varRefrence.Value = EditorGUI.Vector3Field(position, label, varRefrence.Value);
        }
コード例 #6
0
        protected override void VraiableField(Rect position, GUIContent label, VariableSO variableSO)
        {
            var varRefrence = (GameObjectSO)variableSO;

            varRefrence.Value = (GameObject)EditorGUI.ObjectField(position, label, varRefrence.Value, typeof(GameObject), true);
        }