当前位置: 首页>>代码示例>>C#>>正文


C# UnityEngine.Component类代码示例

本文整理汇总了C#中UnityEngine.Component的典型用法代码示例。如果您正苦于以下问题:C# Component类的具体用法?C# Component怎么用?C# Component使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Component类属于UnityEngine命名空间,在下文中一共展示了Component类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExtractRigInfo

 //Should only be created as part of our base framework
 public static AiRig ExtractRigInfo(Component c)
 {
     var rig = c.GetComponent<AiRig>();
     if (rig == null)
         c.GetComponentInParent<AiRig>();
     return rig;
 }
开发者ID:Miista,项目名称:TerrainGeneration,代码行数:8,代码来源:AiRig.cs

示例2: getAttributesFrom

 public override Dictionary<string, object> getAttributesFrom(Component component)
 {
     Dictionary<string, object> scriptAttributes = new Dictionary<string, object>();
     addScriptFieldsToDictionary (scriptAttributes, component);
     addScriptPropertiesToDictionary (scriptAttributes, component);
     return scriptAttributes;
 }
开发者ID:Raysangar,项目名称:BadPrincess-LevelEditor,代码行数:7,代码来源:ScriptAttributesGetter.cs

示例3: CreateChild

 public static Component CreateChild(this Transform parent, Component child)
 {
     Component go = GameObject.Instantiate(child);
     go.transform.SetParent(parent);
     go.transform.Reset();
     return go;
 }
开发者ID:quangthinhnguyen,项目名称:Unity3d-AMCore,代码行数:7,代码来源:TransformExtention.cs

示例4: Process

        public void Process(Component @object)
        {
            var label = (UILabel)@object;
            // 图片字体! 打包字
            if (label.bitmapFont != null)
            {
                string uiFontPath = KDepBuild_NGUI.BuildUIFont(label.bitmapFont);
                //CResourceDependencies.Create(label, CResourceDependencyType.BITMAP_FONT, uiFontPath);
                KAssetDep.Create<KBitmapFontDep>(label, uiFontPath);

                label.bitmapFont = null;
            }
            else if (label.trueTypeFont != null)
            {
                string fontPath = KDependencyBuild.BuildFont(label.trueTypeFont);

                //CResourceDependencies.Create(label, CResourceDependencyType.FONT, fontPath);
                KAssetDep.Create<KUILabelDep>(label, fontPath);
                label.trueTypeFont = null; // 挖空依赖的数据
            }
            else
            {
                Logger.LogWarning("找不到Label的字体: {0}, 场景: {1}", label.name, EditorApplication.currentScene);
            }
        }
开发者ID:s3chugo,项目名称:KEngine,代码行数:25,代码来源:KDepBuild_NGUI.cs

示例5: ComponentField

        public static Component ComponentField(Rect position, GUIContent label, Component value, System.Type inheritsFromType, bool allowSceneObjects, System.Type targetComponentType)
        {
            if (inheritsFromType == null) inheritsFromType = typeof(Component);
            else if (!typeof(Component).IsAssignableFrom(inheritsFromType) && !typeof(IComponent).IsAssignableFrom(inheritsFromType)) throw new TypeArgumentMismatchException(inheritsFromType, typeof(IComponent), "Type must inherit from IComponent or Component.", "inheritsFromType");
            if (targetComponentType == null) throw new System.ArgumentNullException("targetComponentType");
            if (!typeof(Component).IsAssignableFrom(targetComponentType)) throw new TypeArgumentMismatchException(targetComponentType, typeof(Component), "targetComponentType");
            if (value != null && !targetComponentType.IsAssignableFrom(value.GetType())) throw new TypeArgumentMismatchException(value.GetType(), inheritsFromType, "value must inherit from " + inheritsFromType.Name, "value");

            if (TypeUtil.IsType(inheritsFromType, typeof(Component)))
            {
                return EditorGUI.ObjectField(position, label, value, inheritsFromType, true) as Component;
            }
            else
            {
                value = EditorGUI.ObjectField(position, label, value, typeof(Component), true) as Component;
                var go = GameObjectUtil.GetGameObjectFromSource(value);
                if (go != null)
                {
                    foreach (var c in go.GetComponents(inheritsFromType))
                    {
                        if (TypeUtil.IsType(c.GetType(), targetComponentType))
                        {
                            return c as Component;
                        }
                    }
                }
            }

            return null;
        }
开发者ID:XianWorld,项目名称:spacepuppy-unity-framework,代码行数:30,代码来源:SPEditorGUI.cs

示例6: Start

        new void Start()
        {
            base.Start ();
            if (entity == null) {
                Debug.LogError("Serenity Method Trigger miss a gameObject");
                return;
            }
            if (method == null) {
                MethodInfo mi = entity.GetType().GetMethod(methodName);
                foreach(Component comp in entity.GetComponents<Component>()) {
                    mi = comp.GetType().GetMethod(methodName);
                    if(mi!=null)
                    {
                        component = comp;
                        break;
                    }
                }
                if(mi==null)
                {
                    Debug.LogError ("Serenity Method Trigger miss a boolean-returned method with name "+methodName);
                }
                else {

                    method = mi;
                }
            } else {
                methodName = method.Name;
            }
        }
开发者ID:TsubameDono,项目名称:Evolution,代码行数:29,代码来源:SerenityMethodTrigger.cs

示例7: Init

        public override void Init(Reactor reactor)
        {
            base.Init(reactor);

            ComponentMethod cm = null;
            try {
                cm = reactor.FindMethod(actionMethod);
            } catch (ArgumentNullException e) {
                Debug.LogError("[Action Node] Could not find method :" + actionMethod + "\n" + NodeNamesInStack());
                throw e;
            }
            if(cm == null) {
                Debug.LogError("Could not load action method: " + actionMethod);
            } else {
                if(cm.methodInfo.ReturnType == typeof(IEnumerator<NodeResult>)) {
                    component = cm.component;
                    methodInfo = cm.methodInfo;
                    if( methodParams != null )
                    {
                        methodParams.ConvertParams(methodInfo);
                    }
                } else {
                    Debug.LogError("Action method has invalid signature: " + actionMethod);
                }
            }
        }
开发者ID:s76,项目名称:testAI,代码行数:26,代码来源:Action.cs

示例8: Reset

 public override void Reset()
 {
     GameObject = null;
     Component = null;
     ScreenPosition = null;
     SendEvent = null;
 }
开发者ID:Jashengmato,项目名称:TouchScript,代码行数:7,代码来源:LongPressed.cs

示例9: FromComponent

        public static KISItemModuleWrapper FromComponent(Component component)
        {
            if (component != null)
                return new KISItemModuleWrapper(component);

            return null;
        }
开发者ID:zerosofadown,项目名称:Agile.Ksp,代码行数:7,代码来源:KISItemModuleWrapper.cs

示例10: WriteToJson

        public void WriteToJson(IResMgr resmgr, GameObject node, Component component, MyJson.JsonNode_Object json)
        {
            SkinnedMeshRenderer ic = component as SkinnedMeshRenderer;
            //json["type"] = new MyJson.JsonNode_ValueString(this.comptype.Name.ToLower());//必须的一行
            //放到外面去了

            //材质
            MyJson.JsonNode_Array mats = new MyJson.JsonNode_Array();

            json["mats"] = mats;

            foreach (var m in ic.sharedMaterials)
            {
                string hash = resmgr.SaveMat(m);
                mats.Add(new MyJson.JsonNode_ValueString(hash));
            }

            //bounds
            json["center"] = new MyJson.JsonNode_ValueString(StringHelper.ToString(ic.localBounds.center));
            json["size"] = new MyJson.JsonNode_ValueString(StringHelper.ToString(ic.localBounds.size));

            //mesh
            json["mesh"] = new MyJson.JsonNode_ValueString(resmgr.SaveMesh(ic.sharedMesh));

            json["rootboneobj"] = new MyJson.JsonNode_ValueNumber(ic.rootBone.gameObject.GetInstanceID());
            MyJson.JsonNode_Array bones = new MyJson.JsonNode_Array();
            foreach (var b in ic.bones)
            {
                bones.Add(new MyJson.JsonNode_ValueNumber(b.gameObject.GetInstanceID()));
            }
            json["boneobjs"] = bones;
            ic.rootBone.GetInstanceID();
        }
开发者ID:lightszero,项目名称:EgretUnity,代码行数:33,代码来源:ComponetParser_SkinnedMeshRenderer.cs

示例11: Reset

 public override void Reset()
 {
     GameObject = null;
     Component = null;
     ScreenFlickVector = null;
     SendEvent = null;
 }
开发者ID:Jashengmato,项目名称:TouchScript,代码行数:7,代码来源:Flicked.cs

示例12: Apply

        public object Apply(Type targetType, Injector activeInjector, Dictionary<string, object> injectParameters)
        {
            if (parentObject == null)
            {
                object contextViewObj = (IContextView) activeInjector.GetInstance(typeof(IContextView));
                if(contextViewObj != null)
                {
                    object contextView = ((IContextView) contextViewObj).view;
                    if(contextView != null)
                    {
                        if (contextView is Transform) parentObject = (Transform) contextView;
                        else if (contextView is GameObject) parentObject = ((GameObject) contextView).transform;
                    }
                }
            }
            if (parentObject == null)
            {
                destroyGameObjectWhenComplete = true;
                parentObject = new GameObject("Unity Component Provider").transform;
            }
            component = parentObject.gameObject.AddComponent(componentType);

            //TODO: Make auto InjectInto configurable
            activeInjector.InjectInto(component);

            if (_postApply != null)
            {
                _postApply(this, component);
            }
            return component;
        }
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:31,代码来源:UnityComponentProvider.cs

示例13: OnExecute

        /////////
        protected override Status OnExecute(Component agent, IBlackboard blackboard)
        {
            if (nestedFSM == null || nestedFSM.primeNode == null){
                return Status.Failure;
            }

            if (status == Status.Resting){
                CheckInstance();
            }

            if (status == Status.Resting || nestedFSM.isPaused){
                status = Status.Running;
                nestedFSM.StartGraph(agent, blackboard, OnFSMFinish);
            }

            if (!string.IsNullOrEmpty(successState) && nestedFSM.currentStateName == successState){
                nestedFSM.Stop();
                return Status.Success;
            }

            if (!string.IsNullOrEmpty(failureState) && nestedFSM.currentStateName == failureState){
                nestedFSM.Stop();
                return Status.Failure;
            }

            return status;
        }
开发者ID:nemish,项目名称:cubematters,代码行数:28,代码来源:NestedFSM.cs

示例14: OnExecute

        protected override Status OnExecute(Component agent, IBlackboard blackboard)
        {
            currentProbability = probability;
            for (var i = 0; i < outConnections.Count; i++){

                if (failedIndeces.Contains(i))
                    continue;

                if (currentProbability > childWeights[i].value){
                    currentProbability -= childWeights[i].value;
                    continue;
                }

                status = outConnections[i].Execute(agent, blackboard);
                if (status == Status.Success || status == Status.Running)
                    return status;

                if (status == Status.Failure){
                    failedIndeces.Add(i);
                    var newTotal = GetTotal();
                    for (var j = 0; j < failedIndeces.Count; j++){
                        newTotal -= childWeights[j].value;
                    }
                    probability = Random.Range(0, newTotal);
                    return Status.Running;
                }
            }

            return Status.Failure;
        }
开发者ID:nemish,项目名称:cubematters,代码行数:30,代码来源:ProbabilitySelector.cs

示例15: Serialize

 public ComponentData Serialize(Component component) {
     var placedItem = (PlacedItem) component;
     return new PlacedItemData {
         Id = placedItem.CatalogEntry.Id,
         Unique = placedItem.UniqueInSlot
     };
 }
开发者ID:Exosphir,项目名称:exosphir,代码行数:7,代码来源:PlacedItemConverter.cs


注:本文中的UnityEngine.Component类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。