コード例 #1
0
ファイル: ActorCoreEditor.cs プロジェクト: vRNI/StealthGame
    /// <summary>
    /// Called when the object is selected in the editor
    /// </summary>
    private void OnEnable()
    {
        // Grab the serialized objects
        mTarget   = (ActorCore)target;
        mTargetSO = new SerializedObject(target);

        // Update the effects so they can update with the definitions.
        if (!UnityEngine.Application.isPlaying)
        {
            mTarget.InstantiateStates();
            mTarget.InstantiateReactors();
            mTarget.InstantiateEffects();
        }

        // Create the list of items to display
        InstantiateStateList();

        // Generate the list to display
        Assembly lReactorAssembly = Assembly.GetAssembly(typeof(ReactorAction));

        Type[] lReactorTypes = lReactorAssembly.GetTypes().OrderBy(x => x.Name).ToArray <Type>();
        for (int i = 0; i < lReactorTypes.Length; i++)
        {
            Type lType = lReactorTypes[i];
            if (lType.IsAbstract)
            {
                continue;
            }
            if (typeof(ReactorAction).IsAssignableFrom(lType))
            {
                mReactorTypes.Add(lType);
                mReactorNames.Add(BaseNameAttribute.GetName(lType));
            }
        }

        // Create the list of items to display
        InstantiateReactorList();

        // Generate the list to display
        Assembly lEffectAssembly = Assembly.GetAssembly(typeof(ActorCoreEffect));

        Type[] lEffectTypes = lEffectAssembly.GetTypes().OrderBy(x => x.Name).ToArray <Type>();
        for (int i = 0; i < lEffectTypes.Length; i++)
        {
            Type lType = lEffectTypes[i];
            if (lType.IsAbstract)
            {
                continue;
            }
            if (typeof(ActorCoreEffect).IsAssignableFrom(lType))
            {
                mEffectTypes.Add(lType);
                mEffectNames.Add(BaseNameAttribute.GetName(lType));
            }
        }

        // Create the list of items to display
        InstantiateEffectList();
    }
コード例 #2
0
    /// <summary>
    /// Allows us to add to a list
    /// </summary>
    /// <param name="rList"></param>
    private void OnStateListItemAdd(ReorderableList rList)
    {
        //if (mStateIndex >= mStateTypes.Count) { return; }

        //ActorCoreState lItem = Activator.CreateInstance(mStateTypes[mStateIndex]) as ActorCoreState;
        ActorCoreState lItem = new ActorCoreState();

        //lItem.ActorCore = mTarget;

        mTarget._States.Add(lItem);
        mTarget.InstantiateStates();

        mStateList.index = mTarget._States.Count - 1;
        OnStateListItemSelect(rList);

        mIsDirty = true;
    }
コード例 #3
0
    /// <summary>
    /// Called when the object is selected in the editor
    /// </summary>
    private void OnEnable()
    {
        // Grab the serialized objects
        mTarget   = (ActorCore)target;
        mTargetSO = new SerializedObject(target);

        // Update the effects so they can update with the definitions.
        if (!UnityEngine.Application.isPlaying)
        {
            mTarget.InstantiateStates();
            mTarget.InstantiateReactors();
            mTarget.InstantiateEffects();
        }

        // Create the list of items to display
        InstantiateStateList();

        // CDL 06 / 28 / 2018 - this only scans the assembly containing ReactorAction
        //// Generate the list to display
        //Assembly lReactorAssembly = Assembly.GetAssembly(typeof(ReactorAction));
        //Type[] lReactorTypes = lReactorAssembly.GetTypes().OrderBy(x => x.Name).ToArray<Type>();
        //for (int i = 0; i < lReactorTypes.Length; i++)
        //{
        //    Type lType = lReactorTypes[i];
        //    if (lType.IsAbstract) { continue; }
        //    if (typeof(ReactorAction).IsAssignableFrom(lType))
        //    {
        //        mReactorTypes.Add(lType);
        //        mReactorNames.Add(BaseNameAttribute.GetName(lType));
        //    }
        //}

        // CDL 06 / 28 / 2018 - scan all assemblies for Reactors  and Actor Core Effects
        List <Type> lFoundTypes = AssemblyHelper.FoundTypes;

        for (int i = 0; i < lFoundTypes.Count; i++)
        {
            Type lType = lFoundTypes[i];
            if (lType.IsAbstract)
            {
                continue;
            }
            if (typeof(ReactorAction).IsAssignableFrom(lType))
            {
                mReactorTypes.Add(lType);
                mReactorNames.Add(BaseNameAttribute.GetName(lType));
            }
            else if (typeof(ActorCoreEffect).IsAssignableFrom(lType))
            {
                mEffectTypes.Add(lType);
                mEffectNames.Add(BaseNameAttribute.GetName(lType));
            }
        }

        // Create the list of items to display
        InstantiateReactorList();

        // CDL 06 / 28 / 2018 - this only scans the assembly containing ActorCoreEffect
        //// Generate the list to display
        //Assembly lEffectAssembly = Assembly.GetAssembly(typeof(ActorCoreEffect));
        //Type[] lEffectTypes = lEffectAssembly.GetTypes().OrderBy(x => x.Name).ToArray<Type>();
        //for (int i = 0; i < lEffectTypes.Length; i++)
        //{
        //    Type lType = lEffectTypes[i];
        //    if (lType.IsAbstract) { continue; }
        //    if (typeof(ActorCoreEffect).IsAssignableFrom(lType))
        //    {
        //        mEffectTypes.Add(lType);
        //        mEffectNames.Add(BaseNameAttribute.GetName(lType));
        //    }
        //}

        // Create the list of items to display
        InstantiateEffectList();
    }