private void InitFsmVars() { GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.gameObject); if (ownerDefaultTarget == null) { return; } if (ownerDefaultTarget != this.cachedGO) { this.sourceVariables = new INamedVariable[this.getVariables.Length]; this.targetVariables = new NamedVariable[this.getVariables.Length]; for (int i = 0; i < this.getVariables.Length; i++) { string variableName = this.getVariables[i].variableName; this.sourceFsm = ActionHelpers.GetGameObjectFsm(ownerDefaultTarget, this.fsmName.Value); this.sourceVariables[i] = this.sourceFsm.FsmVariables.GetVariable(variableName); this.targetVariables[i] = base.Fsm.Variables.GetVariable(variableName); this.getVariables[i].Type = FsmUtility.GetVariableType(this.targetVariables[i]); if (!string.IsNullOrEmpty(variableName) && this.sourceVariables[i] == null) { base.LogWarning("Missing Variable: " + variableName); } this.cachedGO = ownerDefaultTarget; } } }
void InitFsmVars() { var go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { return; } if (go != cachedGO) { sourceVariables = new INamedVariable[getVariables.Length]; targetVariables = new NamedVariable[getVariables.Length]; for (var i = 0; i < getVariables.Length; i++) { var variableName = getVariables[i].variableName; sourceFsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); sourceVariables[i] = sourceFsm.FsmVariables.GetVariable(variableName); targetVariables[i] = Fsm.Variables.GetVariable(variableName); getVariables[i].Type = FsmUtility.GetVariableType(targetVariables[i]); if (!string.IsNullOrEmpty(variableName) && sourceVariables[i] == null) { LogWarning("Missing Variable: " + variableName); } cachedGO = go; } } }
void InitFsmVar() { var go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { return; } if (go != cachedGO) { sourceFsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); sourceVariable = sourceFsm.FsmVariables.GetVariable(setValue.variableName); targetVariable = Fsm.Variables.GetVariable(setValue.variableName); setValue.Type = FsmUtility.GetVariableType(targetVariable); if (!string.IsNullOrEmpty(setValue.variableName) && sourceVariable == null) { LogWarning("Missing Variable: " + setValue.variableName); } cachedGO = go; } }
public override void OnGUI(SerializedProperty property, GUIContent label) { SerializedProperty componentProperty = property.serializedObject.FindProperty("component"); SerializedProperty propProperty = property.serializedObject.FindProperty("property"); SerializedProperty parameterProperty = property.serializedObject.FindProperty("parameter"); GUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(componentProperty); ComponentHint(componentProperty, propProperty); GUILayout.EndHorizontal(); if (!string.IsNullOrEmpty(componentProperty.stringValue)) { Type componentType = TypeUtility.GetType(componentProperty.stringValue); if (componentType != null) { GUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(propProperty); PropertyHint(propProperty, componentType); GUILayout.EndHorizontal(); if (!string.IsNullOrEmpty(propProperty.stringValue)) { Type variableType = FsmUtility.GetVariableType(TypeUtility.GetMemberType(componentType, propProperty.stringValue)); Debug.Log(variableType); if (variableType != null) { fieldInfo = property.serializedObject.targetObject.GetType().GetField("parameter"); if (parameterProperty.objectReferenceValue == null || parameterProperty.objectReferenceValue.GetType() != variableType) { FsmEditorUtility.DestroyImmediate(parameterProperty.objectReferenceValue as FsmVariable); FsmVariable variable = ScriptableObject.CreateInstance(variableType) as FsmVariable; variable.hideFlags = HideFlags.HideInHierarchy; if (EditorUtility.IsPersistent(parameterProperty.serializedObject.targetObject)) { AssetDatabase.AddObjectToAsset(variable, property.serializedObject.targetObject); AssetDatabase.SaveAssets(); } variable.IsShared = fieldInfo.HasAttribute(typeof(SharedAttribute)) || EditorUtility.IsPersistent(variable) && fieldInfo.HasAttribute(typeof(SharedPersistentAttribute)) || variable is FsmArray; parameterProperty.serializedObject.Update(); parameterProperty.objectReferenceValue = variable; parameterProperty.serializedObject.ApplyModifiedProperties(); } base.OnGUI(parameterProperty, new GUIContent("Parameter")); } } } } }
private void InitFsmVar() { GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.gameObject); if (ownerDefaultTarget == null) { return; } if (ownerDefaultTarget != this.cachedGO) { this.sourceFsm = ActionHelpers.GetGameObjectFsm(ownerDefaultTarget, this.fsmName.Value); this.sourceVariable = this.sourceFsm.FsmVariables.GetVariable(this.storeValue.variableName); this.targetVariable = base.Fsm.Variables.GetVariable(this.storeValue.variableName); this.storeValue.Type = FsmUtility.GetVariableType(this.targetVariable); if (!string.IsNullOrEmpty(this.storeValue.variableName) && this.sourceVariable == null) { base.LogWarning("Missing Variable: " + this.storeValue.variableName); } this.cachedGO = ownerDefaultTarget; } }