public void VariableSettings(BaseInteraction target) { GUILayout.Label("Variable conditions", EditorStyles.boldLabel); if(target.variableKey.Length > 0 || target.numberVarKey.Length > 0) { target.needed = (AIConditionNeeded)EditorGUILayout.EnumPopup("Needed", target.needed); target.autoDestroyOnVariables = EditorGUILayout.Toggle("Auto destroy", target.autoDestroyOnVariables); } if(GUILayout.Button("Add Variable", GUILayout.Width(150))) { target.AddVariableCondition(); } if(target.variableKey.Length > 0) { for(int i=0; i<target.variableKey.Length; i++) { EditorGUILayout.BeginHorizontal(); if(GUILayout.Button("Remove", GUILayout.Width(75))) { target.RemoveVariableCondition(i); return; } target.checkType[i] = EditorGUILayout.Toggle(target.checkType[i], GUILayout.Width(20)); target.variableKey[i] = EditorGUILayout.TextField(target.variableKey[i]); if(target.checkType[i]) GUILayout.Label("== "); else GUILayout.Label(" != "); target.variableValue[i] = EditorGUILayout.TextField(target.variableValue[i]); EditorGUILayout.EndHorizontal(); } } if(GUILayout.Button("Add Number Variable", GUILayout.Width(150))) { target.AddNumberVariableCondition(); } if(target.numberVarKey.Length > 0) { for(int i=0; i<target.numberVarKey.Length; i++) { EditorGUILayout.BeginHorizontal(); if(GUILayout.Button("Remove", GUILayout.Width(75))) { target.RemoveNumberVariableCondition(i); return; } target.numberCheckType[i] = EditorGUILayout.Toggle(target.numberCheckType[i], GUILayout.Width(20)); target.numberVarKey[i] = EditorGUILayout.TextField(target.numberVarKey[i]); if(!target.numberCheckType[i]) GUILayout.Label("not"); target.numberValueCheck[i] = (ValueCheck)EditorGUILayout.EnumPopup(target.numberValueCheck[i]); target.numberVarValue[i] = EditorGUILayout.FloatField(target.numberVarValue[i]); EditorGUILayout.EndHorizontal(); } } if(GUI.changed) EditorUtility.SetDirty(target); }
/// <summary> /// 인스펙터에서 공통적으로 사용될 Editor UI함수 - 시작 값이나 필요 값들을 설정하는 곳에 사용됨. /// </summary> /// <param name="p_Target"></param> public void VariableSettings(BaseInteraction p_Target) { //+ 타이틀. GUILayout.Label("Variable conditions", EditorStyles.boldLabel); //+ 필요 조건과 조건이 일회성으로 자동 삭제 될것인지 설정. if (p_Target.variableKey.Length > 0 || p_Target.numberVarKey.Length > 0) { p_Target.needed = (AIConditionNeeded)EditorGUILayout.EnumPopup("Needed", p_Target.needed); p_Target.autoDestroyOnVariables = EditorGUILayout.Toggle("Auto destroy", p_Target.autoDestroyOnVariables); } //+ 값 추가 버튼. if (GUILayout.Button("Add Variable", GUILayout.Width(150))) { p_Target.AddVariableCondition(); } if (p_Target.variableKey.Length > 0) { for (int i = 0; i < p_Target.variableKey.Length; i++) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Remove", GUILayout.Width(75))) { p_Target.RemoveVariableCondition(i); return; } //+값 설정. p_Target.checkType[i] = EditorGUILayout.Toggle(p_Target.checkType[i], GUILayout.Width(20)); p_Target.variableKey[i] = EditorGUILayout.TextField(p_Target.variableKey[i]); if (p_Target.checkType[i]) { GUILayout.Label("== "); } else { GUILayout.Label(" != "); } p_Target.variableValue[i] = EditorGUILayout.TextField(p_Target.variableValue[i]); EditorGUILayout.EndHorizontal(); } } //+ 숫자 값 추가. if (GUILayout.Button("Add Number Variable", GUILayout.Width(150))) { p_Target.AddNumberVariableCondition(); } if (p_Target.numberVarKey.Length > 0) { for (int i = 0; i < p_Target.numberVarKey.Length; i++) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Remove", GUILayout.Width(75))) { p_Target.RemoveNumberVariableCondition(i); return; } //+ 숫자 값 설정. p_Target.numberCheckType[i] = EditorGUILayout.Toggle(p_Target.numberCheckType[i], GUILayout.Width(20)); p_Target.numberVarKey[i] = EditorGUILayout.TextField(p_Target.numberVarKey[i]); if (!p_Target.numberCheckType[i]) { GUILayout.Label("not"); } p_Target.numberValueCheck[i] = (ValueCheck)EditorGUILayout.EnumPopup(p_Target.numberValueCheck[i]); p_Target.numberVarValue[i] = EditorGUILayout.FloatField(p_Target.numberVarValue[i]); EditorGUILayout.EndHorizontal(); } } //+ 수정된 것이 있다면 Dirty를 발생시켜 화면에 적용시켜 준다. if (GUI.changed) { EditorUtility.SetDirty(p_Target); } }