コード例 #1
0
        /// <summary>
        /// Returns the children classes of the supplied type.
        /// <param name="baseType">The base type.</param>
        /// <returns>The children classes of baseType.</returns>
        /// </summary>
        public static System.Type[] GetDerivedTypes(System.Type baseType)
        {
            // Create the derived type list
            var derivedTypes = new List <System.Type>();

            foreach (Assembly asm in TypeUtility.loadedAssemblies)
            {
                // Get types
                Type[] exportedTypes;

                try {
                    exportedTypes = asm.GetExportedTypes();
                }
                catch (ReflectionTypeLoadException) {
                    Print.LogWarning(string.Format("Behaviour Machine will ignore the following assembly due to type-loading errors: {0}", asm.FullName));
                    continue;
                }

                for (int i = 0; i < exportedTypes.Length; i++)
                {
                    // Get type
                    Type type = exportedTypes[i];
                    // The type is a subclass of baseType?
                    if (!type.IsAbstract && type.IsSubclassOf(baseType) && type.FullName != null)
                    {
                        derivedTypes.Add(type);
                    }
                }
            }
            derivedTypes.Sort((Type o1, Type o2) => o1.ToString().CompareTo(o2.ToString()));
            return(derivedTypes.ToArray());
        }
コード例 #2
0
        /// <summary>
        /// Unity callback called when the object becomes enabled and active.
        /// Enables the start state, if the start state is null then tries to enable the first one.
        /// </summary>
        public virtual void OnEnable()
        {
            #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
            #endif

            // Add this parent to the blackboard to receive system events
            if (isRoot)
            {
                blackboard.AddRootParent(this);
            }

            // Enable the concurrent state
            if (m_ConcurrentState != null && !m_ConcurrentState.enabled)
            {
                ((MonoBehaviour)m_ConcurrentState).enabled = true;
            }

            // There is not an enabled state?
            if (m_EnabledState == null || !m_EnabledState.enabled || m_EnabledState.parent != this)
            {
                // Enable the start state
                if (m_StartState != null && m_StartState.parent == this && !m_StartState.enabled)
                {
                    m_StartState.enabled = true;
                }
                // Try to get the first state
                else
                {
                    var states     = this.states;
                    var firstState = states.Count > 0 ? states[0] : null;
                    if (firstState != null && !(firstState is InternalAnyState))
                    {
                        m_StartState         = firstState;
                        m_StartState.enabled = true;
                        Print.LogWarning("Start State not set in \'" + stateName + "\', getting the first one \'" + m_StartState.name + "\' (" + m_StartState.GetType().Name + ").", this);
                    }
                    else
                    {
                        Print.LogError("No state in \'" + stateName + "\' (" + GetType().Name + ").", this);
                    }
                }
            }
        }
コード例 #3
0
ファイル: MissingNode.cs プロジェクト: pikaqiufk/Client
 public override Status Update()
 {
     Print.LogWarning("Missing Script Node: " + missingNodeType, tree);
     return(Status.Error);
 }
コード例 #4
0
 public override void Awake()
 {
     Print.LogWarning("Missing Node Script: " + missingNodeType, owner as UnityEngine.Object);
 }
コード例 #5
0
 /// <summary>
 /// Prints the obsolete message.
 /// </summary>
 public override void OnValidate()
 {
     base.OnValidate();
     Print.LogWarning("FsmBehaviour is obsolete, please use the StateMachine component. Drag and drop the Plugins/BehaviourMachine/Wrapper/StateMachine.cs script in the Script property of the FsmBehaviour.");
 }